|
Enki
1.9
|
Implementation of an onboard Bluetooth module. More...
#include <Bluetooth.h>
Public Types | |
| enum | Errors { BT_NO_ERROR = 0, ADDRESS_UNKNOWN = 1, DISTANCE_EXCEEDED = 2, TOO_MANY_CONNECTIONS = 3, RECEPTION_BUFFER_FULL = 4 } |
| Error that bluetooth communication can produce. More... | |
Public Member Functions | |
| Bluetooth (Robot *owner, double range, unsigned maxConnections, unsigned rxbuffersize, unsigned txbuffersize, unsigned address) | |
| Constructor e.g. More... | |
| virtual | ~Bluetooth () |
| Destructor. | |
| virtual void | step (double dt, World *w) |
| On every timestep, send the commands recorded to the bluetooth Base to be executed. | |
| void | setAddress (unsigned address) |
| Change the address of the module. | |
| unsigned | getAddress () |
| Return the address of the module. | |
| void | connectTo (unsigned address) |
| Initiate a connection with another module. | |
| bool | closeConnection (unsigned index) |
| Close an established connection with another module. | |
| bool | didIReceive () |
| Indicate if data was received during the last step. | |
| bool | didIReceive (unsigned source) |
| Indicate if data from the module having the address "source" was received during the last step. | |
| bool * | getReceptionFlags () |
| Return the reception flags indicating from which module data was received. | |
| const char * | getRxBuffer (unsigned source) |
| Return the reception buffer associated with another module of address "source". | |
| unsigned | getSizeReceived (unsigned source) |
| Return the amount of data received from another module of address "source" during the last step. | |
| bool | sendDataTo (unsigned dest, char *data, unsigned size) |
| Send data to the module of address "dest". | |
| unsigned * | getTransmissionError () |
| Return the flags indicating on which connection a transmission error occured. | |
| bool | isThereTxError () |
| Indicate if an error of transmission occured during the last step. | |
| unsigned | getConnectionError () |
| Return the status of the connection error flag. | |
| unsigned | getDisconnectionError () |
| Return the status of the disconnection error flag. | |
| unsigned | getTxBufferSize () |
| Return the size of the transmission buffers. | |
| void | changeTxBufferSize (unsigned size) |
| Modify the size of the transmission buffers. | |
| unsigned | getRxBufferSize () |
| Return the size of the reception buffers. | |
| void | changeRxBufferSize (unsigned size) |
| Modify the size of the reception buffers. | |
| unsigned | getMaxConnections () |
| Return the maximum number of simultaneous connections supported by this module. | |
| void | changeMaxConnections (unsigned size) |
| Change the maximum number of simultaneous connections supported by this module. | |
| unsigned | getNbConnections () |
| Return the number of established connections to other modules. | |
| unsigned * | getConnectedAddresses () |
| Return the addresses of the other connected modules. | |
Public Member Functions inherited from Enki::GlobalInteraction | |
| GlobalInteraction () | |
| Constructor. | |
| GlobalInteraction (Robot *owner) | |
| Constructor. | |
| virtual | ~GlobalInteraction () |
| Destructor. | |
| virtual void | init (double dt, World *w) |
| Init at each step. | |
| virtual void | finalize (double dt, World *w) |
| Finalize at each step. | |
Protected Member Functions | |
| void | cancelRxBuffer () |
| Deallocate the memory dedicated for the reception buffer. | |
| void | cancelTxBuffer () |
| Deallocate the memory dedicated for the transmission buffer. | |
| void | cancelAllData () |
| Deallocate all the memory. | |
| void | initAllData () |
| Initialise all the data structure requires by the module. | |
Protected Attributes | |
| double | range |
| Range of the interaction. | |
| unsigned | nbConnections |
| Number of connections currently established. | |
| unsigned | maxConnections |
| Maximum number of simultaneous connections supported. | |
| unsigned | address |
| Address of the Bluetooth module. | |
| char ** | rxBuffer |
| Reception buffers for data coming from other connected modules. | |
| char ** | txBuffer |
| Transmission buffers for data sent to other connected modules. | |
| unsigned | rxBufferSize |
| Size of each buffer for the reception of data. | |
| unsigned | txBufferSize |
| Size of each buffer for the transmission of data. | |
| bool * | receptionFlags |
| Flags signalling the reception of data. | |
| unsigned * | destAddress |
| Addresses of the connected modules. | |
| unsigned * | sizeToSend |
| Size of the data to send. | |
| unsigned * | sizeReceived |
| Size of the data received. | |
| bool | updateAddress |
| Flag indicating a change in the address of the module. | |
| bool | randomAddress |
| Flag indicating that the current address has been assigned randomly. | |
| std::queue< unsigned > | connectToRobot |
| Queue containing request for connection to other modules. | |
| std::queue< unsigned > | closeConnectionToRobot |
| Queue containing request for closing the connection with other modules. | |
| unsigned * | transmissionError |
| Flags indicating transmission errors. | |
| char | connectionError |
| Flag indicating an error involving the connection toward another robot. | |
| char | disconnectionError |
| Flag indicating an error involving the disconnection from another robot. | |
Protected Attributes inherited from Enki::GlobalInteraction | |
| Robot * | owner |
| The physical object that owns the interaction. | |
Friends | |
| class | BluetoothBase |
Implementation of an onboard Bluetooth module.
Error that bluetooth communication can produce.
| Enki::Bluetooth::Bluetooth | ( | Robot * | owner, |
| double | range, | ||
| unsigned | maxConnections, | ||
| unsigned | rxbuffersize, | ||
| unsigned | txbuffersize, | ||
| unsigned | address | ||
| ) |
Constructor e.g.
: "bluetooth(this,10000,7,100,10,1)" for a module of address 1 with a range of 10 meters, 7 supporting simultaneous connections capable of receiving packets of 100 bytes and emitting packets of 10 bytes.
References address, BT_NO_ERROR, connectionError, disconnectionError, initAllData(), maxConnections, nbConnections, Enki::GlobalInteraction::owner, randomAddress, range, rxBufferSize, txBufferSize, and updateAddress.
1.8.11