From: Wootak Jung Date: Fri, 27 Dec 2019 01:31:01 +0000 (+0900) Subject: Add service update logic in service removed case X-Git-Tag: accepted/tizen/unified/20200210.131844^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F17%2F224217%2F1;p=platform%2Fcore%2Fapi%2Fbluetooth.git Add service update logic in service removed case Change-Id: If771281f84a4a6d3dca4cedc63a00772f4e27247 --- diff --git a/include/bluetooth_private.h b/include/bluetooth_private.h index 4904ff4..19fa317 100644 --- a/include/bluetooth_private.h +++ b/include/bluetooth_private.h @@ -559,7 +559,7 @@ typedef void (*bt_adapter_passkey_notification_cb)(const char *remote_address, c #define BT_CHECK_INPUT_PARAMETER(arg) \ if (arg == NULL) { \ - LOGE("[%s] INVALID_PARAMETER(0%s=NULL)", __FUNCTION__, #arg); \ + LOGE("[%s] INVALID_PARAMETER(%s=NULL)", __FUNCTION__, #arg); \ return BT_ERROR_INVALID_PARAMETER; \ } diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index b9e4a09..a86d7a5 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -2840,8 +2840,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us break; } - if (service_change->change_type - == BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_ADD) { + if (service_change->change_type == BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_ADD) { for (l = client->services; l; l = g_slist_next(l)) { svc = l->data; #ifdef TIZEN_GATT_CLIENT @@ -2853,7 +2852,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us #endif } if (l) { - BT_INFO("already added service : %s", svc->path); + BT_INFO("already added service"); break; } #ifdef TIZEN_GATT_CLIENT @@ -2865,8 +2864,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us break; } #else - svc = _bt_gatt_client_add_service(client, - service_change->svc_path); + svc = _bt_gatt_client_add_service(client, service_change->svc_path); if (svc == NULL) { BT_ERR("_bt_gatt_client_add_service is failed"); break; @@ -2878,9 +2876,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us BT_GATT_CLIENT_SERVICE_ADDED, service_change->uuid, client->service_changed_user_data); - } else { - char *removed_uuid = NULL; - + } else { /* BLUETOOTH_GATT_SERVICE_CHANGE_TYPE_REMOVE */ for (l = client->services; l; l = g_slist_next(l)) { svc = l->data; #ifdef TIZEN_GATT_CLIENT @@ -2896,16 +2892,23 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us break; } +#ifdef TIZEN_GATT_CLIENT BT_INFO("Service(%s) is removed", svc->uuid); - removed_uuid = g_strdup(svc->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 bt_gatt_service_destroy((bt_gatt_h)svc); +#endif if (client->connected && client->service_changed_cb) client->service_changed_cb(client, BT_GATT_CLIENT_SERVICE_REMOVED, - removed_uuid, + service_change->uuid, client->service_changed_user_data); - g_free(removed_uuid); } break; }