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 ca51138f488703884301e907a7219dcf12b7982a Author: Szymon Czapracki <[email protected]> AuthorDate: Tue Jan 28 17:33:06 2025 +0100 apps: bttester: Add notify multiple command Add functionality to utilize BTP notify multiple command. Existing notify handling parses non-existent data. --- apps/bttester/src/btp/btp_gatt.h | 7 +++++++ apps/bttester/src/btp_gatt.c | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/apps/bttester/src/btp/btp_gatt.h b/apps/bttester/src/btp/btp_gatt.h index 8da6f43df..7849263de 100644 --- a/apps/bttester/src/btp/btp_gatt.h +++ b/apps/bttester/src/btp/btp_gatt.h @@ -320,6 +320,13 @@ struct btp_gatt_set_mult_val_cmd { uint8_t data[0]; } __packed; +#define BTP_GATT_NOTIFY_MULTIPLE 0x21 +struct btp_gatt_notify_mult_val_cmd { + ble_addr_t addr; + uint16_t count; + uint16_t handles[0]; +} __packed; + /* GATT events */ #define BTP_GATT_EV_NOTIFICATION 0x80 struct btp_gatt_notification_ev { diff --git a/apps/bttester/src/btp_gatt.c b/apps/bttester/src/btp_gatt.c index 157e7da1c..cbfe1f8fe 100644 --- a/apps/bttester/src/btp_gatt.c +++ b/apps/bttester/src/btp_gatt.c @@ -95,7 +95,7 @@ struct find_attr_data { struct notify_mult_cb_data { size_t tuple_cnt; - uint16_t handles[0]; + uint16_t handles[8]; }; static int @@ -1950,6 +1950,38 @@ done: return BTP_STATUS_SUCCESS; } +static uint8_t +notify_mult(const void *cmd, uint16_t cmd_len, + void *rsp, uint16_t *rsp_len) +{ + const struct btp_gatt_notify_mult_val_cmd *cp = cmd; + struct notify_mult_cb_data cb_data; + int i; + + + if (cmd_len < sizeof(*cp) || + (cmd_len != (sizeof(*cp) + + (le16toh(cp->count) * sizeof(cp->handles[0]))))) { + + return BTP_STATUS_FAILED; + } + + if (le16toh(cp->count) > sizeof(cb_data.handles)) { + SYS_LOG_ERR("Too many handles to notify"); + return BTP_STATUS_FAILED; + } + + for (i = 0; i < cp->count; i++) { + cb_data.handles[i] = le16toh(cp->handles[i]); + } + + cb_data.tuple_cnt = cp->count; + + ble_gap_conn_foreach_handle(notify_multiple, (void *)&cb_data); + + return BTP_STATUS_SUCCESS; +} + static uint8_t change_database(const void *cmd, uint16_t cmd_len, void *rsp, uint16_t *rsp_len) @@ -2137,6 +2169,11 @@ static const struct btp_handler handlers[] = { .expect_len = BTP_HANDLER_LENGTH_VARIABLE, .func = set_mult, }, + { + .opcode = BTP_GATT_NOTIFY_MULTIPLE, + .expect_len = BTP_HANDLER_LENGTH_VARIABLE, + .func = notify_mult, + }, }; int
