Handle service changed event 06/226606/1
authorinjun.yang <injun.yang@samsung.com>
Thu, 6 Feb 2020 09:05:00 +0000 (18:05 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 4 Mar 2020 06:17:26 +0000 (15:17 +0900)
[Model] All
[BinType] AP
[Customer] OPEN

[Issue#] N/A
[Request] Internal
[Occurrence Version] N/A

[Problem] Before GATT connected, service changed event invoked.
[Cause & Measure] Ignore GattServiceAdded event before GATT connection completed.
[Checking Method] n/a

[Team] Convergence BT
[Developer] Injun Yang
[Solution company] Samsung
[Change Type] Specification change

Change-Id: I830ba2f702b2a29d9ad381447855e54dd7c98881

bt-oal/bluez_hal/src/bt-hal-gatt-client.c

index 81b28d7..ffef12e 100644 (file)
@@ -136,6 +136,7 @@ typedef struct {
        bt_bdaddr_t bd_addr;    /*remote server address*/
        int conn_id;
        int inst_id;
+       gboolean is_gatt_connected;
 } hal_gattc_client_info_t;
 
 /* Linked list of connected GATT client connection */
@@ -3639,9 +3640,6 @@ void _bt_hal_handle_gattc_connected_event(char* address, gboolean gatt_connected
        hal_gattc_client_info_t *gattc_client = NULL;
        int inst_id = -1;
 
-
-       DBG("+ connected device address [%s]", address);
-
        event = gatt_connected ? HAL_EV_GATT_CLIENT_CONNECTED :
                                HAL_EV_GATT_CLIENT_DISCONNECTED;
 
@@ -3653,6 +3651,8 @@ void _bt_hal_handle_gattc_connected_event(char* address, gboolean gatt_connected
                return;
        }
 
+       gattc_client->is_gatt_connected = gatt_connected;
+
        //send event
        memset(&ev, 0, sizeof(ev));
        ev.conn_id = gattc_client->conn_id;
@@ -3691,8 +3691,6 @@ void _bt_hal_handle_gattc_connected_event(char* address, gboolean gatt_connected
                hal_gattc_server_info_list = g_slist_remove(hal_gattc_server_info_list, conn_info);
                __hal_clean_gattc_server_info(conn_info);
        }
-
-       DBG("-");
 }
 
 static void _bt_hal_send_search_service_result_event(int conn_id, int is_primary,
@@ -3958,6 +3956,7 @@ void _bt_hal_handle_gattc_service_changed_event(gboolean is_added, const char *p
        struct hal_ev_gatt_client_service_changed ev = {0, };
        char address[BT_HAL_ADDRESS_STRING_SIZE];
        hal_gattc_server_info_t *server_info = NULL;
+       hal_gattc_client_info_t *gattc_client = NULL;
        hal_gattc_service_t *service = NULL;
        GSList *list = NULL;
        char *uuid_str = NULL;
@@ -3970,6 +3969,17 @@ void _bt_hal_handle_gattc_service_changed_event(gboolean is_added, const char *p
                return;
        }
 
+       gattc_client = __bt_find_gatt_client_info((bt_bdaddr_t *)ev.bdaddr);
+       if (gattc_client == NULL) {
+               ERR("gattc_client is NULL");
+               return;
+       }
+
+       if (gattc_client->is_gatt_connected == FALSE) {
+               DBG("GattConnected signal is not received yet. Just skip");
+               return;
+       }
+
        if (is_added) {
                /* Get service UUID from path */
                __bt_hal_gattc_get_uuid_from_path(path, &uuid_str);