From 05cd11a144e6e15bdd9d4810c446c3be182e0c7d Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Thu, 17 Apr 2014 01:10:28 +0200 Subject: [PATCH] android/hal-gatt-api: Fix IPC definition for get_characteristic --- android/gatt.c | 6 +++--- android/hal-gatt.c | 8 ++++---- android/hal-ipc-api.txt | 11 ++++++----- android/hal-msg.h | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/android/gatt.c b/android/gatt.c index a4a10489b..9d0b2a2be 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -1799,7 +1799,7 @@ static void handle_client_get_characteristic(const void *buf, uint16_t len) DBG(""); - if (len != sizeof(*cmd) + (cmd->number * sizeof(cmd->gatt_id[0]))) { + if (len != sizeof(*cmd) + (cmd->continuation ? sizeof(cmd->char_id[0]) : 0)) { error("Invalid get characteristic size (%u bytes), terminating", len); raise(SIGTERM); @@ -1843,9 +1843,9 @@ static void handle_client_get_characteristic(const void *buf, uint16_t len) goto done; } - if (cmd->number) + if (cmd->continuation) ch = queue_find(srvc->chars, match_char_by_higher_inst_id, - INT_TO_PTR(cmd->gatt_id[0].inst_id)); + INT_TO_PTR(cmd->char_id[0].inst_id)); else ch = queue_peek_head(srvc->chars); diff --git a/android/hal-gatt.c b/android/hal-gatt.c index b1ba97751..c5ea9da3b 100644 --- a/android/hal-gatt.c +++ b/android/hal-gatt.c @@ -731,12 +731,12 @@ static bt_status_t get_characteristic(int conn_id, btgatt_srvc_id_t *srvc_id, cmd->conn_id = conn_id; srvc_id_to_hal(&cmd->srvc_id, srvc_id); - cmd->number = 0; + cmd->continuation = 0; if (start_char_id) { - gatt_id_to_hal(&cmd->gatt_id[0], start_char_id); - len += sizeof(cmd->gatt_id[0]); - cmd->number = 1; + gatt_id_to_hal(&cmd->char_id[0], start_char_id); + len += sizeof(cmd->char_id[0]); + cmd->continuation = 1; } return hal_ipc_cmd(HAL_SERVICE_ID_GATT, diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt index 906cfc7c3..7a20f56e5 100644 --- a/android/hal-ipc-api.txt +++ b/android/hal-ipc-api.txt @@ -1543,9 +1543,8 @@ Commands and responses: Command parameters: Connection ID (4 octets) GATT Service ID (18 octets) - Number of GATT ID Elements (1 octet) - GATT ID # UUID (16 octets) - GATT ID # Instance ID (1 octet) + Continuation (1 octet) + GATT Characteristic ID (17 octets) ... Response parameters: @@ -1553,8 +1552,10 @@ Commands and responses: Instance ID (1 octet) Is Primary (1 octet) - Valid Number of GATT ID Elements: 0x00 - 0x01 + Valid GATT Characteristic ID: UUID (16 octets) + Instance ID (1 octet) + + GATT Characteristic ID shall only be present when Continuation is non-zero. In case of an error, the error response will be returned. diff --git a/android/hal-msg.h b/android/hal-msg.h index 7a4924474..9fec81bc7 100644 --- a/android/hal-msg.h +++ b/android/hal-msg.h @@ -630,8 +630,8 @@ struct hal_gatt_gatt_id { struct hal_cmd_gatt_client_get_characteristic { int32_t conn_id; struct hal_gatt_srvc_id srvc_id; - uint8_t number; - struct hal_gatt_gatt_id gatt_id[0]; + uint8_t continuation; + struct hal_gatt_gatt_id char_id[0]; } __attribute__((packed)); #define HAL_OP_GATT_CLIENT_GET_DESCRIPTOR 0x0b -- 2.47.3