Skip to content

Commit 1dadb5d

Browse files
eriksandgrenkartben
authored andcommitted
samples: Bluetooth: Print that sample does not support > 1 subevent
This commit adds a print statement to both connected_cs_initiator and connected_cs_reflector which will inform the user that the sample cannot handle more than 1 CS subevent per CS procedure. This is preferable over the sample failing silently if a user is attempting to use such a configuration. Signed-off-by: Erik Sandgren <erik.sandgren@nordicsemi.no>
1 parent e135588 commit 1dadb5d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

samples/bluetooth/channel_sounding/src/connected_cs_initiator.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static ssize_t on_attr_write_cb(struct bt_conn *conn, const struct bt_gatt_attr
2929
static struct bt_conn *connection;
3030
static uint8_t n_ap;
3131
static uint8_t latest_num_steps_reported;
32+
static uint16_t latest_procedure_counter = UINT16_MAX;
3233
static uint16_t latest_step_data_len;
3334
static uint8_t latest_local_steps[STEP_DATA_BUF_LEN];
3435
static uint8_t latest_peer_steps[STEP_DATA_BUF_LEN];
@@ -72,6 +73,13 @@ static void subevent_result_cb(struct bt_conn *conn, struct bt_conn_le_cs_subeve
7273
latest_num_steps_reported = result->header.num_steps_reported;
7374
n_ap = result->header.num_antenna_paths;
7475

76+
if (result->header.procedure_counter == latest_procedure_counter) {
77+
printk("The sample does not handle CS procedures with multiple CS subevents.\n");
78+
latest_procedure_counter = result->header.procedure_counter;
79+
return;
80+
}
81+
latest_procedure_counter = result->header.procedure_counter;
82+
7583
if (result->step_data_buf) {
7684
if (result->step_data_buf->len <= STEP_DATA_BUF_LEN) {
7785
memcpy(latest_local_steps, result->step_data_buf->data,

samples/bluetooth/channel_sounding/src/connected_cs_reflector.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ static K_SEM_DEFINE(sem_written, 0, 1);
2525

2626
static uint16_t step_data_attr_handle;
2727
static struct bt_conn *connection;
28+
static uint16_t latest_procedure_counter = UINT16_MAX;
2829
static uint8_t latest_local_steps[STEP_DATA_BUF_LEN];
2930

3031
static const char sample_str[] = "CS Sample";
@@ -34,6 +35,13 @@ static const struct bt_data ad[] = {
3435

3536
static void subevent_result_cb(struct bt_conn *conn, struct bt_conn_le_cs_subevent_result *result)
3637
{
38+
if (result->header.procedure_counter == latest_procedure_counter) {
39+
printk("The sample does not handle CS procedures with multiple CS subevents.\n");
40+
latest_procedure_counter = result->header.procedure_counter;
41+
return;
42+
}
43+
latest_procedure_counter = result->header.procedure_counter;
44+
3745
if (result->step_data_buf) {
3846
if (result->step_data_buf->len <= STEP_DATA_BUF_LEN) {
3947
memcpy(latest_local_steps, result->step_data_buf->data,

0 commit comments

Comments
 (0)