Skip to content

Commit 0ab5005

Browse files
sjancjhedberg
authored andcommitted
tests: Bluetooth: Tester: Fix GATT Notify Multiple BTP command
This fix multiple issues with command implementation: - lack of LE to host convertion - using strtoul() on non-string data - passing stack variable as attr data (which must be present until notification is sent) This was affecting GATT/SR/GAN/BV-02-C qualification test case. Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
1 parent b1cf15b commit 0ab5005

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

tests/bluetooth/tester/src/btp_gatt.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,7 @@ static uint8_t notify_mult(const void *cmd, uint16_t cmd_len,
21112111
struct bt_conn *conn;
21122112
const size_t min_cnt = 1U;
21132113
int err = 0;
2114-
uint16_t attr_data_len = 0;
2114+
uint16_t server_db_start_handle = server_db[0].handle;
21152115

21162116
if ((cmd_len < sizeof(*cp)) ||
21172117
(cmd_len != sizeof(*cp) + (cp->cnt * sizeof(cp->attr_id[0])))) {
@@ -2133,14 +2133,23 @@ static uint8_t notify_mult(const void *cmd, uint16_t cmd_len,
21332133
(void)memset(params, 0, sizeof(params));
21342134

21352135
for (uint16_t i = 0U; i < cp->cnt; i++) {
2136-
struct bt_gatt_attr attr = server_db[cp->attr_id[i] -
2137-
server_db[0].handle];
2136+
const struct bt_gatt_attr *attr;
2137+
const struct gatt_value *value;
2138+
uint16_t handle = sys_le16_to_cpu(cp->attr_id[i]);
2139+
2140+
if (!IN_RANGE(handle, server_db_start_handle,
2141+
server_db_start_handle + attr_count)) {
2142+
LOG_ERR("ATT handle %u not in server DB range", handle);
2143+
return BTP_STATUS_FAILED;
2144+
}
2145+
2146+
attr = &server_db[handle - server_db_start_handle];
2147+
value = attr->user_data;
21382148

2139-
attr_data_len = strtoul(attr.user_data, NULL, 16);
21402149
params[i].uuid = 0;
2141-
params[i].attr = &attr;
2142-
params[i].data = &attr.user_data;
2143-
params[i].len = attr_data_len;
2150+
params[i].attr = attr;
2151+
params[i].data = value->data;
2152+
params[i].len = value->len;
21442153
params[i].func = notify_cb;
21452154
params[i].user_data = NULL;
21462155
}

0 commit comments

Comments
 (0)