From: Wootak Jung Date: Thu, 19 Mar 2020 02:04:43 +0000 (+0900) Subject: Integrate gatt connection info X-Git-Tag: accepted/tizen/5.5/unified/20200323.173147~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F228075%2F1;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git Integrate gatt connection info no need each connection info Change-Id: I143977735f74455ad2c3ab4d2497c0a0b818312a --- diff --git a/bt-service-adaptation/services/gatt/bt-service-gatt.c b/bt-service-adaptation/services/gatt/bt-service-gatt.c index 62283e1..5a9dc01 100644 --- a/bt-service-adaptation/services/gatt/bt-service-gatt.c +++ b/bt-service-adaptation/services/gatt/bt-service-gatt.c @@ -133,8 +133,39 @@ struct gatt_server_info_t { char *addr; /* Remote GATT Server address */ }; +struct gatt_client_info_t { + int connection_id; /* This value will uniquely identify a GATT client-server connection */ + int instance_id; /* This value unique identifies a GATT server instance */ + char *addr; /* Remote GATT client address */ +}; + +/* TODO: + * Remove this feature if code is verified + * Remove gatt_client/server_info_t and use gatt_conn_info_t + * Remove gatt_client/server_info_list and use gatt_conn_info_list + */ +#define __INTEGRATE_GATT_INFO__ +#ifndef __INTEGRATE_GATT_INFO__ /* Linked List of connected Remote GATT Servers */ static GSList *gatt_server_info_list = NULL; +/* Linked List of connected Remote GATT clients */ +static GSList *gatt_client_info_list = NULL; +#else +/* GATT Connection Info List Structure */ +struct gatt_conn_info_t { + char *addr; /* Remote GATT address */ + int connection_id; /* This value will uniquely identify a GATT client-server connection */ + int client_id; /* This value unique identifies a GATT Client instance */ + int instance_id; /* This value unique identifies a GATT Server instance */ +}; + +/* Linked List of connected Remote GATT info */ +static GSList *gatt_conn_info_list = NULL; +#define gatt_server_info_t gatt_conn_info_t +#define gatt_client_info_t gatt_conn_info_t +#define gatt_server_info_list gatt_conn_info_list +#define gatt_client_info_list gatt_conn_info_list +#endif typedef struct { gboolean is_changed; @@ -214,13 +245,6 @@ struct gatt_server_req_info { char *addr; /* Remote GATT client address */ }; -/* GATT Client Info List Structure */ -struct gatt_client_info_t { - int connection_id; /* This value will uniquely identify a GATT client-server connection */ - int instance_id; /* This value unique identifies a GATT server instance */ - char *addr; /* Remote GATT client address */ -}; - /* GATT Indicate confirm result */ struct gatt_indicate_cfm_result_info_t { int result; /* Result of event */ @@ -283,9 +307,6 @@ static void __bt_update_mtu_gatt_device(char *address, int mtu); /* Linked List of GATT requests from Remote GATT Clients */ static GSList *gatt_server_requests = NULL; -/* Linked List of connected Remote GATT clients */ -static GSList *gatt_client_info_list = NULL; - /* Number of clients to be notified to */ static int num_indicate_clients; @@ -1476,7 +1497,9 @@ static void __bt_handle_gatt_server_connection_state(event_gatts_conn_t *event) { int result = BLUETOOTH_ERROR_NONE; struct gatt_client_info_t *client_info = NULL; +#ifndef __INTEGRATE_GATT_INFO__ struct gatt_server_info_t *server_info = NULL; +#endif bluetooth_device_address_t dev_addr; GVariant *param = NULL; int ret; @@ -1518,10 +1541,14 @@ static void __bt_handle_gatt_server_connection_state(event_gatts_conn_t *event) client_info->addr = g_strdup(address); BT_INFO("Added GATT client addr[%s]", client_info->addr); client_info->connection_id = event->conn_id; +#ifdef __INTEGRATE_GATT_INFO__ + client_info->client_id = -1; +#endif client_info->instance_id = event->server_inst; gatt_client_info_list = g_slist_append(gatt_client_info_list, client_info); BT_INFO("Total num of connected Remote GATT Clients [%d]", g_slist_length(gatt_client_info_list)); +#ifndef __INTEGRATE_GATT_INFO__ /* Save server connection info */ server_info = g_new0(struct gatt_server_info_t, 1); server_info->addr = g_strdup(address); @@ -1530,6 +1557,7 @@ static void __bt_handle_gatt_server_connection_state(event_gatts_conn_t *event) server_info->connection_id = event->conn_id; gatt_server_info_list = g_slist_append(gatt_server_info_list, server_info); BT_INFO("Total num of connected Remote GATT Servers [%d]", g_slist_length(gatt_server_info_list)); +#endif ret = gattc_add_connection_info((bt_address_t *)&dev_addr, event->conn_id, event->server_inst); if (ret != OAL_STATUS_SUCCESS) { @@ -1547,7 +1575,9 @@ static void __bt_handle_gatt_server_disconnection_state(event_gatts_conn_t *even { int result = BLUETOOTH_ERROR_NONE; struct gatt_client_info_t *client_info = NULL; +#ifndef __INTEGRATE_GATT_INFO__ struct gatt_server_info_t *server_info = NULL; +#endif bluetooth_device_address_t dev_addr; GVariant *param = NULL; char address[BT_ADDRESS_STRING_SIZE]; @@ -1590,12 +1620,14 @@ static void __bt_handle_gatt_server_disconnection_state(event_gatts_conn_t *even BLUETOOTH_EVENT_GATT_SERVER_DISCONNECTED, /* Local device is GATT server */ param); +#ifndef __INTEGRATE_GATT_INFO__ /* Remove server info from list */ server_info = _bt_find_remote_gatt_server_info(address); if (server_info) gatt_server_info_list = g_slist_remove(gatt_server_info_list, server_info); else BT_INFO("Can not find conn info, already removed!"); +#endif /* Remove client info from List */ gatt_client_info_list = g_slist_remove(gatt_client_info_list, client_info); @@ -3131,6 +3163,9 @@ static void __bt_handle_client_connected(event_gattc_conn_t *event_data) conn_info = g_new0(struct gatt_server_info_t, 1); conn_info->addr = g_strdup(address); conn_info->client_id = event_data->client_if; +#ifdef __INTEGRATE_GATT_INFO__ + conn_info->instance_id = -1; +#endif conn_info->connection_id = event_data->conn_id; gatt_server_info_list = g_slist_append(gatt_server_info_list, conn_info); BT_DBG("Total num of connected Remote GATT server devices [%d]", diff --git a/bt-service-adaptation/services/include/bt-service-gatt.h b/bt-service-adaptation/services/include/bt-service-gatt.h index cabf594..70a2ce7 100644 --- a/bt-service-adaptation/services/include/bt-service-gatt.h +++ b/bt-service-adaptation/services/include/bt-service-gatt.h @@ -97,7 +97,12 @@ int _bt_get_att_mtu(bluetooth_device_address_t *address, int _bt_gatt_server_acquire_send_response(char *sender, bluetooth_gatt_server_acquire_response_params_t *param, void *); +#define __INTEGRATE_GATT_INFO__ +#ifndef __INTEGRATE_GATT_INFO__ struct gatt_client_info_t *_bt_find_remote_gatt_client_info(char *address); +#else +struct gatt_conn_info_t *_bt_find_remote_gatt_client_info(char *address); +#endif #ifdef TIZEN_GATT_CLIENT char * _bt_gatt_get_default_gatt_client_uuid(void); @@ -153,7 +158,11 @@ int _bt_unregister_gatt_client_instance(const char *sender, int client_id); int _bt_request_att_mtu(bluetooth_device_address_t *device_address, unsigned int mtu); +#ifndef __INTEGRATE_GATT_INFO__ struct gatt_server_info_t *_bt_find_remote_gatt_server_info(char *address); +#else +struct gatt_conn_info_t *_bt_find_remote_gatt_server_info(char *address); +#endif #endif //int _bt_gatt_server_enable_application(int instance_id);