summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Skamra <mariusz.skamra@tieto.com>2016-02-24 15:16:28 +0100
committerMariusz Skamra <mariusz.skamra@tieto.com>2016-03-02 11:38:00 +0100
commit0abe6e85ba7766581cd1a78feec6c4b8eb44252c (patch)
treeacb7bb206b3247238e9946d3289904b810c3df48
parentb1fd0c6a2ce6e1bc6e327bcde574003fd0bb6e51 (diff)
Bluetooth: btp: Fix BTP GATT command opcodes
This patch makes opcodes to be in the sequence. Supported commmands is form now uint8_t array, so this resolves the problem with endianess as well. Change-Id: I602a58081948dbbf5e0d83cbb12a118a5990b9f8 Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
-rw-r--r--tests/bluetooth/tester/btp_spec.txt42
-rw-r--r--tests/bluetooth/tester/src/bttester.c1
-rw-r--r--tests/bluetooth/tester/src/bttester.h43
-rw-r--r--tests/bluetooth/tester/src/gap.c1
-rw-r--r--tests/bluetooth/tester/src/gatt.c50
5 files changed, 70 insertions, 67 deletions
diff --git a/tests/bluetooth/tester/btp_spec.txt b/tests/bluetooth/tester/btp_spec.txt
index 67a4af9c8..f838d60eb 100644
--- a/tests/bluetooth/tester/btp_spec.txt
+++ b/tests/bluetooth/tester/btp_spec.txt
@@ -665,9 +665,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x0a -> 0x3f - Reserved for future use
-
- Opcode 0x40 - Exchange MTU
+ Opcode 0x0a - Exchange MTU
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -680,7 +678,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x41 - Discover All Primary Services
+ Opcode 0x0b - Discover All Primary Services
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -704,7 +702,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x42 - Discover Primary Service by UUID
+ Opcode 0x0c - Discover Primary Service by UUID
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -730,7 +728,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x43 - Find Included Services
+ Opcode 0x0d - Find Included Services
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -763,7 +761,7 @@ Commands and responses:
relationships to other services.
Services found during discovery are returned in the response.
- Opcode 0x44 - Discover All Characteristics of a Service
+ Opcode 0x0e - Discover All Characteristics of a Service
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -791,7 +789,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x45 - Discover Characteristics by UUID
+ Opcode 0x0f - Discover Characteristics by UUID
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -821,7 +819,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x46 - Discover All Characteristic Descriptors
+ Opcode 0x10 - Discover All Characteristic Descriptors
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -847,7 +845,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x47 - Read Characteristic Value/Descriptor
+ Opcode 0x11 - Read Characteristic Value/Descriptor
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -866,7 +864,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x48 - Read Using Characteristic UUID
+ Opcode 0x12 - Read Using Characteristic UUID
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -892,7 +890,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x49 - Read Long Characteristic Value/Descriptor
+ Opcode 0x13 - Read Long Characteristic Value/Descriptor
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -912,7 +910,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x4a - Read Multiple Characteristic Values
+ Opcode 0x14 - Read Multiple Characteristic Values
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -932,7 +930,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x4b - Write Without Response
+ Opcode 0x15 - Write Without Response
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -948,7 +946,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x4c - Signed Write Without Response
+ Opcode 0x16 - Signed Write Without Response
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -966,7 +964,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x4d - Write Characteristic Value/Descriptor
+ Opcode 0x17 - Write Characteristic Value/Descriptor
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -984,7 +982,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x4e - Write Long Characteristic Value/Descriptor
+ Opcode 0x18 - Write Long Characteristic Value/Descriptor
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -1003,7 +1001,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x4f - Reliable Write
+ Opcode 0x19 - Reliable Write
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -1023,7 +1021,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x50 - Configure Notifications
+ Opcode 0x1a - Configure Notifications
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -1037,7 +1035,7 @@ Commands and responses:
In case of an error, the error response will be returned.
- Opcode 0x51 - Configure Indications
+ Opcode 0x1b - Configure Indications
Controller Index: <controller id>
Command parameters: Address_Type (1 octet)
@@ -1052,9 +1050,7 @@ Commands and responses:
In case of an error, the error response will be returned.
Events:
- Opcode 0x80 -> 0xbf - Reserved for future use
-
- Opcode 0xc0 - Notification/Indication Received
+ Opcode 0x80 - Notification/Indication Received
Controller Index: <controller id>
Event parameters: Address_Type (1 octet)
diff --git a/tests/bluetooth/tester/src/bttester.c b/tests/bluetooth/tester/src/bttester.c
index 0fdf88d83..847ac1784 100644
--- a/tests/bluetooth/tester/src/bttester.c
+++ b/tests/bluetooth/tester/src/bttester.c
@@ -25,7 +25,6 @@
#include <bluetooth/bluetooth.h>
#include <misc/printk.h>
#include <misc/byteorder.h>
-#include <misc/util.h>
#include <console/uart_pipe.h>
#include "bttester.h"
diff --git a/tests/bluetooth/tester/src/bttester.h b/tests/bluetooth/tester/src/bttester.h
index 89815b9a3..778c05f95 100644
--- a/tests/bluetooth/tester/src/bttester.h
+++ b/tests/bluetooth/tester/src/bttester.h
@@ -16,6 +16,8 @@
* limitations under the License.
*/
+#include <misc/util.h>
+
#define BTP_MTU 1024
#define BTP_INDEX_NONE 0xff
@@ -343,8 +345,6 @@ struct gatt_set_enc_key_size_cmd {
} __packed;
/* Gatt Client */
-#define GATT_CLIENT_OP_OFFSET 0x40
-
struct gatt_service {
uint16_t start_handle;
uint16_t end_handle;
@@ -371,9 +371,9 @@ struct gatt_descriptor {
uint8_t uuid[0];
} __packed;
-#define GATT_EXCHANGE_MTU 0x40
+#define GATT_EXCHANGE_MTU 0x0a
-#define GATT_DISC_PRIM_UUID 0x42
+#define GATT_DISC_PRIM_UUID 0x0c
struct gatt_disc_prim_uuid_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -385,7 +385,7 @@ struct gatt_disc_prim_uuid_rp {
struct gatt_service services[0];
} __packed;
-#define GATT_FIND_INCLUDED 0x43
+#define GATT_FIND_INCLUDED 0x0d
struct gatt_find_included_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -397,7 +397,7 @@ struct gatt_find_included_rp {
struct gatt_included included[0];
} __packed;
-#define GATT_DISC_ALL_CHRC 0x44
+#define GATT_DISC_ALL_CHRC 0x0e
struct gatt_disc_all_chrc_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -409,7 +409,7 @@ struct gatt_disc_chrc_rp {
struct gatt_characteristic characteristics[0];
} __packed;
-#define GATT_DISC_CHRC_UUID 0x45
+#define GATT_DISC_CHRC_UUID 0x0f
struct gatt_disc_chrc_uuid_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -419,7 +419,7 @@ struct gatt_disc_chrc_uuid_cmd {
uint8_t uuid[0];
} __packed;
-#define GATT_DISC_ALL_DESC 0x46
+#define GATT_DISC_ALL_DESC 0x10
struct gatt_disc_all_desc_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -431,7 +431,7 @@ struct gatt_disc_all_desc_rp {
struct gatt_descriptor descriptors[0];
} __packed;
-#define GATT_READ 0x47
+#define GATT_READ 0x11
struct gatt_read_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -443,7 +443,7 @@ struct gatt_read_rp {
uint8_t data[0];
} __packed;
-#define GATT_READ_LONG 0x49
+#define GATT_READ_LONG 0x13
struct gatt_read_long_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -451,7 +451,7 @@ struct gatt_read_long_cmd {
uint16_t offset;
} __packed;
-#define GATT_READ_MULTIPLE 0x4a
+#define GATT_READ_MULTIPLE 0x14
struct gatt_read_multiple_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -459,7 +459,7 @@ struct gatt_read_multiple_cmd {
uint16_t handles[0];
} __packed;
-#define GATT_WRITE_WITHOUT_RSP 0x4b
+#define GATT_WRITE_WITHOUT_RSP 0x15
struct gatt_write_without_rsp_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -468,7 +468,7 @@ struct gatt_write_without_rsp_cmd {
uint8_t data[0];
} __packed;
-#define GATT_SIGNED_WRITE_WITHOUT_RSP 0x4c
+#define GATT_SIGNED_WRITE_WITHOUT_RSP 0x16
struct gatt_signed_write_without_rsp_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -477,7 +477,7 @@ struct gatt_signed_write_without_rsp_cmd {
uint8_t data[0];
} __packed;
-#define GATT_WRITE 0x4d
+#define GATT_WRITE 0x17
struct gatt_write_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -486,7 +486,7 @@ struct gatt_write_cmd {
uint8_t data[0];
} __packed;
-#define GATT_WRITE_LONG 0x4e
+#define GATT_WRITE_LONG 0x18
struct gatt_write_long_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -496,8 +496,8 @@ struct gatt_write_long_cmd {
uint8_t data[0];
} __packed;
-#define GATT_CFG_NOTIFY 0x50
-#define GATT_CFG_INDICATE 0x51
+#define GATT_CFG_NOTIFY 0x1a
+#define GATT_CFG_INDICATE 0x1b
struct gatt_cfg_notify_cmd {
uint8_t address_type;
uint8_t address[6];
@@ -506,7 +506,7 @@ struct gatt_cfg_notify_cmd {
} __packed;
/* GATT events */
-#define GATT_EV_NOTIFICATION 0xc0
+#define GATT_EV_NOTIFICATION 0x80
struct gatt_notification_ev {
uint8_t address_type;
uint8_t address[6];
@@ -516,6 +516,13 @@ struct gatt_notification_ev {
uint8_t data[0];
} __packed;
+static inline void tester_set_bit(uint8_t *addr, unsigned int bit)
+{
+ uint8_t *p = addr + (bit / 8);
+
+ *p |= BIT(bit % 8);
+}
+
void tester_init(void);
void tester_rsp(uint8_t service, uint8_t opcode, uint8_t index, uint8_t status);
void tester_send(uint8_t service, uint8_t opcode, uint8_t index, uint8_t *data,
diff --git a/tests/bluetooth/tester/src/gap.c b/tests/bluetooth/tester/src/gap.c
index ff50b415d..e05de41ef 100644
--- a/tests/bluetooth/tester/src/gap.c
+++ b/tests/bluetooth/tester/src/gap.c
@@ -25,7 +25,6 @@
#include <bluetooth/conn.h>
#include <misc/byteorder.h>
-#include <misc/util.h>
#include "bttester.h"
diff --git a/tests/bluetooth/tester/src/gatt.c b/tests/bluetooth/tester/src/gatt.c
index f91e8368a..a568102e1 100644
--- a/tests/bluetooth/tester/src/gatt.c
+++ b/tests/bluetooth/tester/src/gatt.c
@@ -128,32 +128,34 @@ static uint8_t btp2bt_uuid(const uint8_t *uuid, uint8_t len,
static void supported_commands(uint8_t *data, uint16_t len)
{
- uint64_t cmds[2];
+ uint8_t cmds[4];
struct gatt_read_supported_commands_rp *rp = (void *) cmds;
- cmds[0] = BIT(GATT_READ_SUPPORTED_COMMANDS);
- cmds[0] |= BIT(GATT_ADD_SERVICE);
- cmds[0] |= BIT(GATT_ADD_CHARACTERISTIC);
- cmds[0] |= BIT(GATT_ADD_DESCRIPTOR);
- cmds[0] |= BIT(GATT_ADD_INCLUDED_SERVICE);
- cmds[0] |= BIT(GATT_SET_VALUE);
- cmds[0] |= BIT(GATT_START_SERVER);
- cmds[0] |= BIT(GATT_SET_ENC_KEY_SIZE);
- cmds[1] = BIT(GATT_EXCHANGE_MTU - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_DISC_PRIM_UUID - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_FIND_INCLUDED - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_DISC_ALL_CHRC - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_DISC_CHRC_UUID - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_DISC_ALL_DESC - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_READ - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_READ_LONG - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_READ_MULTIPLE - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_WRITE_WITHOUT_RSP - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_SIGNED_WRITE_WITHOUT_RSP - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_WRITE - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_WRITE_LONG - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_CFG_NOTIFY - GATT_CLIENT_OP_OFFSET);
- cmds[1] |= BIT(GATT_CFG_INDICATE - GATT_CLIENT_OP_OFFSET);
+ memset(cmds, 0, sizeof(cmds));
+
+ tester_set_bit(cmds, GATT_READ_SUPPORTED_COMMANDS);
+ tester_set_bit(cmds, GATT_ADD_SERVICE);
+ tester_set_bit(cmds, GATT_ADD_CHARACTERISTIC);
+ tester_set_bit(cmds, GATT_ADD_DESCRIPTOR);
+ tester_set_bit(cmds, GATT_ADD_INCLUDED_SERVICE);
+ tester_set_bit(cmds, GATT_SET_VALUE);
+ tester_set_bit(cmds, GATT_START_SERVER);
+ tester_set_bit(cmds, GATT_SET_ENC_KEY_SIZE);
+ tester_set_bit(cmds, GATT_EXCHANGE_MTU);
+ tester_set_bit(cmds, GATT_DISC_PRIM_UUID);
+ tester_set_bit(cmds, GATT_FIND_INCLUDED);
+ tester_set_bit(cmds, GATT_DISC_ALL_CHRC);
+ tester_set_bit(cmds, GATT_DISC_CHRC_UUID);
+ tester_set_bit(cmds, GATT_DISC_ALL_DESC);
+ tester_set_bit(cmds, GATT_READ);
+ tester_set_bit(cmds, GATT_READ_LONG);
+ tester_set_bit(cmds, GATT_READ_MULTIPLE);
+ tester_set_bit(cmds, GATT_WRITE_WITHOUT_RSP);
+ tester_set_bit(cmds, GATT_SIGNED_WRITE_WITHOUT_RSP);
+ tester_set_bit(cmds, GATT_WRITE);
+ tester_set_bit(cmds, GATT_WRITE_LONG);
+ tester_set_bit(cmds, GATT_CFG_NOTIFY);
+ tester_set_bit(cmds, GATT_CFG_INDICATE);
tester_send(BTP_SERVICE_ID_GATT, GATT_READ_SUPPORTED_COMMANDS,
CONTROLLER_INDEX, (uint8_t *) rp, sizeof(cmds));