Enki::Bluetooth Class Reference
[Interaction classes]

#include <Bluetooth.h>

Inheritance diagram for Enki::Bluetooth:

Enki::GlobalInteraction List of all members.

Detailed Description

Implementation of an onboard Bluetooth module.


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.
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.

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.

Friends

class BluetoothBase


Member Enumeration Documentation

enum Enki::Bluetooth::Errors

Error that bluetooth communication can produce.

Enumerator:
BT_NO_ERROR  No error occured during the last step.
ADDRESS_UNKNOWN  The address used was unknown.
DISTANCE_EXCEEDED  The distance between the 2 robots is too great.
TOO_MANY_CONNECTIONS  No additional connection can be made as the robot is already at maximum.
RECEPTION_BUFFER_FULL  The reception buffer is full and no additional data can be written.


Constructor & Destructor Documentation

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.


The documentation for this class was generated from the following files:
Generated on Sun Mar 1 03:10:09 2009 for Enki by  doxygen 1.5.1