Hi,
Here are few patches to make GATT IPC messages structure better
describe its actual content, especially in cases where message has
some optional data which until now were identified by 'number' field.
Such name is misleading since in all cases there could be only one
optional parameter thus messages are updated to have boolean-like
field and properly named optional parameter.
This should make code easier to read as field names in structures
now have consistent names which describe its conents clearly.
Andrzej Kaczmarek (8):
android/hal-gatt-api: Fix IPC definition for service_search
android/hal-gatt-api: Fix IPC definition for get_included_service
android/hal-gatt-api: Fix IPC definition for get_characteristic
android/hal-gatt-api: Fix IPC definition for get_descriptor
android/hal-gatt-api: Fix IPC definition for read_characteristic
android/hal-gatt-api: Fix IPC definition for write_characteristic
android/gatt: Add IPC message verification for service_search
android/ipc: Add common definitions for GATT IPC structures
android/gatt.c | 44 +++++++-----
android/hal-gatt.c | 37 +++++-----
android/hal-ipc-api.txt | 175 +++++++++++++-----------------------------------
android/hal-msg.h | 20 +++---
4 files changed, 100 insertions(+), 176 deletions(-)
--
1.9.2
Hi Andrzej,
On Thursday 17 of April 2014 01:10:25 Andrzej Kaczmarek wrote:
> Hi,
>
> Here are few patches to make GATT IPC messages structure better
> describe its actual content, especially in cases where message has
> some optional data which until now were identified by 'number' field.
> Such name is misleading since in all cases there could be only one
> optional parameter thus messages are updated to have boolean-like
> field and properly named optional parameter.
>
> This should make code easier to read as field names in structures
> now have consistent names which describe its conents clearly.
>
>
> Andrzej Kaczmarek (8):
> android/hal-gatt-api: Fix IPC definition for service_search
> android/hal-gatt-api: Fix IPC definition for get_included_service
> android/hal-gatt-api: Fix IPC definition for get_characteristic
> android/hal-gatt-api: Fix IPC definition for get_descriptor
> android/hal-gatt-api: Fix IPC definition for read_characteristic
> android/hal-gatt-api: Fix IPC definition for write_characteristic
> android/gatt: Add IPC message verification for service_search
> android/ipc: Add common definitions for GATT IPC structures
>
> android/gatt.c | 44 +++++++-----
> android/hal-gatt.c | 37 +++++-----
> android/hal-ipc-api.txt | 175 +++++++++++++-----------------------------------
> android/hal-msg.h | 20 +++---
> 4 files changed, 100 insertions(+), 176 deletions(-)
>
Applied, thanks.
--
Best regards,
Szymon Janc
---
android/gatt.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/android/gatt.c b/android/gatt.c
index aa258f1..e339789 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1458,6 +1458,13 @@ static void handle_client_search_service(const void *buf, uint16_t len)
DBG("");
+ if (len != sizeof(*cmd) + (cmd->filtered ? 16 : 0)) {
+ error("Invalid search service size (%u bytes), terminating",
+ len);
+ raise(SIGTERM);
+ return;
+ }
+
dev = find_device_by_conn_id(cmd->conn_id);
if (!dev) {
error("gatt: dev with conn_id=%d not found", cmd->conn_id);
--
1.9.2
---
android/gatt.c | 6 +++---
android/hal-gatt.c | 2 +-
android/hal-msg.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index f9ba870..878df0e 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -2162,7 +2162,7 @@ static void handle_client_read_characteristic(const void *buf, uint16_t len)
/* TODO authorization needs to be handled */
hal_srvc_id_to_element_id(&cmd->srvc_id, &srvc_id);
- hal_gatt_id_to_element_id(&cmd->gatt_id, &char_id);
+ hal_gatt_id_to_element_id(&cmd->char_id, &char_id);
if (!find_service(cmd->conn_id, &srvc_id, &dev, &srvc)) {
status = HAL_STATUS_FAILED;
@@ -2173,7 +2173,7 @@ static void handle_client_read_characteristic(const void *buf, uint16_t len)
ch = queue_find(srvc->chars, match_char_by_element_id, &char_id);
if (!ch) {
error("gatt: Characteristic with inst_id: %d not found",
- cmd->gatt_id.inst_id);
+ cmd->char_id.inst_id);
status = HAL_STATUS_FAILED;
goto failed;
}
@@ -2189,7 +2189,7 @@ static void handle_client_read_characteristic(const void *buf, uint16_t len)
if (!gatt_read_char(dev->attrib, ch->ch.value_handle,
read_char_cb, cb_data)) {
error("gatt: Cannot read characteristic with inst_id: %d",
- cmd->gatt_id.inst_id);
+ cmd->char_id.inst_id);
status = HAL_STATUS_FAILED;
free(cb_data);
goto failed;
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index bcbeb54..e805a82 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -785,7 +785,7 @@ static bt_status_t read_characteristic(int conn_id, btgatt_srvc_id_t *srvc_id,
cmd.auth_req = auth_req;
srvc_id_to_hal(&cmd.srvc_id, srvc_id);
- gatt_id_to_hal(&cmd.gatt_id, char_id);
+ gatt_id_to_hal(&cmd.char_id, char_id);
return hal_ipc_cmd(HAL_SERVICE_ID_GATT,
HAL_OP_GATT_CLIENT_READ_CHARACTERISTIC,
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 6b4b2f5..4974a51 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -647,7 +647,7 @@ struct hal_cmd_gatt_client_get_descriptor {
struct hal_cmd_gatt_client_read_characteristic {
int32_t conn_id;
struct hal_gatt_srvc_id srvc_id;
- struct hal_gatt_gatt_id gatt_id;
+ struct hal_gatt_gatt_id char_id;
int32_t auth_req;
} __attribute__((packed));
--
1.9.2
---
android/gatt.c | 9 +++++----
android/hal-gatt.c | 11 +++++------
android/hal-ipc-api.txt | 18 ++++++++++++------
android/hal-msg.h | 5 +++--
4 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index f52cb36..a4a1048 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1647,14 +1647,15 @@ static void handle_client_get_included_service(const void *buf, uint16_t len)
DBG("");
- if (len != sizeof(*cmd) + (cmd->number * sizeof(cmd->srvc_id[0]))) {
+ if (len != sizeof(*cmd) +
+ (cmd->continuation ? sizeof(cmd->incl_srvc_id[0]) : 0)) {
error("Invalid get incl services size (%u bytes), terminating",
len);
raise(SIGTERM);
return;
}
- hal_srvc_id_to_element_id(&cmd->srvc_id[0], &match_id);
+ hal_srvc_id_to_element_id(&cmd->srvc_id, &match_id);
if (!find_service(cmd->conn_id, &match_id, &device, &prim_service)) {
status = HAL_STATUS_FAILED;
goto reply;
@@ -1670,10 +1671,10 @@ static void handle_client_get_included_service(const void *buf, uint16_t len)
}
/* Try to use cache here */
- if (cmd->number == 1) {
+ if (!cmd->continuation) {
incl_service = queue_peek_head(prim_service->included);
} else {
- uint8_t inst_id = cmd->srvc_id[1].inst_id;
+ uint8_t inst_id = cmd->incl_srvc_id[0].inst_id;
incl_service = queue_find(prim_service->included,
match_srvc_by_higher_inst_id,
INT_TO_PTR(inst_id));
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index 0229fc8..b1ba977 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -704,14 +704,13 @@ static bt_status_t get_included_service(int conn_id, btgatt_srvc_id_t *srvc_id,
cmd->conn_id = conn_id;
- srvc_id_to_hal(&cmd->srvc_id[0], srvc_id);
- len += sizeof(cmd->srvc_id[0]);
- cmd->number = 1;
+ srvc_id_to_hal(&cmd->srvc_id, srvc_id);
+ cmd->continuation = 0;
if (start_incl_srvc_id) {
- srvc_id_to_hal(&cmd->srvc_id[1], start_incl_srvc_id);
- len += sizeof(cmd->srvc_id[1]);
- cmd->number++;
+ srvc_id_to_hal(&cmd->incl_srvc_id[0], start_incl_srvc_id);
+ len += sizeof(cmd->incl_srvc_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 67da4ec..906cfc7 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1521,15 +1521,21 @@ Commands and responses:
Opcode 0x09 - Get Included Service command/response
Command parameters: Connection ID (4 octets)
- Number of GATT Service ID Elements (1 octet)
- GATT Service ID # UUID (16 octets)
- GATT Service ID # Instance ID (1 octet)
- GATT Service ID # Is Primary (1 octet)
+ GATT Service ID (18 octets)
+ Continuation (1 octet)
+ GATT Included Service ID (18 octets)
...
Response parameters: <none>
- Valid Number of GATT Service ID Elements: 0x01
- 0x02
+ Valid GATT Service ID: UUID (16 octets)
+ Instance ID (1 octet)
+ Is Primary (1 octet)
+
+ Valid GATT Included Service ID: UUID (16 octets)
+ Instance ID (1 octet)
+ Is Primary (1 octet)
+
+ GATT Included Service 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 caf6ad9..7a49244 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -616,8 +616,9 @@ struct hal_gatt_srvc_id {
struct hal_cmd_gatt_client_get_included_service {
int32_t conn_id;
- uint8_t number;
- struct hal_gatt_srvc_id srvc_id[0];
+ struct hal_gatt_srvc_id srvc_id;
+ uint8_t continuation;
+ struct hal_gatt_srvc_id incl_srvc_id[0];
} __attribute__((packed));
#define HAL_OP_GATT_CLIENT_GET_CHARACTERISTIC 0x0a
--
1.9.2
---
android/hal-gatt.c | 2 +-
android/hal-ipc-api.txt | 8 +++-----
android/hal-msg.h | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index 6fde143..0229fc8 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -684,7 +684,7 @@ static bt_status_t search_service(int conn_id, bt_uuid_t *filter_uuid)
if (filter_uuid) {
memcpy(cmd->filter_uuid, filter_uuid, sizeof(*filter_uuid));
len += sizeof(*filter_uuid);
- cmd->number = 1;
+ cmd->filtered = 1;
}
return hal_ipc_cmd(HAL_SERVICE_ID_GATT,
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index a56474c..67da4ec 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1510,13 +1510,11 @@ Commands and responses:
Opcode 0x08 - Search Service command/response
Command parameters: Connection ID (4 octets)
- Number of UUID Filters (1 octet)
- UUID Filter # (16 octets)
- ...
+ Filtered (1 octet)
+ Filter UUID (16 octets)
Response parameters: <none>
- Valid Number of UUID Filters: 0x00
- 0x01
+ Filter UUID shall only be present when Filtered 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 ca36b59..caf6ad9 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -603,7 +603,7 @@ struct hal_cmd_gatt_client_refresh {
#define HAL_OP_GATT_CLIENT_SEARCH_SERVICE 0x08
struct hal_cmd_gatt_client_search_service {
int32_t conn_id;
- uint8_t number;
+ uint8_t filtered;
uint8_t filter_uuid[0];
} __attribute__((packed));
--
1.9.2
---
android/gatt.c | 6 +++---
android/hal-gatt.c | 2 +-
android/hal-msg.h | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index 878df0e..aa258f1 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -2262,7 +2262,7 @@ static void handle_client_write_characteristic(const void *buf, uint16_t len)
}
hal_srvc_id_to_element_id(&cmd->srvc_id, &srvc_id);
- hal_gatt_id_to_element_id(&cmd->gatt_id, &char_id);
+ hal_gatt_id_to_element_id(&cmd->char_id, &char_id);
if (!find_service(cmd->conn_id, &srvc_id, &dev, &srvc)) {
status = HAL_STATUS_FAILED;
@@ -2273,7 +2273,7 @@ static void handle_client_write_characteristic(const void *buf, uint16_t len)
ch = queue_find(srvc->chars, match_char_by_element_id, &char_id);
if (!ch) {
error("gatt: Characteristic with inst_id: %d not found",
- cmd->gatt_id.inst_id);
+ cmd->char_id.inst_id);
status = HAL_STATUS_FAILED;
goto failed;
}
@@ -2300,7 +2300,7 @@ static void handle_client_write_characteristic(const void *buf, uint16_t len)
if (!res) {
error("gatt: Cannot write char. with inst_id: %d",
- cmd->gatt_id.inst_id);
+ cmd->char_id.inst_id);
status = HAL_STATUS_FAILED;
goto failed;
}
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index e805a82..3bbae2b 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -810,7 +810,7 @@ static bt_status_t write_characteristic(int conn_id, btgatt_srvc_id_t *srvc_id,
cmd->auth_req = auth_req;
srvc_id_to_hal(&cmd->srvc_id, srvc_id);
- gatt_id_to_hal(&cmd->gatt_id, char_id);
+ gatt_id_to_hal(&cmd->char_id, char_id);
memcpy(cmd->value, p_value, len);
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 4974a51..ed0a67a 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -660,7 +660,7 @@ struct hal_cmd_gatt_client_read_characteristic {
struct hal_cmd_gatt_client_write_characteristic {
int32_t conn_id;
struct hal_gatt_srvc_id srvc_id;
- struct hal_gatt_gatt_id gatt_id;
+ struct hal_gatt_gatt_id char_id;
int32_t write_type;
int32_t len;
int32_t auth_req;
--
1.9.2
---
android/gatt.c | 10 +++++-----
android/hal-gatt.c | 12 +++++-------
android/hal-ipc-api.txt | 15 ++++++++++-----
android/hal-msg.h | 5 +++--
4 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/android/gatt.c b/android/gatt.c
index 9d0b2a2..f9ba870 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -2017,8 +2017,8 @@ static void handle_client_get_descriptor(const void *buf, uint16_t len)
DBG("");
- if ((len != sizeof(*cmd) + cmd->number * sizeof(cmd->gatt_id[0])) ||
- (cmd->number != 1 && cmd->number != 2)) {
+ if (len != sizeof(*cmd) +
+ (cmd->continuation ? sizeof(cmd->descr_id[0]) : 0)) {
error("gatt: Invalid get descr command (%u bytes), terminating",
len);
@@ -2030,7 +2030,7 @@ static void handle_client_get_descriptor(const void *buf, uint16_t len)
primary = cmd->srvc_id.is_primary;
hal_srvc_id_to_element_id(&cmd->srvc_id, &srvc_id);
- hal_gatt_id_to_element_id(&cmd->gatt_id[0], &char_id);
+ hal_gatt_id_to_element_id(&cmd->char_id, &char_id);
if (!find_service(conn_id, &srvc_id, &dev, &srvc)) {
error("gatt: Get descr. could not find service");
@@ -2059,10 +2059,10 @@ static void handle_client_get_descriptor(const void *buf, uint16_t len)
status = HAL_STATUS_SUCCESS;
/* Send from cache */
- if (cmd->number > 1)
+ if (cmd->continuation)
descr = queue_find(ch->descriptors,
match_descr_by_higher_inst_id,
- INT_TO_PTR(cmd->gatt_id[1].inst_id));
+ INT_TO_PTR(cmd->descr_id[0].inst_id));
else
descr = queue_peek_head(ch->descriptors);
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index c5ea9da..bcbeb54 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -758,15 +758,13 @@ static bt_status_t get_descriptor(int conn_id, btgatt_srvc_id_t *srvc_id,
cmd->conn_id = conn_id;
srvc_id_to_hal(&cmd->srvc_id, srvc_id);
-
- gatt_id_to_hal(&cmd->gatt_id[0], char_id);
- len += sizeof(cmd->gatt_id[0]);
- cmd->number = 1;
+ gatt_id_to_hal(&cmd->char_id, char_id);
+ cmd->continuation = 0;
if (start_descr_id) {
- gatt_id_to_hal(&cmd->gatt_id[1], start_descr_id);
- len += sizeof(cmd->gatt_id[1]);
- cmd->number++;
+ gatt_id_to_hal(&cmd->descr_id[0], start_descr_id);
+ len += sizeof(cmd->descr_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 7a20f56..fa6552e 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1563,9 +1563,9 @@ 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)
+ GATT Characteristic ID (17 octets)
+ Continuation (1 octet)
+ GATT Descriptor ID (17 octets)
...
Response parameters: <none>
@@ -1573,8 +1573,13 @@ Commands and responses:
Instance ID (1 octet)
Is Primary (1 octet)
- Valid Number of GATT ID Elements: 0x01
- 0x02
+ Valid GATT Characteristic ID: UUID (16 octets)
+ Instance ID (1 octet)
+
+ Valid GATT Descriptor ID: UUID (16 octets)
+ Instance ID (1 octet)
+
+ GATT Descriptor 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 9fec81b..6b4b2f5 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -638,8 +638,9 @@ struct hal_cmd_gatt_client_get_characteristic {
struct hal_cmd_gatt_client_get_descriptor {
int32_t conn_id;
struct hal_gatt_srvc_id srvc_id;
- uint8_t number;
- struct hal_gatt_gatt_id gatt_id[0];
+ struct hal_gatt_gatt_id char_id;
+ uint8_t continuation;
+ struct hal_gatt_gatt_id descr_id[0];
} __attribute__((packed));
#define HAL_OP_GATT_CLIENT_READ_CHARACTERISTIC 0x0c
--
1.9.2
Since GATT IPC uses common structures for services, characteristics and
descriptors in many messages there's no need to describe each structure
in each call separately. They can be replaced with common definition.
---
android/hal-ipc-api.txt | 157 ++++++++++--------------------------------------
1 file changed, 32 insertions(+), 125 deletions(-)
diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index fa6552e..1e519cd 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1434,6 +1434,22 @@ Bluetooth GATT HAL (ID 9)
Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
+Structures:
+
+ GATT Service ID: UUID (16 octets)
+ Instance ID (1 octet)
+ Is Primary (1 octet)
+
+ GATT Included Service ID: UUID (16 octets)
+ Instance ID (1 octet)
+ Is Primary (1 octet)
+
+ GATT Characteristic ID: UUID (16 octets)
+ Instance ID (1 octet)
+
+ GATT Descriptor ID: UUID (16 octets)
+ Instance ID (1 octet)
+
Commands and responses:
Opcode 0x00 - Error response
@@ -1527,14 +1543,6 @@ Commands and responses:
...
Response parameters: <none>
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
- Valid GATT Included Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
GATT Included Service ID shall only be present when Continuation is non-zero.
In case of an error, the error response will be returned.
@@ -1548,13 +1556,6 @@ Commands and responses:
...
Response parameters: <none>
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
- 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.
@@ -1569,16 +1570,6 @@ Commands and responses:
...
Response parameters: <none>
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
- Valid GATT Characteristic ID: UUID (16 octets)
- Instance ID (1 octet)
-
- Valid GATT Descriptor ID: UUID (16 octets)
- Instance ID (1 octet)
-
GATT Descriptor ID shall only be present when Continuation is non-zero.
In case of an error, the error response will be returned.
@@ -1587,37 +1578,23 @@ Commands and responses:
Command parameters: Connection ID (4 octets)
GATT Service ID (18 octets)
- GATT ID (17 octets)
+ GATT Characteristic ID (17 octets)
Authorization (4 octets)
Response parameters: <none>
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
- Valid GATT ID: UUID (16 octets)
- Instance ID (1 octet)
-
In case of an error, the error response will be returned.
Opcode 0x0d - Write Characteristic command/response
Command parameters: Connection ID (4 octets)
GATT Service ID (18 octets)
- GATT ID (17 octets)
+ GATT Characteristic ID (17 octets)
Write Type (4 octets)
Length (4 octets)
Authorization Req. (4 octets)
Value (variable)
Response parameters: <none>
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
- Valid GATT ID: UUID (16 octets)
- Instance ID (1 octet)
-
Valid Write Type: 0x01 = No response
0x02 = Default
0x03 = Prepare
@@ -1629,45 +1606,25 @@ Commands and responses:
Command parameters: Connection ID (4 octets)
GATT Service ID (18 octets)
- GATT ID (17 octets)
- Descr. GATT ID (17 octets)
+ GATT Characteristic ID (17 octets)
+ GATT Descriptor ID (17 octets)
Authorization Req. (4 octets)
Response parameters: <none>
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
- Valid GATT ID: UUID (16 octets)
- Instance ID (1 octet)
-
- Valid Descr. GATT ID: UUID (16 octets)
- Instance ID (1 octet)
-
In case of an error, the error response will be returned.
Opcode 0x0f - Write Descriptor command/response
Command parameters: Connection ID (4 octets)
GATT Service ID (18 octets)
- GATT ID (17 octets)
- Descr. GATT ID (17 octets)
+ GATT Characteristic ID (17 octets)
+ GATT Descriptor ID (17 octets)
Write Type (4 octets)
Length (4 octets)
Authorization Req. (4 octets)
Value (variable)
Response parameters: <none>
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
- Valid GATT ID: UUID (16 octets)
- Instance ID (1 octet)
-
- Valid Descr. GATT ID: UUID (16 octets)
- Instance ID (1 octet)
-
Valid Write Type: 0x01 = No response
0x02 = Default
0x03 = Prepare
@@ -1688,16 +1645,9 @@ Commands and responses:
Command parameters: Client Interface (4 octets)
Remote address (6 octets)
GATT Service ID (18 octets)
- GATT ID (17 octets)
+ GATT Characteristic ID (17 octets)
Response parameters: <none>
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
- Valid GATT ID: UUID (16 octets)
- Instance ID (1 octet)
-
In case of an error, the error response will be returned.
Opcode 0x12 - Deregister For Notification command/response
@@ -1705,16 +1655,9 @@ Commands and responses:
Command parameters: Client Interface (4 octets)
Remote address (6 octets)
GATT Service ID (18 octets)
- GATT ID (17 octets)
+ GATT Characteristic ID (17 octets)
Response parameters: <none>
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
- Valid GATT ID: UUID (16 octets)
- Instance ID (1 octet)
-
In case of an error, the error response will be returned.
Opcode 0x13 - Read Remote RSSI command/response
@@ -1935,44 +1878,28 @@ Notifications:
Notification parameters: Connection ID (4 octets)
GATT Service ID (18 octets)
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octets)
- Is Primary (1 octet)
-
Opcode 0x87 - Get Characteristic notification
Notification parameters: Connection ID (4 octets)
Status (4 octets)
GATT Service ID (18 octets)
- GATT Char. ID (17 octets)
+ GATT Characteristic ID (17 octets)
Char Prop. (4 octets)
- Valid GATT Service: As described in Search Result
-
- Valid GATT Char. ID: UUID (16 octets)
- Instance ID (1 octet)
-
Opcode 0x88 - Get Descriptor notification
Notification parameters: Connection ID (4 octets)
Status (4 octets)
GATT Service ID (18 octets)
- GATT Char. ID (17 octets)
- GATT Descr. ID (17 octets)
-
- Valid GATT Service & Char. ID: As described in Get Characteristic
-
- Valid GATT Descr. ID: UUID (16 octets)
- Instance ID (1 octet)
+ GATT Characteristic ID (17 octets)
+ GATT Descriptor ID (17 octets)
Opcode 0x89 - Get Included Service notification
Notification parameters: Connection ID (4 octets)
Status (4 octets)
GATT Service ID (18 octets)
- GATT Incl. Service ID (18 octets)
-
- Valid GATT Service & Incl. Service ID: As described in Search Result
+ GATT Included Service ID (18 octets)
Opcode 0x8a - Register For Notification notification
@@ -1980,26 +1907,18 @@ Notifications:
Registered (4 octets)
Status (4 octets)
GATT Service ID (18 octets)
- GATT Char. ID (17 octets)
-
- Valid GATT Service ID: As described in Get Characteristic
-
- Valid GATT Char. ID: As described in Get Characteristic
+ GATT Characteristic ID (17 octets)
Opcode 0x8b - Notify notification
Notification parameters: Connection ID (4 octets)
Address (6 octets)
GATT Service ID (18 octets)
- GATT Char. ID (17 octets)
+ GATT Characteristic ID (17 octets)
Is Notify (1 octet)
Length (2 octets)
Value (variable)
- Valid GATT Service ID: As described in Get Characteristic
-
- Valid GATT Char. ID: As described in Get Characteristic
-
Opcode 0x8c - Read Characteristic notification
Notification parameters: Connection ID (4 octets)
@@ -2007,17 +1926,13 @@ Notifications:
GATT Read Parameters (variable)
Valid GATT Read Parameters: GATT Service ID (18 octets)
- GATT Char. ID (17 octets)
- GATT Descr. ID (17 octets)
+ GATT Characteristic ID (17 octets)
+ GATT Descriptor ID (17 octets)
Value Type (4 octets)
Status (1 octet)
Length (2 octets)
Value (variable)
- Valid GATT Service ID: As described in Get Characteristic
-
- Valid GATT Char. & Decr. ID: As described in Get Descriptor
-
Opcode 0x8d - Write Characteristic notification
Notification parameters: Connection ID (4 octets)
@@ -2029,10 +1944,6 @@ Notifications:
GATT Description ID (17 octets)
Status (1 octet)
- Valid GATT Service ID: As described in Get Descriptor
-
- Valid GATT Char. & Decr. ID: As described in Get Descriptor
-
Opcode 0x8e - Read Descriptor notification
Notification parameters: Connection ID (4 octets)
@@ -2086,10 +1997,6 @@ Notifications:
GATT Service ID (18 octets)
Service Handle (4 octets)
- Valid GATT Service ID: UUID (16 octets)
- Instance ID (1 octet)
- Is Primary (1 octet)
-
Opcode 0x96 - Included Service Added notification
Notification patemeters: Status (4 octets)
--
1.9.2
---
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 a4a1048..9d0b2a2 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 b1ba977..c5ea9da 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 906cfc7..7a20f56 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: <none>
@@ -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 7a49244..9fec81b 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
--
1.9.2