BTComm provides the framework to produce an RS232 emulation plugin communicating over a Bluetooth RFComm connection.
BTComm has no API of its own but instead works over the Serial Communications C32 server using the Ser comms C32 APIs. BTComm is itself provided by a serial communications module in the form of a CSY file. Bluetooth virtual serial ports are typically used for application debugging over Bluetooth.
BTComm is used to create an emulated serial connection over the serial communications (Ser comms C32) server. There are three key concepts to consider when you need serial comms emulation over Bluetooth.
Serial Communications - A general discussion the Symbian Ser comms C32 classes that play a part in establishing a BTComm serial communications port.
Communication Modules - A general discussion about communication modules.
Communication Modes - A general discussion about the possible modes in which a BTComm port may be opened.
Serial Communications
BTComm provides Serial Communications emulation over Bluetooth. As such, the following Ser Comms C32 classes are used in making an RS232 BTComm connection:
RCommServ
- A session on the Serial Comms server.
RComm
- A subsession on the Serial Comms server. Objects of this class will check that the client has the correct capabilities to open the port.
Serial Communication Sessions
RCommServ::Connect()
creates a session on the comms server. The desired serial protocol is loaded using the RCommServ::LoadCommModule()
function.
Note: Several instances of a module can be loaded, the reference count for the module will simply be incremented for each subsequent load.
Serial Communications Server
RComm
provides several useful methods for serial communications including:
RComm::Open()
Open a port on the serial server.
RComm::Close()
Closes the port.
RComm::Read()
, RComm::ReadOneOrMore()
- Reading data over the port.
RComm::Write()
- Writing data over the port.
Opening the port
Having connected to the server and configured the session the connection can be opened. There are two RComm::Open()
methods. For BTComm we are only interested in the three parameter version. The three parameters are aServer
, aName
and aMode
. The other RComm::Open()
also includes an aRole
. Roles are discussed in more detail below.
Communications Modules
There are three Comm modules provided by default, they are:
ECUART - A customizable RS232 mode serial port module.
IRCOMM - The Infrared mode serial port module.
BTCOMM - The Bluetooth mode serial port module.
The BTCOMM.csy
module provides Serial over Bluetooth. The .csy extension is omitted in code.
Communication Modes
The aMode
parameter takes a TCommAccess
mode. There are three possible modes defined by TCommAccess
, they are:
ECommExclusive - Opens a port in exclusive mode. Any attempt to open or access the port by another application will fail.
ECommShared - Opens a port in shared mode. Other RComm
clients that are opened in ECommShared
mode can use the port.
ECommPreemptable - Allows another RComm
client to pre-empt the port if being opened in one of the other two modes.
BTComm must be opened in Exclusive mode ECommExclusive
.
Roles
There are two possible serial communication roles, they are:
DTE - Configures the connection as for a port of a computer.
DCE - Configures the connection as for a modem.
The role can be omitted as BTComm only supports the DTE mode. In this mode the signal lines DTR and RTS are outputs while the others are inputs. If you require the DCE rolw use RFComm instead of BTComm.
Using BTComm walks through the steps involved in setting up a BTComm connection.