From: Wootak Jung Date: Mon, 23 Dec 2019 05:29:36 +0000 (+0900) Subject: Modify GATT Service changed event handling logic X-Git-Tag: submit/tizen/20200207.062602^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab68d97ecf250b684c3ba4f8950a8c0c0c5f8f9f;p=platform%2Fcore%2Fapi%2Fbluetooth.git Modify GATT Service changed event handling logic Change-Id: I27ca2b3b20cc0007795be80e0741ea4013fbe703 --- diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index 1c42639..b9e4a09 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -2812,6 +2812,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us const GSList *l = NULL; bt_gatt_client_s *client = NULL; bt_gatt_service_s *svc = NULL; + int ret; BT_INFO("BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED"); @@ -2843,42 +2844,59 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us == BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_ADD) { for (l = client->services; l; l = g_slist_next(l)) { svc = l->data; +#ifdef TIZEN_GATT_CLIENT + if (!g_strcmp0(svc->uuid, service_change->uuid)) + break; +#else if (!g_strcmp0(svc->path, service_change->svc_path)) break; +#endif } if (l) { BT_INFO("already added service : %s", svc->path); break; } #ifdef TIZEN_GATT_CLIENT - BT_INFO("TODO this task"); + BT_INFO("Service(%s) is added", service_change->uuid); + client->services_discovered = false; + ret = _bt_gatt_client_update_services(client); + if (ret != BT_ERROR_NONE) { + BT_ERR("_bt_gatt_client_update_services is failed"); + break; + } #else svc = _bt_gatt_client_add_service(client, service_change->svc_path); -#endif if (svc == NULL) { BT_ERR("_bt_gatt_client_add_service is failed"); break; } +#endif if (client->connected && client->service_changed_cb) client->service_changed_cb(client, BT_GATT_CLIENT_SERVICE_ADDED, - svc->uuid, + service_change->uuid, client->service_changed_user_data); } else { char *removed_uuid = NULL; for (l = client->services; l; l = g_slist_next(l)) { svc = l->data; +#ifdef TIZEN_GATT_CLIENT + if (!g_strcmp0(svc->uuid, service_change->uuid)) + break; +#else if (!g_strcmp0(svc->path, service_change->svc_path)) break; +#endif } if (!l) { BT_ERR("There is NO matched service"); break; } + BT_INFO("Service(%s) is removed", svc->uuid); removed_uuid = g_strdup(svc->uuid); bt_gatt_service_destroy((bt_gatt_h)svc); diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index abf2ec4..504812a 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -2334,7 +2334,9 @@ void __bt_gatt_client_service_changed_cb(bt_gatt_client_h c, ret = bt_get_uuid_name(uuid, &svc); if (ret != BT_ERROR_NONE) - TC_PRT("Remote device [%s] : %s is %s", addr, svc, + svc = g_strdup(uuid); + + TC_PRT("Remote device [%s] : %s is %s", addr, svc, type == BT_GATT_CLIENT_SERVICE_ADDED ? "Added" : "Removed"); g_free(svc);