Bluetooth module class. More...
#include <BluetoothModule.h>
Public Member Functions | |
virtual | ~BluetoothModule () |
Class destructor. | |
virtual bool | shutdown ()=0 |
virtual std::string | getLocalMac ()=0 |
virtual std::string | getVersion ()=0 |
virtual void | setEnabled (bool enabled)=0 |
virtual bool | connectSPP (int idConn, unsigned char *dstAddr, unsigned char dstPort)=0 |
virtual bool | listenSPP (int idConn)=0 |
virtual bool | disconnectSPP (int idConn)=0 |
virtual bool | addSDPRecord (int localPort, void *data, size_t len)=0 |
virtual bool | sendSPPData (int connid, const void *data, size_t len)=0 |
int | registerSPPConnection (BluetoothSPPConnection *conn) |
Register SPP connection. | |
bool | registerIncomingSPPConnection (BluetoothSPPConnection *conn) |
Register listening SPP connection. | |
void | deregisterSPPConnection (int idConn) |
Unregister a bluetooth SPP connection. | |
BluetoothSPPConnection * | createSPPConnection (const unsigned char *dstAddr, int dstPort, const char *pin) |
Create a new SPP connection. | |
BluetoothSPPConnection * | createIncomingSPPConnection (int localPort) |
Listen for a new SPP connection. | |
bool | setIncomingPin (const char *pin) |
Set the pin code for incoming connection request Sets the pin code when incoming connection request is received. | |
Static Public Member Functions | |
static BluetoothModule * | getModule () |
Return the bluetooth module object Returns pointer to the instance of BluetoothModule class. | |
Protected Member Functions | |
BluetoothModule () | |
Class constructor. | |
void | sendIncomingData (BluetoothSPPConnection *pConn, void *buf, size_t len) |
Forward incoming data to BluetoothSPPConnection object. | |
void | setConnectionState (BluetoothSPPConnection *pConn, SPP_CONN_STATUS state) |
Forward connection state to BluetoothSPPConnection object. | |
Protected Attributes | |
Mutex | connMutex |
BluetoothSPPConnection * | connections [MAX_BT_CONNECTIONS] |
char | incomingPin [MAX_BT_PIN] |
Static Protected Attributes | |
static BluetoothModule * | pModule = NULL |
Friends | |
class | BluetoothSPPConnection |
Bluetooth module class.
Implements the generic Bluetooth subsystem interfaces. Other classes will be derived from it to support specific Bluetooth modules.
BluetoothModule::~BluetoothModule | ( | ) | [virtual] |
Class destructor.
Terminates the LMX Bluetooth module object.
BluetoothModule::BluetoothModule | ( | ) | [protected] |
Class constructor.
Virtual constructor for BluetoothModule class
virtual bool BluetoothModule::addSDPRecord | ( | int | localPort, | |
void * | data, | |||
size_t | len | |||
) | [pure virtual] |
Reader implementation should override this function to implement method for storing a new service record in local service discovery database
localPort | Local port used by the service | |
data | Pointer to the data to be used | |
len | Data length |
Implemented in LMXBluetoothModule.
virtual bool BluetoothModule::connectSPP | ( | int | idConn, | |
unsigned char * | dstAddr, | |||
unsigned char | dstPort | |||
) | [pure virtual] |
Reader implementation should override this function to implement method for connecting the device over SPP (Serial Port Protocol).
idConn | Connection ID to be used | |
dstAddr | Address of the destination device | |
dstPort | Port of the destination device |
Implemented in LMXBluetoothModule.
BluetoothSPPConnection * BluetoothModule::createIncomingSPPConnection | ( | int | localPort | ) |
Listen for a new SPP connection.
Creates a new listening SPP connection with given parameters; returns pointer to that connection object. The object is in disconnected state and flips to connected state as soon as any incoming connection is received.
localPort | Service port to listen on |
BluetoothSPPConnection * BluetoothModule::createSPPConnection | ( | const unsigned char * | dstAddr, | |
int | dstPort, | |||
const char * | pin | |||
) |
Create a new SPP connection.
Creates a new SPP connection with given parameters; returns pointer to that connection object.
dstAddr | Destination BDADDR to connect to | |
dstPort | Destination service port to connect to | |
pin | Destination device's PIN code |
void BluetoothModule::deregisterSPPConnection | ( | int | idConn | ) |
Unregister a bluetooth SPP connection.
Unregisters a bluetooth SPP connection in the LMXBluetoothModule
idConn | Connection ID that should be unregistered |
virtual bool BluetoothModule::disconnectSPP | ( | int | idConn | ) | [pure virtual] |
Reader implementation should override this function to implement method for disconnecting the SPP link
idConn | Connection ID that should be disconnected |
Implemented in LMXBluetoothModule.
virtual std::string BluetoothModule::getLocalMac | ( | ) | [pure virtual] |
Reader implementation should override this function to implement method for reading device MAC address.
Implemented in LMXBluetoothModule.
static BluetoothModule* BluetoothModule::getModule | ( | ) | [inline, static] |
Return the bluetooth module object Returns pointer to the instance of BluetoothModule class.
virtual std::string BluetoothModule::getVersion | ( | ) | [pure virtual] |
Reader implementation should override this function to implement method for retrieving reader's bluetooth protocol version.
Implemented in LMXBluetoothModule.
virtual bool BluetoothModule::listenSPP | ( | int | idConn | ) | [pure virtual] |
Reader implementation should override this function to implement method for putting the device into listening mode
idConn | Connection ID that should be used for listening incoming packets |
Implemented in LMXBluetoothModule.
bool BluetoothModule::registerIncomingSPPConnection | ( | BluetoothSPPConnection * | conn | ) |
Register listening SPP connection.
Register a new SPP connection pointer in LMXBluetoothModule.
conn | Pointer to the bluetooth connection object |
int BluetoothModule::registerSPPConnection | ( | BluetoothSPPConnection * | conn | ) |
Register SPP connection.
Register a new SPP connection pointer in LMXBluetoothModule.
conn | Pointer to the bluetooth connection object |
void BluetoothModule::sendIncomingData | ( | BluetoothSPPConnection * | pConn, | |
void * | buf, | |||
size_t | len | |||
) | [protected] |
Forward incoming data to BluetoothSPPConnection object.
Forwards incoming SPP data to the buffer in the connection object.
pConn | Pointer to the connection object that must receive the data | |
buf | Pointer to the buffer which contents must be forwarded | |
len | Buffer size |
virtual bool BluetoothModule::sendSPPData | ( | int | connid, | |
const void * | data, | |||
size_t | len | |||
) | [pure virtual] |
Reader implementation should override this function to implement method for sending the SDP data to over the bluetooth connection
connid | Connection ID, returned on SPP connection registration | |
data | Data to be sent over SPP link | |
len | Data length |
Implemented in LMXBluetoothModule.
void BluetoothModule::setConnectionState | ( | BluetoothSPPConnection * | pConn, | |
SPP_CONN_STATUS | state | |||
) | [protected] |
Forward connection state to BluetoothSPPConnection object.
Forwards connection state events to connection object.
pConn | Pointer to the connection object that must receive the connection state events | |
state | The new state that will be set |
virtual void BluetoothModule::setEnabled | ( | bool | enabled | ) | [pure virtual] |
Reader implementation should override this function to set the device into enabled or disabled state.
enabled | If set to true, the bluetooth device will be enabled. If set to false, the bluetooth device will be disabled. |
Implemented in LMXBluetoothModule.
bool BluetoothModule::setIncomingPin | ( | const char * | newpin | ) |
Set the pin code for incoming connection request Sets the pin code when incoming connection request is received.
newpin | Pointer to pin code to use for the connection |
virtual bool BluetoothModule::shutdown | ( | ) | [pure virtual] |
Reader implementation should override this function to implement a hardware uninitialization procedure. Reader manager calls this function during system shutdown.
Implemented in LMXBluetoothModule.
BluetoothSPPConnection* BluetoothModule::connections[MAX_BT_CONNECTIONS] [protected] |
List of bluetooth connections associated with the BluetoothModule class instance
Mutex BluetoothModule::connMutex [protected] |
Mutex to protect SPP connection list
char BluetoothModule::incomingPin[MAX_BT_PIN] [protected] |
Incoming PIN code
BluetoothModule * BluetoothModule::pModule = NULL [static, protected] |
Static variable to hold the pointer to the instance of BluetoothModule class