Skip to content

Commit c5a126c

Browse files
bugo-nordicnashif
authored andcommitted
bluetooth: host: LE CS subevent result reassembly
Adds HCI support for LE CS subevent result continue event and the reassembly logic for the partial results. When subevent results are completed or the subevent is aborted, the user callback is invoked with a buffer pointing to the HCI event buffer, so no copy is done. When subevent results are incomplete, then a reassembly buffer is allocated from a fixed sized pool. This buffer is used for the reassembling of the subevent result containing all of the step data, which is then passed to the user via the callback. kconfigs have been added to set the size and the count of the reassembly buffer. Signed-off-by: Burak Gorduk <[email protected]>
1 parent ac98d0e commit c5a126c

File tree

6 files changed

+446
-34
lines changed

6 files changed

+446
-34
lines changed

include/zephyr/bluetooth/conn.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ enum bt_conn_le_cs_procedure_done_status {
548548
/** Subevent done status */
549549
enum bt_conn_le_cs_subevent_done_status {
550550
BT_CONN_LE_CS_SUBEVENT_COMPLETE = BT_HCI_LE_CS_SUBEVENT_DONE_STATUS_COMPLETE,
551-
BT_CONN_LE_CS_SUBEVENT_INCOMPLETE = BT_HCI_LE_CS_SUBEVENT_DONE_STATUS_PARTIAL,
552551
BT_CONN_LE_CS_SUBEVENT_ABORTED = BT_HCI_LE_CS_SUBEVENT_DONE_STATUS_ABORTED,
553552
};
554553

@@ -618,7 +617,19 @@ struct bt_conn_le_cs_subevent_result {
618617
int8_t reference_power_level;
619618
/** Procedure status. */
620619
enum bt_conn_le_cs_procedure_done_status procedure_done_status;
621-
/** Subevent status. */
620+
/** Subevent status
621+
*
622+
* For aborted subevents, this will be set to @ref BT_CONN_LE_CS_SUBEVENT_ABORTED
623+
* and abort_step will contain the step number on which the subevent was aborted.
624+
* Consider the following example:
625+
*
626+
* subevent_done_status = @ref BT_CONN_LE_CS_SUBEVENT_ABORTED
627+
* num_steps_reported = 160
628+
* abort_step = 100
629+
*
630+
* this would mean that steps from 0 to 99 are complete and steps from 100 to 159
631+
* are aborted.
632+
*/
622633
enum bt_conn_le_cs_subevent_done_status subevent_done_status;
623634
/** Abort reason.
624635
*
@@ -640,6 +651,11 @@ struct bt_conn_le_cs_subevent_result {
640651
/** Number of CS steps in the subevent.
641652
*/
642653
uint8_t num_steps_reported;
654+
/** Step number, on which the subevent was aborted
655+
* if subevent_done_status is @ref BT_CONN_LE_CS_SUBEVENT_COMPLETE
656+
* then abort_step will be unused and set to 255
657+
*/
658+
uint8_t abort_step;
643659
} header;
644660
struct net_buf_simple *step_data_buf;
645661
};

include/zephyr/bluetooth/hci_types.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3636,6 +3636,25 @@ struct bt_hci_evt_le_cs_subevent_result {
36363636
uint8_t steps[];
36373637
} __packed;
36383638

3639+
#define BT_HCI_EVT_LE_CS_SUBEVENT_RESULT_CONTINUE 0x32
3640+
3641+
struct bt_hci_evt_le_cs_subevent_result_continue {
3642+
uint16_t conn_handle;
3643+
uint8_t config_id;
3644+
uint8_t procedure_done_status;
3645+
uint8_t subevent_done_status;
3646+
#ifdef CONFIG_LITTLE_ENDIAN
3647+
uint8_t procedure_abort_reason: 4;
3648+
uint8_t subevent_abort_reason: 4;
3649+
#else
3650+
uint8_t subevent_abort_reason: 4;
3651+
uint8_t procedure_abort_reason: 4;
3652+
#endif /* CONFIG_LITTLE_ENDIAN */
3653+
uint8_t num_antenna_paths;
3654+
uint8_t num_steps_reported;
3655+
uint8_t steps[];
3656+
} __packed;
3657+
36393658
#define BT_HCI_EVT_LE_CS_TEST_END_COMPLETE 0x33
36403659
struct bt_hci_evt_le_cs_test_end_complete {
36413660
uint8_t status;
@@ -3734,6 +3753,7 @@ struct bt_hci_evt_le_cs_test_end_complete {
37343753
#define BT_EVT_MASK_LE_CS_READ_REMOTE_FAE_TABLE_COMPLETE BT_EVT_BIT(44)
37353754
#define BT_EVT_MASK_LE_CS_CONFIG_COMPLETE BT_EVT_BIT(46)
37363755
#define BT_EVT_MASK_LE_CS_SUBEVENT_RESULT BT_EVT_BIT(48)
3756+
#define BT_EVT_MASK_LE_CS_SUBEVENT_RESULT_CONTINUE BT_EVT_BIT(49)
37373757
#define BT_EVT_MASK_LE_CS_TEST_END_COMPLETE BT_EVT_BIT(50)
37383758

37393759
/** HCI Error Codes, BT Core Spec v5.4 [Vol 1, Part F]. */

subsys/bluetooth/Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,26 @@ config BT_CHANNEL_SOUNDING_TEST
203203
help
204204
Enable support for Channel Sounding test mode.
205205

206+
config BT_CHANNEL_SOUNDING_REASSEMBLY_BUFFER_SIZE
207+
int "Subevent result reassembly buffer size"
208+
depends on BT_CHANNEL_SOUNDING
209+
range 239 5600
210+
default 5600
211+
help
212+
When the results for a CS subevent cannot fit into a single HCI event,
213+
it will be split up into multiple events and consequently, reassembled into a
214+
full CS subevent. This config sets the size of the reassembly buffer.
215+
216+
config BT_CHANNEL_SOUNDING_REASSEMBLY_BUFFER_CNT
217+
int "Subevent result reassembly buffer count"
218+
depends on BT_CHANNEL_SOUNDING
219+
range 1 BT_MAX_CONN
220+
default 1
221+
help
222+
Controls the number of the reassembly buffers for CS subevent
223+
results. Each running CS procedure is allocated one buffer and the
224+
number of concurrent CS procedures is limited by this value.
225+
206226
endif # BT_CONN
207227

208228
rsource "Kconfig.iso"

0 commit comments

Comments
 (0)