Add server info finding logic for getting mtu 37/238037/1 accepted/tizen/unified/20200710.114128 submit/tizen/20200708.225225
authorWootak Jung <wootak.jung@samsung.com>
Wed, 8 Jul 2020 00:57:53 +0000 (09:57 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 8 Jul 2020 00:57:53 +0000 (09:57 +0900)
Change-Id: I152679386cde402b881c47f0a5c7f264bf20a632
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-service/services/gatt/bt-service-gatt.c

index 500b004..237b00d 100644 (file)
@@ -2608,7 +2608,7 @@ int _bt_get_att_mtu(bluetooth_device_address_t *address,
 {
        BT_CHECK_PARAMETER(address, return);
        BT_CHECK_PARAMETER(mtu, return);
-       struct gatt_client_info_t *conn_info = NULL;
+       struct gatt_client_info_t *client_info = NULL;
        char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
        int ret = OAL_STATUS_SUCCESS;
        int stack_mtu;
@@ -2617,26 +2617,32 @@ int _bt_get_att_mtu(bluetooth_device_address_t *address,
 
        BT_INFO("Get current MTU size for the remote client:DevAddress:[%s]", addr);
 
-       conn_info = _bt_find_remote_gatt_client_info(addr);
-       if (conn_info) {
+       client_info = _bt_find_remote_gatt_client_info(addr);
+       if (client_info) {
                BT_INFO("GATT Client [%s] is connected, conn Id [%d] Instance ID [%d]",
-                               conn_info->addr, conn_info->connection_id, conn_info->instance_id);
-       } else {
-               BT_ERR("GATT Client [%s] is not yet connected..", addr);
-               return BLUETOOTH_ERROR_NOT_CONNECTED;
-       }
+                               client_info->addr, client_info->connection_id, client_info->instance_id);
 
-       if (conn_info->instance_id == -1) {
-               ret = gattc_get_att_mtu(conn_info->connection_id, &stack_mtu);
+               ret = gatts_get_att_mtu(client_info->connection_id, &stack_mtu);
                if (ret != OAL_STATUS_SUCCESS) {
                        BT_ERR("ret: %d", ret);
                        return _bt_convert_oal_status_to_bt_error(ret);
                }
        } else {
-               ret = gatts_get_att_mtu(conn_info->connection_id, &stack_mtu);
-               if (ret != OAL_STATUS_SUCCESS) {
-                       BT_ERR("ret: %d", ret);
-                       return _bt_convert_oal_status_to_bt_error(ret);
+               struct gatt_server_info_t *server_info = NULL;
+               BT_ERR("GATT Client [%s] is not yet connected..", addr);
+               server_info = _bt_find_remote_gatt_server_info(addr);
+               if (server_info) {
+                       BT_INFO("GATT Server [%s] is connected, conn Id [%d] Client ID [%d]",
+                                       server_info->addr, server_info->connection_id, server_info->client_id);
+
+                       ret = gattc_get_att_mtu(server_info->connection_id, &stack_mtu);
+                       if (ret != OAL_STATUS_SUCCESS) {
+                               BT_ERR("ret: %d", ret);
+                               return _bt_convert_oal_status_to_bt_error(ret);
+                       }
+               } else {
+                       BT_ERR("GATT Server [%s] is not yet connected..", addr);
+                       return BLUETOOTH_ERROR_NOT_CONNECTED;
                }
        }