Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Bluetooth Sockets overview


Purpose

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: initiator and receiver. The receiver sets things up and then 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.

[Top]


Architectural relationships

The Bluetooth Sockets 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 Bluetooth Sockets API adds appropriate types and constants that enable the sockets API to be used with Bluetooth.

[Top]


Description

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 a particular classes of device.


Commands and options

You can send commands to an RFCOMM socket through an RSocket::Ioctl() call. Options on a socket can be get and set through RSocket::GetOpt() and RSocket::SetOpt() respectively.

You can send commands to L2CAP sockets and to the HCI layer through RSocket::Ioctl().