Diff between 99309507de8f43a83e353e25e72a66ce28105191 and 34cd14d15ed11d76c87cbfad221b2de12aa77239

Changed Files

File Additions Deletions Status
android/gatt.c +47 -47 modified

Full Patch

diff --git a/android/gatt.c b/android/gatt.c
index 14fd164..f53884b 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -116,7 +116,7 @@ struct service {
 struct notification_data {
 	struct hal_gatt_srvc_id service;
 	struct hal_gatt_gatt_id ch;
-	struct connection *conn;
+	struct app_connection *conn;
 	guint notif_id;
 	guint ind_id;
 	int ref;
@@ -138,7 +138,7 @@ struct gatt_device {
 	int conn_cnt;
 };
 
-struct connection {
+struct app_connection {
 	struct gatt_device *device;
 	struct gatt_app *app;
 	int32_t id;
@@ -301,7 +301,7 @@ static bool match_pending_device(const void *data, const void *user_data)
 
 static bool match_connection_by_id(const void *data, const void *user_data)
 {
-	const struct connection *conn = data;
+	const struct app_connection *conn = data;
 	const int32_t id = PTR_TO_INT(user_data);
 
 	return conn->id == id;
@@ -310,13 +310,13 @@ static bool match_connection_by_id(const void *data, const void *user_data)
 static bool match_connection_by_device_and_app(const void *data,
 							const void *user_data)
 {
-	const struct connection *conn = data;
-	const struct connection *match = user_data;
+	const struct app_connection *conn = data;
+	const struct app_connection *match = user_data;
 
 	return conn->device == match->device && conn->app == match->app;
 }
 
-static struct connection *find_connection_by_id(int32_t conn_id)
+static struct app_connection *find_connection_by_id(int32_t conn_id)
 {
 	return queue_find(app_connections, match_connection_by_id,
 							INT_TO_PTR(conn_id));
@@ -324,7 +324,7 @@ static struct connection *find_connection_by_id(int32_t conn_id)
 
 static bool match_connection_by_device(const void *data, const void *user_data)
 {
-	const struct connection *conn = data;
+	const struct app_connection *conn = data;
 	const struct gatt_device *dev = user_data;
 
 	return conn->device == dev;
@@ -332,7 +332,7 @@ static bool match_connection_by_device(const void *data, const void *user_data)
 
 static bool match_connection_by_app(const void *data, const void *user_data)
 {
-	const struct connection *conn = data;
+	const struct app_connection *conn = data;
 	const struct gatt_app *app = user_data;
 
 	return conn->app == app;
@@ -596,7 +596,7 @@ failed:
 									status);
 }
 
-static void send_client_disconnection_notify(struct connection *connection,
+static void send_client_disconnection_notify(struct app_connection *connection,
 								int32_t status)
 {
 	struct hal_ev_gatt_client_disconnect ev;
@@ -611,7 +611,7 @@ static void send_client_disconnection_notify(struct connection *connection,
 				HAL_EV_GATT_CLIENT_DISCONNECT, sizeof(ev), &ev);
 }
 
-static void send_client_connection_notify(struct connection *connection,
+static void send_client_connection_notify(struct app_connection *connection,
 								int32_t status)
 {
 	struct hal_ev_gatt_client_connect ev;
@@ -626,7 +626,7 @@ static void send_client_connection_notify(struct connection *connection,
 							sizeof(ev), &ev);
 }
 
-static void send_app_disconnect_notify(struct connection *connection,
+static void send_app_disconnect_notify(struct app_connection *connection,
 								int32_t status)
 {
 	if (connection->app->type == APP_CLIENT)
@@ -634,7 +634,7 @@ static void send_app_disconnect_notify(struct connection *connection,
 	/* TODO: handle APP_SERVER */
 }
 
-static void send_app_connect_notify(struct connection *connection,
+static void send_app_connect_notify(struct app_connection *connection,
 								int32_t status)
 {
 	if (connection->app->type == APP_CLIENT)
@@ -644,7 +644,7 @@ static void send_app_connect_notify(struct connection *connection,
 
 static void disconnect_notify_by_device(void *data, void *user_data)
 {
-	struct connection *conn = data;
+	struct app_connection *conn = data;
 	struct gatt_device *dev = user_data;
 
 	if (dev != conn->device)
@@ -692,7 +692,7 @@ static void device_unref(struct gatt_device *device)
 
 static void destroy_connection(void *data)
 {
-	struct connection *conn = data;
+	struct app_connection *conn = data;
 
 	if (!queue_find(gatt_devices, match_by_value, conn->device))
 		goto cleanup;
@@ -736,7 +736,7 @@ static void send_client_primary_notify(void *data, void *user_data)
 					sizeof(ev), &ev);
 }
 
-static void send_client_all_primary(struct connection *connection,
+static void send_client_all_primary(struct app_connection *connection,
 								int32_t status)
 {
 	struct hal_ev_gatt_client_search_complete ev;
@@ -802,7 +802,7 @@ static struct service *create_service(uint8_t id, bool primary, char *uuid,
 
 static void primary_cb(uint8_t status, GSList *services, void *user_data)
 {
-	struct connection *conn = user_data;
+	struct app_connection *conn = user_data;
 	GSList *l;
 	int32_t gatt_status;
 	uint8_t instance_id;
@@ -921,7 +921,7 @@ struct connect_data {
 
 static void send_app_connect_notifications(void *data, void *user_data)
 {
-	struct connection *conn = data;
+	struct app_connection *conn = data;
 	struct connect_data *con_data = user_data;
 
 	if (conn->device == con_data->dev)
@@ -1121,14 +1121,14 @@ static struct gatt_device *create_device(const bdaddr_t *addr)
 	return device_ref(dev);
 }
 
-static struct connection *create_connection(struct gatt_device *device,
+static struct app_connection *create_connection(struct gatt_device *device,
 						struct gatt_app *app)
 {
-	struct connection *new_conn;
+	struct app_connection *new_conn;
 	static int32_t last_conn_id = 1;
 
 	/* Check if already connected */
-	new_conn = new0(struct connection, 1);
+	new_conn = new0(struct app_connection, 1);
 	if (!new_conn)
 		return NULL;
 
@@ -1151,7 +1151,7 @@ static struct connection *create_connection(struct gatt_device *device,
 	return new_conn;
 }
 
-static void trigger_disconnection(struct connection *connection)
+static void trigger_disconnection(struct app_connection *connection)
 {
 	/* Notify client */
 	if (queue_remove(app_connections, connection))
@@ -1162,7 +1162,7 @@ static void trigger_disconnection(struct connection *connection)
 
 static void app_disconnect_devices(struct gatt_app *client)
 {
-	struct connection *conn;
+	struct app_connection *conn;
 
 	/* find every connection for client record and trigger disconnect */
 	conn = queue_remove_if(app_connections, match_connection_by_app,
@@ -1175,7 +1175,7 @@ static void app_disconnect_devices(struct gatt_app *client)
 	}
 }
 
-static bool trigger_connection(struct connection *connection)
+static bool trigger_connection(struct app_connection *connection)
 {
 	switch (connection->device->state) {
 	case DEVICE_DISCONNECTED:
@@ -1225,10 +1225,10 @@ static void handle_client_unregister(const void *buf, uint16_t len)
 					HAL_OP_GATT_CLIENT_UNREGISTER, status);
 }
 
-static struct connection *find_conn(const bdaddr_t *addr, int32_t app_id,
+static struct app_connection *find_conn(const bdaddr_t *addr, int32_t app_id,
 							int32_t app_type)
 {
-	struct connection conn_match;
+	struct app_connection conn_match;
 	struct gatt_device *dev = NULL;
 	struct gatt_app *app;
 
@@ -1256,8 +1256,8 @@ static struct connection *find_conn(const bdaddr_t *addr, int32_t app_id,
 static void handle_client_connect(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_gatt_client_connect *cmd = buf;
-	struct connection conn_match;
-	struct connection *conn;
+	struct app_connection conn_match;
+	struct app_connection *conn;
 	struct gatt_device *device;
 	struct gatt_app *client;
 	bdaddr_t addr;
@@ -1310,7 +1310,7 @@ reply:
 static void handle_client_disconnect(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_gatt_client_disconnect *cmd = buf;
-	struct connection *conn;
+	struct app_connection *conn;
 	uint8_t status;
 
 	DBG("");
@@ -1489,7 +1489,7 @@ done:
 static void handle_client_search_service(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_gatt_client_search_service *cmd = buf;
-	struct connection *conn;
+	struct app_connection *conn;
 	uint8_t status;
 
 	DBG("");
@@ -1566,7 +1566,7 @@ static void send_client_incl_service_notify(const struct service *prim,
 
 struct get_included_data {
 	struct service *prim;
-	struct connection *conn;
+	struct app_connection *conn;
 };
 
 static int get_inst_id_of_prim_services(const struct gatt_device *dev)
@@ -1582,7 +1582,7 @@ static int get_inst_id_of_prim_services(const struct gatt_device *dev)
 static void get_included_cb(uint8_t status, GSList *included, void *user_data)
 {
 	struct get_included_data *data = user_data;
-	struct connection *conn = data->conn;
+	struct app_connection *conn = data->conn;
 	struct service *service = data->prim;
 	struct service *incl;
 	int instance_id;
@@ -1645,7 +1645,7 @@ failed:
 								GATT_FAILURE);
 }
 
-static bool search_included_services(struct connection *connection,
+static bool search_included_services(struct app_connection *connection,
 							struct service *service)
 {
 	struct get_included_data *data;
@@ -1666,11 +1666,11 @@ static bool search_included_services(struct connection *connection,
 }
 
 static bool find_service(int32_t conn_id, struct element_id *service_id,
-					struct connection **connection,
+					struct app_connection **connection,
 					struct service **service)
 {
 	struct service *srvc;
-	struct connection *conn;
+	struct app_connection *conn;
 
 	conn = find_connection_by_id(conn_id);
 	if (!conn) {
@@ -1695,7 +1695,7 @@ static bool find_service(int32_t conn_id, struct element_id *service_id,
 static void handle_client_get_included_service(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_gatt_client_get_included_service *cmd = buf;
-	struct connection *conn;
+	struct app_connection *conn;
 	struct service *prim_service;
 	struct service *incl_service;
 	struct element_id match_id;
@@ -1856,7 +1856,7 @@ static void handle_client_get_characteristic(const void *buf, uint16_t len)
 	const struct hal_cmd_gatt_client_get_characteristic *cmd = buf;
 	struct characteristic *ch;
 	struct element_id match_id;
-	struct connection *conn;
+	struct app_connection *conn;
 	struct service *srvc;
 	uint8_t status;
 
@@ -1997,7 +1997,7 @@ static uint16_t parse_descrs(const uint8_t *pdu, guint16 len,
 }
 
 struct discover_desc_data {
-	struct connection *conn;
+	struct app_connection *conn;
 	struct service *srvc;
 	struct characteristic *ch;
 
@@ -2008,7 +2008,7 @@ static void gatt_discover_desc_cb(guint8 status, const guint8 *pdu, guint16 len,
 							gpointer user_data)
 {
 	struct discover_desc_data *data = user_data;
-	struct connection *conn = data->conn;
+	struct app_connection *conn = data->conn;
 	struct service *srvc = data->srvc;
 	struct characteristic *ch = data->ch;
 	struct descriptor *descr;
@@ -2044,7 +2044,7 @@ reply:
 	free(data);
 }
 
-static bool build_descr_cache(struct connection *connection,
+static bool build_descr_cache(struct app_connection *connection,
 					struct service *srvc,
 					struct characteristic *ch)
 {
@@ -2091,7 +2091,7 @@ static void handle_client_get_descriptor(const void *buf, uint16_t len)
 	struct service *srvc;
 	struct element_id srvc_id;
 	struct element_id char_id;
-	struct connection *conn;
+	struct app_connection *conn;
 	int32_t conn_id;
 	uint8_t primary;
 	uint8_t status;
@@ -2232,7 +2232,7 @@ static void handle_client_read_characteristic(const void *buf, uint16_t len)
 	const struct hal_cmd_gatt_client_read_characteristic *cmd = buf;
 	struct char_op_data *cb_data;
 	struct characteristic *ch;
-	struct connection *conn;
+	struct app_connection *conn;
 	struct service *srvc;
 	struct element_id srvc_id;
 	struct element_id char_id;
@@ -2327,7 +2327,7 @@ static void handle_client_write_characteristic(const void *buf, uint16_t len)
 	const struct hal_cmd_gatt_client_write_characteristic *cmd = buf;
 	struct char_op_data *cb_data = NULL;
 	struct characteristic *ch;
-	struct connection *conn;
+	struct app_connection *conn;
 	struct service *srvc;
 	struct element_id srvc_id;
 	struct element_id char_id;
@@ -2513,7 +2513,7 @@ static void handle_client_read_descriptor(const void *buf, uint16_t len)
 	struct element_id char_id;
 	struct element_id descr_id;
 	struct element_id srvc_id;
-	struct connection *conn;
+	struct app_connection *conn;
 	int32_t conn_id = 0;
 	uint8_t primary;
 	uint8_t status;
@@ -2628,7 +2628,7 @@ static void handle_client_write_descriptor(const void *buf, uint16_t len)
 	struct element_id srvc_id;
 	struct element_id char_id;
 	struct element_id descr_id;
-	struct connection *conn;
+	struct app_connection *conn;
 	int32_t conn_id;
 	uint8_t primary;
 	uint8_t status;
@@ -2751,7 +2751,7 @@ static void write_execute_cb(guint8 status, const guint8 *pdu, guint16 len,
 static void handle_client_execute_write(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_gatt_client_execute_write *cmd = buf;
-	struct connection *conn;
+	struct app_connection *conn;
 	uint8_t status;
 	uint8_t flags;
 
@@ -2846,7 +2846,7 @@ static void handle_client_register_for_notification(const void *buf,
 	struct notification_data *notification;
 	struct characteristic *c;
 	struct element_id match_id;
-	struct connection *conn;
+	struct app_connection *conn;
 	int32_t conn_id = 0;
 	struct service *service;
 	uint8_t status;
@@ -2952,7 +2952,7 @@ static void handle_client_deregister_for_notification(const void *buf,
 {
 	const struct hal_cmd_gatt_client_deregister_for_notification *cmd = buf;
 	struct notification_data *notification, notif;
-	struct connection *conn;
+	struct app_connection *conn;
 	int32_t conn_id = 0;
 	uint8_t status;
 	int32_t gatt_status;