Fix issue where WriteValue/AcquireNotify method comes before gatt connected #2 97/316797/1
authorWootak Jung <wootak.jung@samsung.com>
Mon, 16 Dec 2024 01:25:41 +0000 (10:25 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 18 Dec 2024 03:03:02 +0000 (12:03 +0900)
Change-Id: Ic4e5866054e6df682a8be09401675bc294339ed8
Signed-off-by: Sohyeon Choi <shss.choi@samsung.com>
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-oal/bluez_hal/src/bt-hal-gatt-server.c

index 390a97d779cf871fb1e5aae4e5853ac7efe5d293..c51229a96cc2285133df371a95ea7c5369548a08 100644 (file)
@@ -222,8 +222,8 @@ static GSList * hal_gatts_server_register_list;
 static int assigned_id = 0;
 static gboolean instance_id_used[BT_GATTS_MAX];
 static guint manager_id[BT_GATTS_MAX];
-static bool acquire_notify_is_pending = false;
-static bool write_value_is_pending = false;
+static int acquire_notify_pending_count = 0;
+static int write_value_pending_count = 0;
 
 #define CHECK_BTGATT_INIT() if (_bt_hal_gatt_interface_ready() == false)\
 {\
@@ -1362,8 +1362,9 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                        ERR("Client info not found. This method call will be called again shortly");
                        g_variant_unref(var);
 
-                       if (write_value_is_pending) {
-                               write_value_is_pending = false;
+                       if (write_value_pending_count > 2) {
+                               ERR("Client info still not found (count %d). Ignoring this method call", write_value_pending_count);
+                               write_value_pending_count = 0;
                                goto done;
                        }
 
@@ -1379,10 +1380,10 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                        info->user_data = user_data;
 
                        g_timeout_add(300, __bt_pending_method_call, info);
-                       write_value_is_pending = true;
+                       write_value_pending_count++;
                        return;
                }
-               write_value_is_pending = false;
+               write_value_pending_count = 0;
 
                svc_info = __bt_gatt_find_gatt_service_from_char(object_path, &char_hdl);
                if (svc_info == NULL || event_cb == NULL) {
@@ -1647,8 +1648,9 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                        ERR("Client info not found. This method call will be called again shortly");
                        g_variant_iter_free(iter);
 
-                       if (acquire_notify_is_pending) {
-                               acquire_notify_is_pending = false;
+                       if (acquire_notify_pending_count > 2) {
+                               ERR("Client info still not found (count %d). Ignoring this method call", acquire_notify_pending_count);
+                               acquire_notify_pending_count = 0;
                                goto done;
                        }
 
@@ -1663,10 +1665,10 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                        info->user_data = user_data;
 
                        g_timeout_add(300, __bt_pending_method_call, info);
-                       acquire_notify_is_pending = true;
+                       acquire_notify_pending_count++;
                        return;
                }
-               acquire_notify_is_pending = false;
+               acquire_notify_pending_count = 0;
 
                svc_info = __bt_gatt_find_gatt_service_from_char(object_path, &char_hdl);
                if (svc_info == NULL) {
@@ -1710,6 +1712,11 @@ static gboolean __bt_pending_method_call(gpointer data)
        struct method_call_info *info = data;
 
        DBG("The method call was called again");
+       if (g_strcmp0(info->method_name, "WriteValue") == 0)
+               DBG("WriteValue pending count [%d]", write_value_pending_count);
+       if (g_strcmp0(info->method_name, "AcquireNotify") == 0)
+               DBG("AcquireNotify pending count [%d]", acquire_notify_pending_count);
+
        __bt_gatt_char_method_call(info->connection,
                        info->sender,
                        info->object_path,