Skip to content

Commit a08f3a8

Browse files
committed
nimble/ll: Add a workaround to debug Channel Sounding on bsim
Limit Channel Sounding channels to 0-39 for bsim.Babblesim does not support the required range of channels, so to debug on bsim let's just truncate value to supported value range. CS_SYNC packet does not contain a header nor CRC, but on bsim we can not skip those. Let's include this overhead in step duration.
1 parent 0745543 commit a08f3a8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

nimble/controller/src/ble_ll_cs_proc.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ struct ble_ll_cs_sm *g_ble_ll_cs_sm_current;
7474
/* The requency measurement period in µs */
7575
#define T_FM (80)
7676

77+
/* Complement to full byte (4 bits) + header (16 bits) + CRC (24 bits) */
78+
#define BSIM_PACKET_OVERHEAD 4 + 16 + 24;
79+
7780
static struct ble_ll_cs_aci aci_table[] = {
7881
{1, 1, 1}, {2, 2, 1}, {3, 3, 1}, {4, 4, 1},
7982
{2, 1, 2}, {3, 1, 3}, {4, 1, 4}, {4, 2, 2}
@@ -660,6 +663,14 @@ ble_ll_cs_proc_calculate_timing(struct ble_ll_cs_sm *cssm)
660663

661664
cssm->procedure_interval_usecs = params->procedure_interval * cssm->connsm->conn_itvl *
662665
BLE_LL_CONN_ITVL_USECS;
666+
667+
#if BABBLESIM
668+
cssm->mode_duration_usecs[BLE_LL_CS_MODE0] += BSIM_PACKET_OVERHEAD;
669+
cssm->mode_duration_usecs[BLE_LL_CS_MODE1] += BSIM_PACKET_OVERHEAD;
670+
cssm->mode_duration_usecs[BLE_LL_CS_MODE2] += BSIM_PACKET_OVERHEAD;
671+
cssm->mode_duration_usecs[BLE_LL_CS_MODE3] += BSIM_PACKET_OVERHEAD;
672+
#endif
673+
663674
return 0;
664675
}
665676

@@ -669,6 +680,10 @@ ble_ll_cs_proc_step_state_duration_get(uint8_t state, uint8_t mode,
669680
{
670681
uint32_t duration = 0;
671682

683+
#if BABBLESIM
684+
t_sy += BSIM_PACKET_OVERHEAD;
685+
#endif
686+
672687
switch (state) {
673688
case STEP_STATE_CS_SYNC_I:
674689
case STEP_STATE_CS_SYNC_R:
@@ -856,6 +871,12 @@ ble_ll_cs_proc_sched_cb_get(uint8_t role, uint8_t step_state)
856871
BLE_LL_ASSERT(0);
857872
}
858873

874+
#if BABBLESIM
875+
if (cb == ble_ll_cs_tone_tx_start || cb == ble_ll_cs_tone_rx_start) {
876+
cb = ble_ll_cs_proc_skip_txrx;
877+
}
878+
#endif
879+
859880
return cb;
860881
}
861882

nimble/drivers/nrf5x/src/ble_phy.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070

7171
#if BABBLESIM
7272
extern void tm_tick(void);
73+
#undef RADIO_STATE_STATE_Tx
74+
#undef RADIO_STATE_STATE_TxDisable
75+
#define RADIO_STATE_STATE_TxStarting (11UL) /* An additional state used in bsim */
76+
#define RADIO_STATE_STATE_Tx (12UL) /* RADIO is in the TX state */
77+
#define RADIO_STATE_STATE_TxDisable (13UL) /* RADIO is in the TXDISABLED state */
7378
#endif
7479

7580
#include <controller/ble_ll_pdu.h>

0 commit comments

Comments
 (0)