Revert "Integrate gatt connection info" 04/304304/1
authorWootak Jung <wootak.jung@samsung.com>
Mon, 6 Nov 2023 00:34:45 +0000 (09:34 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 15 Jan 2024 22:46:49 +0000 (07:46 +0900)
This reverts commit 837896a29835d78365a7e1d852de09e1821635bc.

Change-Id: I1179a05fb78b678aabfe0a8528090b4f4dc900ff
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-service/services/gatt/bt-service-gatt.c
bt-service/services/include/bt-service-gatt.h

index 731ecc9..3daff77 100644 (file)
@@ -125,39 +125,8 @@ 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__ // TODO: this feature can be used if easy setup scenario is fully supported and the name need to be changed to avoid confusion with existing GATT flags
-#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;
@@ -239,6 +208,13 @@ 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 */
@@ -303,6 +279,9 @@ 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;
 
@@ -1716,9 +1695,7 @@ 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;
@@ -1760,14 +1737,10 @@ 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 + 12);
                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);
@@ -1776,7 +1749,6 @@ 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) {
@@ -1794,9 +1766,7 @@ 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];
@@ -1847,7 +1817,6 @@ 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) {
@@ -1858,10 +1827,6 @@ static void __bt_handle_gatt_server_disconnection_state(event_gatts_conn_t *even
                } else {
                        BT_INFO("Can not find conn info, already removed!");
                }
-#else
-               /* Remove all services from info list_gatt_info */
-               __bt_cleanup_remote_services(client_info);
-#endif
 
                /* Remove client info from List */
                gatt_client_info_list = g_slist_remove(gatt_client_info_list, client_info);
@@ -3654,9 +3619,6 @@ 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]",
@@ -3695,9 +3657,7 @@ static void __bt_handle_client_disconnected(event_gattc_conn_t *event_data)
 {
        int result = BLUETOOTH_ERROR_NONE;
        struct gatt_server_info_t *conn_info = NULL;
-#ifndef __INTEGRATE_GATT_INFO__
        struct gatt_client_info_t *client_info = NULL;
-#endif
        struct gatt_out_conn_info_t *out_conn_info = NULL;
        GVariant *param = NULL;
 
@@ -3753,7 +3713,6 @@ static void __bt_handle_client_disconnected(event_gattc_conn_t *event_data)
        } else
                BT_INFO("Can not find conn info, already removed!");
 
-#ifndef __INTEGRATE_GATT_INFO__
        /* Remove client info */
        client_info = _bt_find_remote_gatt_client_info(address);
        if (client_info) {
@@ -3762,7 +3721,6 @@ static void __bt_handle_client_disconnected(event_gattc_conn_t *event_data)
                g_free(client_info->addr);
                g_free(client_info);
        }
-#endif
 
        __bt_remove_mtu_gatt_device(address);
 
index 4140b4e..845169b 100644 (file)
@@ -94,12 +94,7 @@ 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__ // TODO: this feature can be used if easy setup scenario is fully supported
-#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
 
 char * _bt_gatt_get_default_gatt_client_uuid(void);
 
@@ -162,11 +157,7 @@ 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
 
 #ifdef __cplusplus
 }