From 2edb4a4a5ff1aae9001ed92b47045764256a3758 Mon Sep 17 00:00:00 2001 From: Marcin Kraglak Date: Thu, 27 Mar 2014 22:13:00 +0100 Subject: [PATCH] android/gatt: Add helper to get client by id It will look for gatt_client by client_id. --- android/gatt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/android/gatt.c b/android/gatt.c index 665cf0f74..81b29af3d 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -148,6 +148,11 @@ static bool match_client_by_id(const void *data, const void *user_data) return client->id == exp_id; } +static struct gatt_client *find_client_by_id(int32_t id) +{ + return queue_find(gatt_clients, match_client_by_id, INT_TO_PTR(id)); +} + static bool match_by_value(const void *data, const void *user_data) { return data == user_data; @@ -633,8 +638,7 @@ static void handle_client_scan(const void *buf, uint16_t len) DBG("new state %d", cmd->start); - registered = queue_find(gatt_clients, match_client_by_id, - INT_TO_PTR(cmd->client_if)); + registered = find_client_by_id(cmd->client_if); if (!registered) { error("gatt: Client not registered"); status = HAL_STATUS_FAILED; @@ -730,8 +734,7 @@ static void handle_client_connect(const void *buf, uint16_t len) DBG(""); /* Check if client is registered */ - l = queue_find(gatt_clients, match_client_by_id, - INT_TO_PTR(cmd->client_if)); + l = find_client_by_id(cmd->client_if); if (!l) { error("gatt: Client id %d not found", cmd->client_if); status = HAL_STATUS_FAILED; -- 2.47.3