Bluetooth socket overview
purpose
Discover other Bluetooth devices and read and write data through Bluetooth.
There are two roles to establish a communication channel through the Bluetooth: initiator and acceptor. The acceptor is waiting to establish a connection after the configuration is configured. Once the connection is established, both parties are equal, they can send or accept data. This API can be programmed in both parties.
Structural relationship
Bluetooth socket API supports communication in L2CAP and RFCMM layers. The API is based on the client sleeve API. The client sleeve API is to allow clients and remote devices to connect or allow remote devices to connect, and send and receive data standard APIs before disconnect. Bluetooth sockets API also adds an appropriate type and constant for Bluetooth applications
description
API has five key concepts: socket addresses, remote devices, RFCMM commands, options, L2CAP commands, and hci commands
Socket address
Each Bluetooth device has a unique 48-bit address, encapsulated in TBTDEVADDR.
The socket API encapsulates a generalized communication end of communication through TsockAddr, while Bluetooth provides a dedicated version TBTSockAddr, which adds a Bluetooth device address.
Remote device challenge
The client can ask the remote device to be available through RhostResolver. A TINQUIRYSOCKADDR type parameter is used to provide this inquiry: mainly to limit the discovery of the device details.
Commands and options
We can send a command to an RFCMM socket by calling the rsocket :: ioctl (). The options for sockets can be set by rsocket :: getopt () and RSocket :: setOpt (), respectively.
With RSocket :: ioctl (), we can send a command to the L2CAP socket and HCI layer.