Skip to content

Commit 7e5ac1b

Browse files
ppryga-nordiccfriedt
authored andcommitted
Bluetooth: controller: df: fix handling of max count of IQ reports
There was an error in handling of max number of IQ reports generated by controller. Accordin to BT Core Spec 5.1 the host may request a number of CTEs to be sampled and reported by controller while enable IQ sampling. The max_cte_count value set to zero means sample all CTEs in a periodic advertising chain. The commit fixes wrong handling of the max_cte_count provided value to generate expected number of IQ reports. Signed-off-by: Piotr Pryga <[email protected]>
1 parent f215361 commit 7e5ac1b

File tree

1 file changed

+12
-6
lines changed
  • subsys/bluetooth/controller/ll_sw/nordic/lll

1 file changed

+12
-6
lines changed

subsys/bluetooth/controller/ll_sw/nordic/lll/lll_sync.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static void isr_done(void *param);
5858
#if defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX)
5959
static int create_iq_report(struct lll_sync *lll, uint8_t rssi_ready,
6060
uint8_t packet_status);
61+
static bool is_max_cte_reached(uint8_t max_cte_count, uint8_t cte_count);
6162
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */
6263
static uint8_t data_channel_calc(struct lll_sync *lll);
6364
static enum sync_status sync_filtrate_by_cte_type(uint8_t cte_type_mask, uint8_t filter_policy);
@@ -547,10 +548,9 @@ static void isr_aux_setup(void *param)
547548

548549
cfg = lll_df_sync_cfg_latest_get(&lll->df_cfg, NULL);
549550

550-
if (cfg->is_enabled) {
551-
lll_df_conf_cte_rx_enable(cfg->slot_durations, cfg->ant_sw_len,
552-
cfg->ant_ids, aux_ptr->chan_idx);
553-
cfg->cte_count = 0;
551+
if (cfg->is_enabled && is_max_cte_reached(cfg->max_cte_count, cfg->cte_count)) {
552+
lll_df_conf_cte_rx_enable(cfg->slot_durations, cfg->ant_sw_len, cfg->ant_ids,
553+
aux_ptr->chan_idx);
554554

555555
radio_switch_complete_and_phy_end_disable();
556556
} else
@@ -930,8 +930,7 @@ static inline int create_iq_report(struct lll_sync *lll, uint8_t rssi_ready,
930930
cfg = lll_df_sync_cfg_curr_get(&lll->df_cfg);
931931

932932
if (cfg->is_enabled) {
933-
934-
if (cfg->cte_count < cfg->max_cte_count) {
933+
if (is_max_cte_reached(cfg->max_cte_count, cfg->cte_count)) {
935934
sample_cnt = radio_df_iq_samples_amount_get();
936935

937936
/* If there are no samples available, the CTEInfo was
@@ -954,6 +953,8 @@ static inline int create_iq_report(struct lll_sync *lll, uint8_t rssi_ready,
954953
ftr->rssi = ((rssi_ready) ? radio_rssi_get() :
955954
BT_HCI_LE_RSSI_NOT_AVAILABLE);
956955

956+
cfg->cte_count += 1U;
957+
957958
ull_rx_put(iq_report->hdr.link, iq_report);
958959
} else {
959960
return -ENODATA;
@@ -963,6 +964,11 @@ static inline int create_iq_report(struct lll_sync *lll, uint8_t rssi_ready,
963964

964965
return 0;
965966
}
967+
968+
static bool is_max_cte_reached(uint8_t max_cte_count, uint8_t cte_count)
969+
{
970+
return max_cte_count == BT_HCI_LE_SAMPLE_CTE_ALL || cte_count < max_cte_count;
971+
}
966972
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */
967973

968974
static uint8_t data_channel_calc(struct lll_sync *lll)

0 commit comments

Comments
 (0)