Add a function to find remote client info matched addr and inst id 70/267470/1
authorWootak Jung <wootak.jung@samsung.com>
Mon, 6 Dec 2021 04:26:36 +0000 (13:26 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 6 Dec 2021 04:26:36 +0000 (13:26 +0900)
Change-Id: Ifed5672d2302910a7d9521b2644535a475c432f8

bt-service/services/gatt/bt-service-gatt.c

index 0390b16..79dccc4 100644 (file)
@@ -1621,6 +1621,25 @@ static void __bt_handle_gatt_server_service_deleted(event_gatts_srvc_t *event)
        }
 }
 
+static struct gatt_client_info_t *_bt_find_remote_gatt_client_info_with_inst_id(char *address, int instance_id)
+{
+       GSList *l;
+       struct gatt_client_info_t *info = NULL;
+       for (l = gatt_client_info_list; l != NULL; l = g_slist_next(l)) {
+               info = (struct gatt_client_info_t*)l->data;
+               if (info == NULL)
+                       continue;
+
+               if (!g_strcmp0(info->addr, address)) {
+                       if (info->instance_id == instance_id) {
+                               BT_DBG("Remote GATT client found addr[%s] instance_id[%d]", info->addr, info->instance_id);
+                               return info;
+                       }
+               }
+       }
+       return NULL;
+}
+
 struct gatt_client_info_t *_bt_find_remote_gatt_client_info(char *address)
 {
        GSList *l;
@@ -2961,7 +2980,7 @@ int _bt_gatt_server_send_indication(char *sender, bluetooth_device_address_t *de
                }
 
        } else {
-               conn = _bt_find_remote_gatt_client_info(address);
+               conn = _bt_find_remote_gatt_client_info_with_inst_id(address, param->instance_id);
                if (conn) {
                        ret = gatts_send_indication(param->instance_id, param->atrribute_handle,
                                        conn->connection_id, data->length,