Skip to content

Commit

Permalink
apps: bttester: Add notify multiple command
Browse files Browse the repository at this point in the history
Add funcionality to utilize BTP notify multiple command.
Existing notify handling parses nonexisting data.
  • Loading branch information
szymon-czapracki committed Jan 28, 2025
1 parent 0f09bcf commit 388966b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apps/bttester/src/btp/btp_gatt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 data[0];
} __packed;

/* GATT events */
#define BTP_GATT_EV_NOTIFICATION 0x80
struct btp_gatt_notification_ev {
Expand Down
35 changes: 35 additions & 0 deletions apps/bttester/src/btp_gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,36 @@ set_mult(const void *cmd, uint16_t cmd_len,
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;
uint16_t handles[16];
struct ble_gap_conn_desc conn;
uint16_t data_idx = 0;
int rc;
int i;

rc = ble_gap_conn_find_by_addr(&cp->addr, &conn);
if (rc) {
return BTP_STATUS_FAILED;
}


for (i = 0; i < cp->count; i++) {
handles[i] = get_le16(cp->data + data_idx);
data_idx += 2;
}

rc = ble_gatts_notify_multiple(conn.conn_handle, cp->count, handles);
if (rc) {
return BTP_STATUS_FAILED;
}

return BTP_STATUS_SUCCESS;
}

static uint8_t
change_database(const void *cmd, uint16_t cmd_len,
void *rsp, uint16_t *rsp_len)
Expand Down Expand Up @@ -2100,6 +2130,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
Expand Down

0 comments on commit 388966b

Please sign in to comment.