typedef struct {
bt_bdaddr_t bd_addr; /*remote server address*/
+ int conn_id;
int inst_id; /*server instance id*/
GSList *gatt_list_services;
} hal_gattc_server_info_t;
if (server_info == NULL) {
server_info = g_malloc0(sizeof(hal_gattc_server_info_t));
memcpy(server_info->bd_addr.address, bd_addr->address, BT_HAL_ADDRESS_LENGTH_MAX);
+ server_info->conn_id = conn_id;
server_info->inst_id = server_inst_id;
hal_gattc_server_info_list = g_slist_append(hal_gattc_server_info_list, server_info);
DBG("Added server connection info in list");
return BT_STATUS_FAIL;
}
+#if 0
+ // TODO: This logic is not able to handle in case service-added event is coming unexpectedly.
/* Check the service info is stored */
if (g_slist_length(conn_info->gatt_list_services) > 0) {
GSList *l = NULL;
} else {
DBG("No stored service, request to bluez");
}
+#endif
_bt_hal_convert_addr_type_to_string(device_address,
(unsigned char *)conn_info->bd_addr.address);
/*add gatt server connection info*/
gatt_conn_info = g_malloc0(sizeof(hal_gattc_server_info_t));
memcpy(gatt_conn_info->bd_addr.address, gattc_data->bd_addr.address, BT_HAL_ADDRESS_LENGTH_MAX);
+ gatt_conn_info->conn_id = gattc_data->conn_id;
gatt_conn_info->inst_id = gattc_data->inst_id;
hal_gattc_server_info_list = g_slist_append(hal_gattc_server_info_list, gatt_conn_info);
_bt_hal_convert_device_path_to_address(path, address);
_bt_hal_convert_addr_string_to_type(ev.bdaddr, address);
- ev.change_type = is_added;
server_info = __bt_find_gatt_conn_info((bt_bdaddr_t *)ev.bdaddr);
if (server_info == NULL) {
ERR("service_info is NULL");
}
if (is_added) {
+ /* Get service UUID from path */
__bt_hal_gattc_get_uuid_from_path(path, &uuid_str);
- DBG("GATT Service(%s) Added", uuid_str);
- /* Set UUID by using path */
- _bt_hal_convert_uuid_string_to_type(ev.uuid, uuid_str);
- g_free(uuid_str);
+ if (uuid_str) {
+ DBG("conn_id(%d) GATT Service(%s) Added", server_info->conn_id, uuid_str);
+ _bt_hal_convert_uuid_string_to_type(ev.uuid, uuid_str);
+ g_free(uuid_str);
+ } else {
+ ERR("uuid_str is NULL");
+ return;
+ }
/* Create new service and append into the list */
__hal_gattc_get_service_info(server_info, path);
if (g_strcmp0(service->svc_path, path) == 0) {
memcpy(ev.uuid, service->svc_uuid.uu, sizeof(bt_uuid_t));
uuid_str = g_malloc0(BT_HAL_UUID_STRING_LEN);
- /* Set UUID from stored service info */
_bt_hal_convert_uuid_type_to_string(uuid_str, ev.uuid);
- DBG("GATT Service(%s) Removed", uuid_str);
- g_free(uuid_str);
+ DBG("conn_id(%d) GATT Service(%s) Removed", server_info->conn_id, uuid_str);
/* Remove service info in list */
server_info->gatt_list_services = g_slist_remove(server_info->gatt_list_services, service);
break;
}
}
+
+ if (uuid_str) {
+ g_free(uuid_str);
+ } else {
+ ERR("uuid_str is NULL");
+ return;
+ }
}
/* Send GATT Client service changed event */
+ ev.change_type = is_added;
+ ev.conn_id = server_info->conn_id;
event_cb(HAL_EV_GATT_CLIENT_SERVICE_CHANGED, (void *)&ev, sizeof(ev));
}
-