Fix to reallocate fd when gatt write fails 39/305539/1
authorWootak Jung <wootak.jung@samsung.com>
Thu, 1 Feb 2024 06:16:04 +0000 (15:16 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 5 Feb 2024 01:27:41 +0000 (10:27 +0900)
Change-Id: Ic9e2cf70d022c1d0f66b45587f08b382cd425421
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-api/bt-gatt-client.c

index a370502..187e0a4 100644 (file)
@@ -2489,6 +2489,21 @@ static int  bluetooth_gatt_client_write_characteristics_value_to_fd(
        if (written != length) {
                att_result = BLUETOOTH_ERROR_INTERNAL;
                BT_ERR("write data failed.  ret : %d ", written);
+               if (TIZEN_FEATURE_DA_REFERENCE) {
+                       /* If bluetooth_gatt_client_write_channel_watch_cb() is not called
+                        * due to a server issue and write request fails,
+                        * remove the existing fd from the list and reallocate it.*/
+                       GSList *l;
+                       for (l = gatt_characteristic_write_list; l != NULL; l = l->next) {
+                               bt_gatt_characteristic_write_info_t *info = l->data;
+                               if (!info)
+                                       continue;
+                               if (info->write_fd == fd) {
+                                       gatt_characteristic_write_list = g_slist_remove(gatt_characteristic_write_list, info);
+                                       break;
+                               }
+                       }
+               }
        }
 
        return att_result;