[PATCH v2 2/2] android/gatt: Handle Unregister gatt client command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds unregister gatt client app command handling.
---
 android/gatt.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index 5206f5e..bc90814 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -55,6 +55,15 @@ static int find_client_uuid(gconstpointer data, gconstpointer user_data)
 	return memcmp(exp_uuid, cur_uuid, sizeof(client->uuid));
 }
 
+static int find_client_if(gconstpointer data, gconstpointer user_data)
+{
+	const int32_t exp_cif = GPOINTER_TO_INT(user_data);
+	const struct gatt_clients *client = data;
+	const int32_t cur_cif = client->client_if;
+
+	return cur_cif != exp_cif;
+}
+
 static void handle_client_register(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_gatt_client_register *cmd = buf;
@@ -101,10 +110,29 @@ failed:
 
 static void handle_client_unregister(const void *buf, uint16_t len)
 {
+	const struct hal_cmd_gatt_client_unregister *cmd = buf;
+	GSList *found_client_if;
+	uint8_t status;
+
 	DBG("");
 
+	found_client_if = g_slist_find_custom(gatt_clients_list,
+						GINT_TO_POINTER(cmd->client_if),
+						find_client_if);
+	if (!found_client_if) {
+		error("gatt: client_if: %d not found", cmd->client_if);
+		status = HAL_STATUS_FAILED;
+		goto failed;
+	}
+
+	gatt_clients_list = g_slist_remove(gatt_clients_list,
+							found_client_if->data);
+
+	status = HAL_STATUS_SUCCESS;
+
+failed:
 	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
-			HAL_OP_GATT_CLIENT_UNREGISTER, HAL_STATUS_FAILED);
+					HAL_OP_GATT_CLIENT_UNREGISTER, status);
 }
 
 static void handle_client_scan(const void *buf, uint16_t len)
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux