BluetoothModule Class Reference

Bluetooth module class. More...

#include <BluetoothModule.h>

Inheritance diagram for BluetoothModule:
LMXBluetoothModule

List of all members.

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.
BluetoothSPPConnectioncreateSPPConnection (const unsigned char *dstAddr, int dstPort, const char *pin)
 Create a new SPP connection.
BluetoothSPPConnectioncreateIncomingSPPConnection (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 BluetoothModulegetModule ()
 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
BluetoothSPPConnectionconnections [MAX_BT_CONNECTIONS]
char incomingPin [MAX_BT_PIN]

Static Protected Attributes

static BluetoothModulepModule = NULL

Friends

class BluetoothSPPConnection

Detailed Description

Bluetooth module class.

Implements the generic Bluetooth subsystem interfaces. Other classes will be derived from it to support specific Bluetooth modules.


Constructor & Destructor Documentation

BluetoothModule::~BluetoothModule (  )  [virtual]

Class destructor.

Terminates the LMX Bluetooth module object.

BluetoothModule::BluetoothModule (  )  [protected]

Class constructor.

Virtual constructor for BluetoothModule class


Member Function Documentation

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

Parameters:
localPort Local port used by the service
data Pointer to the data to be used
len Data length
Returns:
Returns true if the record was successfully created

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

Parameters:
idConn Connection ID to be used
dstAddr Address of the destination device
dstPort Port of the destination device
Returns:
Returns true if the connection was established successfully, false otherwise

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.

Parameters:
localPort Service port to listen on
Returns:
Returns pointer to new connection object or NULL on error.
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.

Parameters:
dstAddr Destination BDADDR to connect to
dstPort Destination service port to connect to
pin Destination device's PIN code
Returns:
Returns pointer to new connection object or NULL on error.
void BluetoothModule::deregisterSPPConnection ( int  idConn  ) 

Unregister a bluetooth SPP connection.

Unregisters a bluetooth SPP connection in the LMXBluetoothModule

Parameters:
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

Parameters:
idConn Connection ID that should be disconnected
Returns:
Returns true if the device was successfully connected, false otherwise

Implemented in LMXBluetoothModule.

virtual std::string BluetoothModule::getLocalMac (  )  [pure virtual]

Reader implementation should override this function to implement method for reading device MAC address.

Returns:
Returns MAC address as string

Implemented in LMXBluetoothModule.

static BluetoothModule* BluetoothModule::getModule (  )  [inline, static]

Return the bluetooth module object Returns pointer to the instance of BluetoothModule class.

Returns:
Returns pointer to the BluetoothModule instance
virtual std::string BluetoothModule::getVersion (  )  [pure virtual]

Reader implementation should override this function to implement method for retrieving reader's bluetooth protocol version.

Returns:
Returns version number as string

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

Parameters:
idConn Connection ID that should be used for listening incoming packets
Returns:
Returns true if the device is in listening mode, false otherwise

Implemented in LMXBluetoothModule.

bool BluetoothModule::registerIncomingSPPConnection ( BluetoothSPPConnection conn  ) 

Register listening SPP connection.

Register a new SPP connection pointer in LMXBluetoothModule.

Parameters:
conn Pointer to the bluetooth connection object
Returns:
Returns connection id or -1 on error
int BluetoothModule::registerSPPConnection ( BluetoothSPPConnection conn  ) 

Register SPP connection.

Register a new SPP connection pointer in LMXBluetoothModule.

Parameters:
conn Pointer to the bluetooth connection object
Returns:
Returns connection id or -1 on error
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.

Parameters:
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

Parameters:
connid Connection ID, returned on SPP connection registration
data Data to be sent over SPP link
len Data length
Returns:
Returns true if data was sent out, false on error

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.

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

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

Parameters:
newpin Pointer to pin code to use for the connection
Returns:
Returns true when pin code was successfully set, false otherwise
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.

Returns:
Returns true if the shutdown was successful, false otherwise

Implemented in LMXBluetoothModule.


Member Data Documentation

BluetoothSPPConnection* BluetoothModule::connections[MAX_BT_CONNECTIONS] [protected]

List of bluetooth connections associated with the BluetoothModule class instance

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


The documentation for this class was generated from the following files:
Generated on Wed Oct 20 11:13:43 2010 for libspatha by  doxygen 1.6.3