Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/5] android/gatt: Fix sending notification for register gatt client
@ 2014-04-07 12:05 Grzegorz Kolodziejczyk
  2014-04-07 12:05 ` [PATCH 2/5] android/tester: Add register client success test case Grzegorz Kolodziejczyk
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-04-07 12:05 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds missing send notification in case of errors for gatt
client registration. In case of error status GATT_FAILURE with given in
cmd UUID is send in notification.
---
 android/gatt.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/android/gatt.c b/android/gatt.c
index 4f0a656..3628642 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -413,6 +413,8 @@ static void handle_client_register(const void *buf, uint16_t len)
 
 	DBG("");
 
+	memset(&ev, 0, sizeof(ev));
+
 	if (queue_find(gatt_clients, match_client_by_uuid, &cmd->uuid)) {
 		error("gatt: client uuid is already on list");
 		status = HAL_STATUS_FAILED;
@@ -422,12 +424,10 @@ static void handle_client_register(const void *buf, uint16_t len)
 	client = new0(struct gatt_client, 1);
 	if (!client) {
 		error("gatt: cannot allocate memory for registering client");
-		status = HAL_STATUS_FAILED;
+		status = HAL_STATUS_NOMEM;
 		goto failed;
 	}
 
-	memcpy(client->uuid, cmd->uuid, sizeof(client->uuid));
-
 	client->notifications = queue_new();
 	if (!client->notifications) {
 		error("gatt: couldn't allocate notifications queue");
@@ -436,22 +436,34 @@ static void handle_client_register(const void *buf, uint16_t len)
 		goto failed;
 	}
 
-	client->id = client_cnt++;
+	memcpy(client->uuid, cmd->uuid, sizeof(client->uuid));
 
-	queue_push_head(gatt_clients, client);
+	client->id = client_cnt++;
 
-	status = HAL_STATUS_SUCCESS;
+	if (!queue_push_head(gatt_clients, client)) {
+		error("gatt: Cannot push client on the list");
+		destroy_gatt_client(client);
+		status = HAL_STATUS_FAILED;
+		goto failed;
+	}
 
 	ev.status = GATT_SUCCESS;
 	ev.client_if = client->id;
-	memcpy(ev.app_uuid, client->uuid, sizeof(client->uuid));
+
+	status = HAL_STATUS_SUCCESS;
+
+failed:
+	if (status != HAL_STATUS_SUCCESS)
+		ev.status = GATT_FAILURE;
+
+	/* We should send notification with given in cmd UUID */
+	memcpy(ev.app_uuid, cmd->uuid, sizeof(ev.app_uuid));
 
 	ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT,
 			HAL_EV_GATT_CLIENT_REGISTER_CLIENT, sizeof(ev), &ev);
 
-failed:
-	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
-					HAL_OP_GATT_CLIENT_REGISTER, status);
+	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT, HAL_OP_GATT_CLIENT_REGISTER,
+									status);
 }
 
 static void handle_client_unregister(const void *buf, uint16_t len)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-04-10  9:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-07 12:05 [PATCH 1/5] android/gatt: Fix sending notification for register gatt client Grzegorz Kolodziejczyk
2014-04-07 12:05 ` [PATCH 2/5] android/tester: Add register client success test case Grzegorz Kolodziejczyk
2014-04-07 12:05 ` [PATCH 3/5] android/tester: Add register client fail " Grzegorz Kolodziejczyk
2014-04-07 12:05 ` [PATCH 4/5] android/tester: Add unregister client success " Grzegorz Kolodziejczyk
2014-04-07 12:05 ` [PATCH 5/5] android/tester: Add unregister client fail " Grzegorz Kolodziejczyk
2014-04-10  9:57 ` [PATCH 1/5] android/gatt: Fix sending notification for register gatt client Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox