Discovers other Bluetooth devices, and reads and writes data over Bluetooth.
There are two roles to be played in establishing a communications channel over Bluetooth, they are:
The receiver starts the Bluetooth system and waits for an initiator to make the connection. Once the connection has been made, both ends are equals, and either can send and receive data and terminate the connection. This API allows either role to be programmed.
The API supports communication over both the L2CAP and RFCOMM layers of the Bluetooth protocol suite. The API is based on the Sockets Client-Side API, which provides a standard API that allows a client to make a connection to a remote device or have the remote device connect to it, then to send and receive data before disconnecting.
The API has five key concepts: socket address, remote device inquiry, RFCOMM commands and options, L2CAP commands, and HCI commands.
Socket address
Each Bluetooth device has a unique 48-bit address. This is encapsulated by TBTDevAddr
.
The sockets API encapsulates a generic communications end point through a TSockAddr
. Bluetooth provides a specialised version of this, TBTSockAddr
, which adds a Bluetooth device address field.
Remote device inquiry
A client can query for available remote devices through the sockets class RHostResolver
. A parameter of type TInquirySockAddr
is supplied for such queries: principally, this allows you to limit discovery to specific classes of device.
Commands and options
You can send commands to an RFCOMM socket through an RSocket::Ioctl()
call. It is possible to get and set options on a socket through RSocket::GetOpt()
and RSocket::SetOpt()
respectively.
You can send commands to L2CAP sockets and to the HCI layer through RSocket::Ioctl()
.