2014-03-05 08:59:46

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 1/5] android/hal-gatt-api: Simplify GATT Test cmd struct

Make nested struct open coded for simplicity.
---
android/hal-ipc-api.txt | 15 +++++++--------
android/hal-msg.h | 8 ++------
2 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 6bf9af3..6fa0d3b 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1657,14 +1657,13 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
Opcode 0x16 - Test Command command/response

Command parameters: Command (4 octets)
- Test Parameters (32 octets)
- Valid Test Parameter: Address (6 octets)
- UUID (16 octets)
- U1 (2 octets)
- U2 (2 octets)
- U3 (2 octets)
- U4 (2 octets)
- U5 (2 octets)
+ Address (6 octets)
+ UUID (16 octets)
+ U1 (2 octets)
+ U2 (2 octets)
+ U3 (2 octets)
+ U4 (2 octets)
+ U5 (2 octets)
Response parameters: <none>

In case of an error, the error response will be returned.
diff --git a/android/hal-msg.h b/android/hal-msg.h
index dd25f6e..c3b1bc3 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -680,7 +680,8 @@ struct hal_cmd_gatt_client_set_adv_data {
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_TEST_COMMAND 0x16
-struct hal_gatt_test_params {
+struct hal_cmd_gatt_client_test_command {
+ int32_t command;
uint8_t bda1[6];
uint8_t uuid1[16];
uint16_t u1;
@@ -690,11 +691,6 @@ struct hal_gatt_test_params {
uint16_t u5;
} __attribute__((packed));

-struct hal_cmd_gatt_client_test_command {
- int32_t command;
- struct hal_gatt_test_params params;
-} __attribute__((packed));
-
#define HAL_OP_GATT_SERVER_REGISTER 0x17
struct hal_cmd_gatt_server_register {
uint8_t uuid[16];
--
1.9.0



2014-03-05 13:24:56

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH 1/5] android/hal-gatt-api: Simplify GATT Test cmd struct

Hi Jakub,

On Wednesday 05 of March 2014 09:59:46 Jakub Tyszkowski wrote:
> Make nested struct open coded for simplicity.
> ---
> android/hal-ipc-api.txt | 15 +++++++--------
> android/hal-msg.h | 8 ++------
> 2 files changed, 9 insertions(+), 14 deletions(-)
>
> diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
> index 6bf9af3..6fa0d3b 100644
> --- a/android/hal-ipc-api.txt
> +++ b/android/hal-ipc-api.txt
> @@ -1657,14 +1657,13 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
> Opcode 0x16 - Test Command command/response
>
> Command parameters: Command (4 octets)
> - Test Parameters (32 octets)
> - Valid Test Parameter: Address (6 octets)
> - UUID (16 octets)
> - U1 (2 octets)
> - U2 (2 octets)
> - U3 (2 octets)
> - U4 (2 octets)
> - U5 (2 octets)
> + Address (6 octets)
> + UUID (16 octets)
> + U1 (2 octets)
> + U2 (2 octets)
> + U3 (2 octets)
> + U4 (2 octets)
> + U5 (2 octets)
> Response parameters: <none>
>
> In case of an error, the error response will be returned.
> diff --git a/android/hal-msg.h b/android/hal-msg.h
> index dd25f6e..c3b1bc3 100644
> --- a/android/hal-msg.h
> +++ b/android/hal-msg.h
> @@ -680,7 +680,8 @@ struct hal_cmd_gatt_client_set_adv_data {
> } __attribute__((packed));
>
> #define HAL_OP_GATT_CLIENT_TEST_COMMAND 0x16
> -struct hal_gatt_test_params {
> +struct hal_cmd_gatt_client_test_command {
> + int32_t command;
> uint8_t bda1[6];
> uint8_t uuid1[16];
> uint16_t u1;
> @@ -690,11 +691,6 @@ struct hal_gatt_test_params {
> uint16_t u5;
> } __attribute__((packed));
>
> -struct hal_cmd_gatt_client_test_command {
> - int32_t command;
> - struct hal_gatt_test_params params;
> -} __attribute__((packed));
> -
> #define HAL_OP_GATT_SERVER_REGISTER 0x17
> struct hal_cmd_gatt_server_register {
> uint8_t uuid[16];
>

All patches applied, thanks.

--
Best regards,
Szymon Janc

2014-03-05 08:59:50

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 5/5] android/hal-gatt-api: Use proper type for length

Length can be up to 600 thus 16bit value should be used.
---
android/hal-msg.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 677f450..8ac26ab 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -781,7 +781,7 @@ struct hal_cmd_gatt_server_send_response {
int32_t conn_id;
int32_t trans_id;
int32_t status;
- uint8_t len;
+ uint16_t len;
uint8_t data[0];
} __attribute__((packed));

--
1.9.0


2014-03-05 08:59:49

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 4/5] android/hal-gatt-api: Simplify GATT Service ID struct

Make nested struct open coded for simplicity.
---
android/hal-ipc-api.txt | 19 +++++++++----------
android/hal-msg.h | 11 ++++++-----
2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 8d512dd..43b79ec 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1500,7 +1500,8 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
Service ID Elements (variable)
Valid Number of Service ID Elements: 0x01
0x02
- Valid Service ID Element: GATT ID (17 octets)
+ Valid Service ID Element: UUID (16 octets)
+ Instance ID (1 octet)
Is Primary (1 octet)
Valid GATT ID: UUID (16 octets)
Instance ID (1 octet)
@@ -1706,7 +1707,8 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
GATT Service ID (18 octets)
Number of Handles (4 octet)

- Valid GATT Service ID: GATT ID (17 octets)
+ Valid GATT Service ID: UUID (16 octets)
+ Instance ID (1 octets)
Is Primary (1 octet)

Valid GATT ID: UUID (16 octets)
@@ -1837,10 +1839,9 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)

Notification parameters: Connection ID (4 octets)
GATT Service ID (18 octets)
- Valid GATT Service ID: GATT ID (17 octets)
+ Valid GATT Service ID: UUID (16 octets)
+ Instance ID (1 octets)
Is Primary (1 octet)
- Valid GATT ID: UUID (16 octets)
- Instance ID (1 octet)

Opcode 0x87 - Get Characteristic notification

@@ -1969,15 +1970,13 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)

Notification parameters: Status (4 octets)
Server (4 octets)
- Service ID (18 octets)
+ GATT Service ID (18 octets)
Service Handle (4 octets)

- Valid Service ID: ID (17 octets)
+ Valid Service ID: UUID (16 octets)
+ Instance ID (1 octet)
Is Primary (1 octet)

- Valid ID: UUID (16 octets)
- Instance ID (1 octet)
-
Opcode 0x96 - Included Service Added notification

Notification patemeters: Status (4 octets)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 546172b..677f450 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -561,13 +561,9 @@ struct hal_cmd_gatt_client_search_service {
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_GET_INCLUDED_SERVICE 0x09
-struct hal_gatt_gatt_id {
+struct hal_gatt_srvc_id {
uint8_t uuid[16];
uint8_t inst_id;
-} __attribute__((packed));
-
-struct hal_gatt_srvc_id {
- struct hal_gatt_gatt_id gatt_id;
uint8_t is_primary;
} __attribute__((packed));

@@ -578,6 +574,11 @@ struct hal_cmd_gatt_client_get_included_service {
} __attribute__((packed));

#define HAL_OP_GATT_CLIENT_GET_CHARACTERISTIC 0x0a
+struct hal_gatt_gatt_id {
+ uint8_t uuid[16];
+ uint8_t inst_id;
+} __attribute__((packed));
+
struct hal_cmd_gatt_client_get_characteristic {
int32_t conn_id;
struct hal_gatt_srvc_id srvc_id;
--
1.9.0


2014-03-05 08:59:48

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 3/5] android/hal-gatt-api: Simplify GATT Read Char. event

Make nested struct open coded for simplicity.
---
android/hal-ipc-api.txt | 5 ++---
android/hal-msg.h | 8 ++------
2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index e88a85d..8d512dd 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1904,11 +1904,10 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
GATT Descr. ID (17 octets)
Value Type (4 octets)
Status (1 octet)
- Unformatted Value (variable)
+ Length (2 octets)
+ Value (variable)
Valid GATT Service ID: As described in Get Characteristic
Valid GATT Char. & Decr. ID: As described in Get Descriptor
- Valid Unformatted Value: Length (2 octets)
- Value (variable)

Opcode 0x8d - Write Characteristic notification

diff --git a/android/hal-msg.h b/android/hal-msg.h
index 5511297..546172b 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1316,18 +1316,14 @@ struct hal_ev_gatt_client_notify {
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_READ_CHARACTERISTIC 0x8c
-struct hal_gatt_unformated_value {
- uint16_t len;
- uint8_t value[0];
-} __attribute__((packed));
-
struct hal_gatt_read_params {
struct hal_gatt_srvc_id srvc_id;
struct hal_gatt_gatt_id char_id;
struct hal_gatt_gatt_id descr_id;
uint8_t status;
uint16_t value_type;
- struct hal_gatt_unformated_value value;
+ uint16_t len;
+ uint8_t value[0];
} __attribute__((packed));

struct hal_ev_gatt_client_read_characteristic {
--
1.9.0


2014-03-05 08:59:47

by Jakub Tyszkowski

[permalink] [raw]
Subject: [PATCH 2/5] android/hal-gatt-api: Simplify GATT Notify ev struct

Make nested struct open coded for simplicity.
---
android/hal-ipc-api.txt | 3 +--
android/hal-msg.h | 8 ++------
2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/android/hal-ipc-api.txt b/android/hal-ipc-api.txt
index 6fa0d3b..e88a85d 100644
--- a/android/hal-ipc-api.txt
+++ b/android/hal-ipc-api.txt
@@ -1885,8 +1885,7 @@ Android HAL name: "gatt" (BT_PROFILE_GATT_ID)
Opcode 0x8b - Notify notification

Notification parameters: Connection ID (4 octets)
- Notify Parameters (variable)
- Valid Notify Parameters: Address (6 octets)
+ Address (6 octets)
GATT Service ID (18 octets)
GATT Char. ID (17 octets)
Is Notify (1 octet)
diff --git a/android/hal-msg.h b/android/hal-msg.h
index c3b1bc3..5511297 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -1305,7 +1305,8 @@ struct hal_ev_gatt_client_reg_for_notif {
} __attribute__((packed));

#define HAL_EV_GATT_CLIENT_NOTIFY 0x8b
-struct hal_gatt_notify_params {
+struct hal_ev_gatt_client_notify {
+ int32_t conn_id;
uint8_t bda[6];
struct hal_gatt_srvc_id srvc_id;
struct hal_gatt_gatt_id char_id;
@@ -1314,11 +1315,6 @@ struct hal_gatt_notify_params {
uint8_t value[0];
} __attribute__((packed));

-struct hal_ev_gatt_client_notify {
- int32_t conn_id;
- struct hal_gatt_notify_params data;
-} __attribute__((packed));
-
#define HAL_EV_GATT_CLIENT_READ_CHARACTERISTIC 0x8c
struct hal_gatt_unformated_value {
uint16_t len;
--
1.9.0