Add service added event handling logic 13/224213/1
authorWootak Jung <wootak.jung@samsung.com>
Fri, 7 Feb 2020 04:37:07 +0000 (13:37 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 7 Feb 2020 05:40:02 +0000 (14:40 +0900)
Add added service in list

Change-Id: I1bcb6795d8207a6b415ccfb99a70a578fb4eb874

bt-api/bt-event-handler.c
bt-oal/bluez_hal/inc/bt-hal-msg.h
bt-oal/bluez_hal/src/bt-hal-gatt-client.c
bt-oal/bluez_hal/src/bt-hal-gatt.c
bt-oal/hardware/bt_gatt_client.h
bt-oal/include/oal-event.h
bt-oal/oal-gatt.c
bt-service-adaptation/services/gatt/bt-service-gatt.c
include/bluetooth-api.h

index b213807..91108b4 100644 (file)
@@ -3825,7 +3825,7 @@ static void __bt_gatt_client_event_filter(GDBusConnection *connection,
                char *address_str = NULL;
                char *name = NULL;
 
                char *address_str = NULL;
                char *name = NULL;
 
-               g_variant_get(parameters, "(i&s&s)", &change.change_type, &address_str, &change.uuid);
+               g_variant_get(parameters, "(ii&s&s)", &change.inst_id, &change.change_type, &address_str, &change.uuid);
 
                _bt_convert_addr_string_to_type(change.device_addr.addr, address_str);
                bluetooth_get_uuid_name(change.uuid, &name);
 
                _bt_convert_addr_string_to_type(change.device_addr.addr, address_str);
                bluetooth_get_uuid_name(change.uuid, &name);
index 1990673..2c46056 100644 (file)
@@ -805,6 +805,7 @@ struct hal_ev_dbfw_plus_info_recieved {
 #define HAL_EV_GATT_CLIENT_SERVICE_CHANGED 0xCF
 struct hal_ev_gatt_client_service_changed {
        int32_t conn_id;
 #define HAL_EV_GATT_CLIENT_SERVICE_CHANGED 0xCF
 struct hal_ev_gatt_client_service_changed {
        int32_t conn_id;
+       int32_t inst_id;
        uint8_t bdaddr[6];
        uint8_t change_type;
        uint8_t uuid[16];
        uint8_t bdaddr[6];
        uint8_t change_type;
        uint8_t uuid[16];
index b3214ac..bf10167 100644 (file)
@@ -3965,5 +3965,6 @@ void _bt_hal_handle_gattc_service_changed_event(gboolean is_added, const char *p
        /* Send GATT Client service changed event */
        ev.change_type = is_added;
        ev.conn_id = server_info->conn_id;
        /* Send GATT Client service changed event */
        ev.change_type = is_added;
        ev.conn_id = server_info->conn_id;
+       ev.inst_id = server_info->inst_id;
        event_cb(HAL_EV_GATT_CLIENT_SERVICE_CHANGED, (void *)&ev, sizeof(ev));
 }
        event_cb(HAL_EV_GATT_CLIENT_SERVICE_CHANGED, (void *)&ev, sizeof(ev));
 }
index 20d68bd..a476088 100644 (file)
@@ -689,7 +689,8 @@ static void __bt_hal_handle_gatt_client_service_changed(void *buf, uint16_t len)
        DBG("GATT Client service changed event received");
 
        if (bt_gatt_callbacks->client->service_changed_cb)
        DBG("GATT Client service changed event received");
 
        if (bt_gatt_callbacks->client->service_changed_cb)
-               bt_gatt_callbacks->client->service_changed_cb((bt_bdaddr_t *)ev->bdaddr, ev->change_type, ev->uuid, ev->conn_id);
+               bt_gatt_callbacks->client->service_changed_cb((bt_bdaddr_t *)ev->bdaddr,
+                               ev->change_type, ev->uuid, ev->conn_id, ev->inst_id);
 }
 
 static bt_hal_le_adv_info_t *__bt_hal_get_adv_ind_info(char *addr)
 }
 
 static bt_hal_le_adv_info_t *__bt_hal_get_adv_ind_info(char *addr)
index 55c99d7..d229184 100644 (file)
@@ -133,7 +133,7 @@ typedef void (*register_for_notification_callback)(int conn_id,
 typedef void (*notify_callback)(int conn_id, btgatt_notify_params_t *p_data);
 
 /** Registers service changed callback operation */
 typedef void (*notify_callback)(int conn_id, btgatt_notify_params_t *p_data);
 
 /** Registers service changed callback operation */
-typedef void (*service_changed_callback)(bt_bdaddr_t *bd_addr, int change_type, uint8_t *uuid, int conn_id);
+typedef void (*service_changed_callback)(bt_bdaddr_t *bd_addr, int change_type, uint8_t *uuid, int conn_id, int inst_id);
 
 /** Reports result of a GATT read operation */
 typedef void (*read_characteristic_callback)(int conn_id, int status,
 
 /** Reports result of a GATT read operation */
 typedef void (*read_characteristic_callback)(int conn_id, int status,
index 0cc17d9..100e701 100644 (file)
@@ -496,6 +496,7 @@ typedef struct {
        uint8_t change_type;
        oal_uuid_t uuid;
        int conn_id;
        uint8_t change_type;
        oal_uuid_t uuid;
        int conn_id;
+       int inst_id;
 } event_gattc_service_changed_data;
 
 typedef struct {
 } event_gattc_service_changed_data;
 
 typedef struct {
index af15692..90c9e62 100644 (file)
@@ -213,7 +213,7 @@ static void cb_gattc_write_descriptor(int conn_id, int status, btgatt_write_para
 static void cb_gattc_register_for_notification(int conn_id, int registered, int status,
                        btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id);
 static void cb_gattc_notify(int conn_id, btgatt_notify_params_t *p_data);
 static void cb_gattc_register_for_notification(int conn_id, int registered, int status,
                        btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id);
 static void cb_gattc_notify(int conn_id, btgatt_notify_params_t *p_data);
-static void cb_gattc_service_changed(bt_bdaddr_t *bd_addr, int change_type, uint8_t *uuid, int conn_id);
+static void cb_gattc_service_changed(bt_bdaddr_t *bd_addr, int change_type, uint8_t *uuid, int conn_id, int inst_id);
 static void cb_gattc_configure_mtu_cmpl(int conn_id, int status, int mtu);
 
 /*TODO GATT CLient callbacks will be implemented in subsequent patches */
 static void cb_gattc_configure_mtu_cmpl(int conn_id, int status, int mtu);
 
 /*TODO GATT CLient callbacks will be implemented in subsequent patches */
@@ -1606,7 +1606,7 @@ static void cb_gattc_notify(int conn_id, btgatt_notify_params_t *p_data)
        }
 }
 
        }
 }
 
-static void cb_gattc_service_changed(bt_bdaddr_t *bd_addr, int change_type, uint8_t *uuid, int conn_id)
+static void cb_gattc_service_changed(bt_bdaddr_t *bd_addr, int change_type, uint8_t *uuid, int conn_id, int inst_id)
 {
        event_gattc_service_changed_data *event = g_new0(event_gattc_service_changed_data, 1);
 
 {
        event_gattc_service_changed_data *event = g_new0(event_gattc_service_changed_data, 1);
 
@@ -1614,6 +1614,7 @@ static void cb_gattc_service_changed(bt_bdaddr_t *bd_addr, int change_type, uint
        event->change_type = change_type;
        memcpy(event->uuid.uuid, uuid, sizeof(event->uuid.uuid));
        event->conn_id = conn_id;
        event->change_type = change_type;
        memcpy(event->uuid.uuid, uuid, sizeof(event->uuid.uuid));
        event->conn_id = conn_id;
+       event->inst_id = inst_id;
 
        send_event_bda_trace(OAL_EVENT_GATTC_SERVICE_CHANGED_IND, event, sizeof(*event), (bt_address_t *)bd_addr);
 }
 
        send_event_bda_trace(OAL_EVENT_GATTC_SERVICE_CHANGED_IND, event, sizeof(*event), (bt_address_t *)bd_addr);
 }
index 2305b5d..d59d769 100644 (file)
@@ -4082,13 +4082,21 @@ static void __bt_handle_client_service_changed_ind(event_gattc_service_changed_d
        char *address_str = NULL;
        char *uuid_str = NULL;
 
        char *address_str = NULL;
        char *uuid_str = NULL;
 
-       if (event_data->change_type == 0) {
-               svc_info_list = __bt_get_service_info_list(event_data->conn_id);
-               if (svc_info_list == NULL) {
-                       BT_ERR("svc_info_list is NULL");
-                       return;
-               }
+       svc_info_list = __bt_get_service_info_list(event_data->conn_id);
+       if (svc_info_list == NULL) {
+               BT_ERR("svc_info_list is NULL");
+               return;
+       }
 
 
+       if (event_data->change_type) {
+               /* Add service UUID in list */
+               svc_info = g_malloc0(sizeof(bt_gatt_service_info_t));
+               memcpy(svc_info->uuid, event_data->uuid.uuid, BLUETOOTH_UUID_HEX_MAX_LEN);
+               svc_info->inst_id = event_data->inst_id;
+               svc_info->is_primary = 1; // TODO: Need to check is_primary is required or not
+               svc_info_list->services = g_slist_append(svc_info_list->services, svc_info);
+               BT_DBG("Service created and added in Svc info list or connection ID %d", event_data->conn_id);
+       } else {
                /* Remove service UUID in list */
                for (l = svc_info_list->services; l != NULL; l = g_slist_next(l)) {
                        svc_info = (bt_gatt_service_info_t *)l->data;
                /* Remove service UUID in list */
                for (l = svc_info_list->services; l != NULL; l = g_slist_next(l)) {
                        svc_info = (bt_gatt_service_info_t *)l->data;
@@ -4108,7 +4116,7 @@ static void __bt_handle_client_service_changed_ind(event_gattc_service_changed_d
        _bt_convert_addr_type_to_string(address_str, event_data->address.addr);
        _bt_uuid_to_string(&event_data->uuid, uuid_str);
 
        _bt_convert_addr_type_to_string(address_str, event_data->address.addr);
        _bt_uuid_to_string(&event_data->uuid, uuid_str);
 
-       param = g_variant_new("(iss)", event_data->change_type, address_str, uuid_str);
+       param = g_variant_new("(iiss)", event_data->inst_id, event_data->change_type, address_str, uuid_str);
 
        _bt_send_event(BT_GATT_CLIENT_EVENT,
                        BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
 
        _bt_send_event(BT_GATT_CLIENT_EVENT,
                        BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED,
index 5ce249f..9fef6cc 100644 (file)
@@ -1716,6 +1716,7 @@ typedef struct {
        char *svc_path;
        bluetooth_gatt_service_change_type_t change_type;
 #ifdef TIZEN_GATT_CLIENT
        char *svc_path;
        bluetooth_gatt_service_change_type_t change_type;
 #ifdef TIZEN_GATT_CLIENT
+       int inst_id;
        char *uuid;
 #endif
 } bt_gatt_service_change_t;
        char *uuid;
 #endif
 } bt_gatt_service_change_t;