This is an automated email from the ASF dual-hosted git repository. janc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git
commit e2065a6016dc2fbe439458eb09ebfa599e4e3cba Author: Krzysztof Kopyściński <[email protected]> AuthorDate: Thu Jul 13 10:09:14 2023 +0200 bluetooth: tester: Use define for variable length BTP commands This makes code a bit easier to follow. --- apps/bttester/src/btp/bttester.h | 5 +++++ apps/bttester/src/btp_gap.c | 4 ++-- apps/bttester/src/btp_gatt.c | 20 ++++++++++---------- apps/bttester/src/btp_gatt_cl.c | 18 +++++++++--------- apps/bttester/src/btp_l2cap.c | 4 ++-- apps/bttester/src/btp_mesh.c | 10 +++++----- 6 files changed, 33 insertions(+), 28 deletions(-) diff --git a/apps/bttester/src/btp/bttester.h b/apps/bttester/src/btp/bttester.h index 120e623db..8e8b98b5a 100644 --- a/apps/bttester/src/btp/bttester.h +++ b/apps/bttester/src/btp/bttester.h @@ -77,6 +77,11 @@ tester_rsp_full(uint8_t service, uint8_t opcode, const void *rsp, size_t len); void tester_event(uint8_t service, uint8_t opcode, const void *data, size_t len); +/* Used to indicate that command length is variable and that validation will + * be done in handler. + */ +#define BTP_HANDLER_LENGTH_VARIABLE (-1) + struct btp_handler { uint8_t opcode; uint8_t index; diff --git a/apps/bttester/src/btp_gap.c b/apps/bttester/src/btp_gap.c index 30c36e229..ebd076315 100644 --- a/apps/bttester/src/btp_gap.c +++ b/apps/bttester/src/btp_gap.c @@ -1801,7 +1801,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GAP_START_ADVERTISING, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = start_advertising, }, { @@ -1886,7 +1886,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GAP_SET_FILTER_ACCEPT_LIST, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = set_filter_accept_list, }, }; diff --git a/apps/bttester/src/btp_gatt.c b/apps/bttester/src/btp_gatt.c index b77919466..72115e21a 100644 --- a/apps/bttester/src/btp_gatt.c +++ b/apps/bttester/src/btp_gatt.c @@ -1918,7 +1918,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GATT_DISC_PRIM_UUID, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = disc_prim_uuid, }, { @@ -1933,7 +1933,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GATT_DISC_CHRC_UUID, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = disc_chrc_uuid, }, { @@ -1953,7 +1953,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GATT_READ_UUID, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = read_uuid, }, { @@ -1963,34 +1963,34 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GATT_READ_MULTIPLE, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = read_multiple, }, { .opcode = BTP_GATT_WRITE_WITHOUT_RSP, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = write_without_rsp, }, #if 0 { .opcode = BTP_GATT_SIGNED_WRITE_WITHOUT_RSP, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = write_signed_without_rsp, }, #endif { .opcode = BTP_GATT_WRITE, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = write_data, }, { .opcode = BTP_GATT_WRITE_LONG, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = write_long, }, { .opcode = BTP_GATT_RELIABLE_WRITE, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = reliable_write, }, { @@ -2005,7 +2005,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GATT_GET_ATTRIBUTES, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = get_attrs, }, { diff --git a/apps/bttester/src/btp_gatt_cl.c b/apps/bttester/src/btp_gatt_cl.c index 63f657562..ff76d7dd7 100644 --- a/apps/bttester/src/btp_gatt_cl.c +++ b/apps/bttester/src/btp_gatt_cl.c @@ -1459,7 +1459,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GATTC_DISC_PRIM_UUID, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = disc_prim_uuid, }, { @@ -1474,7 +1474,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GATTC_DISC_CHRC_UUID, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = disc_chrc_uuid, }, { @@ -1489,7 +1489,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GATTC_READ_UUID, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = read_uuid, }, { @@ -1499,34 +1499,34 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_GATTC_READ_MULTIPLE, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = read_multiple, }, { .opcode = BTP_GATTC_WRITE_WITHOUT_RSP, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = write_without_rsp, }, #if 0 { .opcode = BTP_GATTC_SIGNED_WRITE_WITHOUT_RSP, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = write_signed_without_rsp, }, #endif { .opcode = BTP_GATTC_WRITE, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = write, }, { .opcode = BTP_GATTC_WRITE_LONG, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = write_long, }, { .opcode = BTP_GATTC_RELIABLE_WRITE, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = reliable_write, }, { diff --git a/apps/bttester/src/btp_l2cap.c b/apps/bttester/src/btp_l2cap.c index f8450760b..34749af7f 100644 --- a/apps/bttester/src/btp_l2cap.c +++ b/apps/bttester/src/btp_l2cap.c @@ -727,7 +727,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_L2CAP_SEND_DATA, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = send_data, }, { @@ -737,7 +737,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_L2CAP_RECONFIGURE, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = reconfigure, }, { diff --git a/apps/bttester/src/btp_mesh.c b/apps/bttester/src/btp_mesh.c index 8d557e2af..96eaaf81f 100644 --- a/apps/bttester/src/btp_mesh.c +++ b/apps/bttester/src/btp_mesh.c @@ -837,12 +837,12 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_MESH_CONFIG_PROVISIONING, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = config_prov, }, { .opcode = BTP_MESH_PROVISION_NODE, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = provision_node, }, { @@ -862,7 +862,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_MESH_INPUT_STRING, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = input_string, }, { @@ -887,7 +887,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_MESH_NET_SEND, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = net_send, }, { @@ -902,7 +902,7 @@ static const struct btp_handler handlers[] = { }, { .opcode = BTP_MESH_MODEL_SEND, - .expect_len = -1, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = model_send, }, {
