OSDN Git Service

android/doc: Add socket-api.txt document
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Tue, 3 Dec 2013 15:53:11 +0000 (17:53 +0200)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Sun, 8 Dec 2013 15:32:05 +0000 (17:32 +0200)
Document describes how socket HAL is working.

android/socket-api.txt [new file with mode: 0644]

diff --git a/android/socket-api.txt b/android/socket-api.txt
new file mode 100644 (file)
index 0000000..9f622f9
--- /dev/null
@@ -0,0 +1,61 @@
+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));