Upgrade bluez5_37 :Merge the code from private
[platform/upstream/bluez.git] / android / socket-api.txt
1 Android Socket protocol for Bluetooth
2 =====================================
3
4 Since Android switched from BlueZ (where sockets where nicely implemented) to
5 Bluedroid user space stack there is a need to emulate bluetooth sockets.
6
7 Android Bluetooth Socket Hardware Abstraction Layer (HAL) bt_sock.h has
8 only 2 functions:
9
10 static btsock_interface_t sock_if = {
11         sizeof(sock_if),
12         sock_listen,
13         sock_connect
14 };
15
16 with following parameters:
17
18 sock_listen(btsock_type_t type, const char *service_name,
19                 const uint8_t *uuid, int chan, int *sock_fd, int flags)
20 sock_connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
21                 const uint8_t *uuid, int chan, int *sock_fd, int flags)
22
23 socket type RFCOMM is only supported at the moment. uuid and channel used
24 to decide where to connect.
25
26 sockfd is used to return socket fd to Android framework. It is used to inform
27 framework when remote device is connected.
28
29 listen()
30 ========
31
32 Listens on RFCOMM socket, socket channel is either found based on uuid or
33 channel parameter used directly. Returns sock_fd to Android framework.
34
35 Through this sock_fd channel number as (int) needs to be written right after
36 listen() succeeds.
37
38 When remote device is connected to this socket we shall send accept signal
39 through sock_fd
40
41 connect()
42 =========
43
44 Connects to remote device specified in bd_addr parameter. Socket channel is
45 found by SDP search of remote device by supplied uuid. Returns sock_fd to
46 Android framework.
47
48 Through this sock_fd channel number as (int) needs to be written right after
49 connects() succeeds.
50
51 When remote device is connected to this socket we shall send connect signal
52 through sock_fd
53
54 The format of connect/accept signal is shown below:
55
56 struct hal_sock_connect_signal {
57         short   size;
58         uint8_t bdaddr[6];
59         int     channel;
60         int     status;
61 } __attribute__((packed));