The Bluetooth specification defines commands and options that can be used with the various layers of the protocol. The Bluetooth Sockets API makes some of these available as follows:
Host Controller Interface (HCI) commands [BS1, Host Controller Interface], which provide a command interface to the
baseband controller and link manager. These are provided through asynchonous I/O control (ioctl) commands on an L2CAP or RFCOMM socket, as there is no direct EPOC interface to the HCI. Ioctls are issued through RSocket::Ioctl()
. HCI commands
gives the details.
L2CAP-level options [BS1, Logical link control and adaptation protocol]: these are also issued through ioctls on an L2CAP socket. L2CAP commands gives the details.
RFCOMM commands and options [BS1, RFCOMM with TS 07.10]: these are issued through ioctls on an RFCOMM socket, and sockets option settings (RSocket::GetOpt()
and RSocket::GetOpt()
). RFCOMM commands and RFCOMM options give the details.
The following example shows the HCI command Read_Class_of_Device being issued on an L2CAP socket. The ioctl for this is KHCIReadDeviceClassIoctl
, which returns a THCIDeviceClassIoctl
object packaged in a THCIDeviceClassBuf
package buffer. The example extracts the device class into a variable majorClass
.
THCIDeviceClassBuf codbuf;
TRequestStatus status;
socket.Ioctl(KHCIReadDeviceClassIoctl, status, &codbuf, KSolBtHCI);
User::WaitForRequest(status);
TUint16 majorClass = codbuf().iMajorDeviceClass;