mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-26 13:44:23 +08:00
cb284a7adc
Document describes how socket HAL is working.
62 lines
1.8 KiB
Plaintext
62 lines
1.8 KiB
Plaintext
Android Socket protocol for Bluetooth
|
|
=====================================
|
|
|
|
Since Android switched from BlueZ (where sockets where nicely implemented) to
|
|
Bluedroid user space stack there is a need to emulate bluetooth sockets.
|
|
|
|
Android Bluetooth Socket Hardware Abstraction Layer (HAL) bt_sock.h has
|
|
only 2 functions:
|
|
|
|
static btsock_interface_t sock_if = {
|
|
sizeof(sock_if),
|
|
sock_listen,
|
|
sock_connect
|
|
};
|
|
|
|
with following parameters:
|
|
|
|
sock_listen(btsock_type_t type, const char *service_name,
|
|
const uint8_t *uuid, int chan, int *sock_fd, int flags)
|
|
sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
|
|
const uint8_t *uuid, int chan, int *sock_fd, int flags)
|
|
|
|
socket type RFCOMM is only supported at the moment. uuid and channel used
|
|
to decide where to connect.
|
|
|
|
sockfd is used to return socket fd to Android framework. It is used to inform
|
|
framework when remote device is connected.
|
|
|
|
listen()
|
|
========
|
|
|
|
Listens on RFCOMM socket, socket channel is either found based on uuid or
|
|
channel parameter used directly. Returns sock_fd to Android framework.
|
|
|
|
Through this sock_fd channel number as (int) needs to be written right after
|
|
listen() succeeds.
|
|
|
|
When remote device is connected to this socket we shall send accept signal
|
|
through sock_fd
|
|
|
|
connect()
|
|
=========
|
|
|
|
Connects to remote device specified in bd_addr parameter. Socket channel is
|
|
found by SDP search of remote device by supplied uuid. Returns sock_fd to
|
|
Android framework.
|
|
|
|
Through this sock_fd channel number as (int) needs to be written right after
|
|
connects() succeeds.
|
|
|
|
When remote device is connected to this socket we shall send connect signal
|
|
through sock_fd
|
|
|
|
The format of connect/accept signal is shown below:
|
|
|
|
struct hal_sock_connect_signal {
|
|
short size;
|
|
uint8_t bdaddr[6];
|
|
int channel;
|
|
int status;
|
|
} __attribute__((packed));
|