Add service update logic in service removed case 17/224217/1
authorWootak Jung <wootak.jung@samsung.com>
Fri, 27 Dec 2019 01:31:01 +0000 (10:31 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 7 Feb 2020 05:48:09 +0000 (14:48 +0900)
Change-Id: If771281f84a4a6d3dca4cedc63a00772f4e27247

include/bluetooth_private.h
src/bluetooth-common.c

index 4904ff4..19fa317 100644 (file)
@@ -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; \
        }
 
index b9e4a09..a86d7a5 100644 (file)
@@ -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;
        }