LE CoC: Add support for L2CAP_LE type socket in OAL 57/271557/1
authorAyush Garg <ayush.garg@samsung.com>
Mon, 21 Feb 2022 10:44:26 +0000 (16:14 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Wed, 23 Feb 2022 04:32:29 +0000 (10:02 +0530)
This patch adds support for OAL_SOCK_L2CAP_LE type
socket.

Change-Id: I190535687e7eb312535b5ff5584f51fcac47ec38
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
bt-oal/include/oal-socket.h
bt-oal/oal-socket.c

index 3cb313a..b30e431 100755 (executable)
@@ -28,7 +28,8 @@ extern "C" {
 typedef enum {
        OAL_SOCK_RFCOMM,
        OAL_SOCK_SCO,
-       OAL_SOCK_L2CAP
+       OAL_SOCK_L2CAP,
+       OAL_SOCK_L2CAP_LE
 } oal_sock_type_t;
 
 /**
index 0d3fe43..d0b8516 100755 (executable)
@@ -358,6 +358,11 @@ int socket_connect(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, int channel, b
                        socket_api->connect((const bt_bdaddr_t *)bd,
                                BTSOCK_RFCOMM, NULL, channel, &sock_fd, 0);
                break;
+       case OAL_SOCK_L2CAP_LE:
+               BT_INFO("L2CAP_LE socket connect");
+               socket_api->connect((const bt_bdaddr_t *)bd,
+                       BTSOCK_L2CAP_LE, NULL, channel, &sock_fd, 0);
+               break;
        default:
                BT_ERR("Socket type: %d not supported", sock_type);
        }
@@ -387,12 +392,15 @@ int socket_connect(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, int channel, b
 int socket_listen(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, char *svc_name, int channel)
 {
        int sock_fd = -1;
-       int srv_channel;
+       int srv_channel = -1;
        int ret = BT_STATUS_FAIL;
 
        CHECK_OAL_SOCKET_ENABLED();
-       OAL_CHECK_PARAMETER(svc_name, return);
-       API_TRACE("svc_name: %s", svc_name);
+
+       if (sock_type != OAL_SOCK_L2CAP_LE) {
+               OAL_CHECK_PARAMETER(svc_name, return);
+               API_TRACE("svc_name: %s", svc_name);
+       }
 
        switch (sock_type) {
        case OAL_SOCK_RFCOMM:
@@ -403,6 +411,11 @@ int socket_listen(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, char *svc_name,
                        ret = socket_api->listen(BTSOCK_RFCOMM,
                                        svc_name, p_uuid->uuid, channel, &sock_fd, 0);
                break;
+       case OAL_SOCK_L2CAP_LE:
+               BT_INFO("l2cap_le socket listen to psm %d", channel);
+               ret = socket_api->listen(BTSOCK_L2CAP_LE,
+                               NULL, NULL, channel, &sock_fd, 0);
+               break;
        default:
                BT_ERR("Socket type: %d not supported", sock_type);
        }
@@ -414,13 +427,16 @@ int socket_listen(oal_sock_type_t sock_type, oal_uuid_t *p_uuid, char *svc_name,
 
        BT_INFO("Bluetooth server socket created, sock_fd=%d", sock_fd);
 
-       /* Read server channel number sent by stack */
-       srv_channel = sock_wait_for_channel(sock_fd);
-       if (srv_channel < 0) {
-               BT_ERR("incorrect channel= %d", srv_channel);
-               return  -1;
+       /* Read server channel number sent by stack
+        * Skipping it for l2cap_le socket, it will be read at FRWK API.
+        */
+       if (sock_type != OAL_SOCK_L2CAP_LE) {
+               srv_channel = sock_wait_for_channel(sock_fd);
+               if (srv_channel < 0) {
+                       BT_ERR("incorrect channel= %d", srv_channel);
+                       return  -1;
+               }
        }
-
        BT_INFO("server channel= %d", srv_channel);
 
        return sock_fd;