Skip to content

Commit 64eaa52

Browse files
cvinayakcarlescufi
authored andcommitted
Bluetooth: Controller: Initial support for Periodic Sync Receive enable
Initial support for Periodic Advertising Synchronization Receive Enable command. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 1686551 commit 64eaa52

File tree

3 files changed

+68
-21
lines changed

3 files changed

+68
-21
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,6 +3551,22 @@ static void le_per_adv_recv_enable(struct net_buf *buf, struct net_buf **evt)
35513551

35523552
status = ll_sync_recv_enable(handle, cmd->enable);
35533553

3554+
#if CONFIG_BT_CTLR_DUP_FILTER_LEN > 0
3555+
if (!status) {
3556+
if (cmd->enable &
3557+
BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_FILTER_DUPLICATE) {
3558+
if (!dup_scan || (dup_count < 0)) {
3559+
dup_count = 0;
3560+
dup_curr = 0U;
3561+
} else {
3562+
/* FIXME: Invalidate dup_ext_adv_mode array entries */
3563+
}
3564+
} else if (!dup_scan) {
3565+
dup_count = DUP_FILTER_DISABLED;
3566+
}
3567+
}
3568+
#endif
3569+
35543570
ccst = hci_cmd_complete(evt, sizeof(*ccst));
35553571
ccst->status = status;
35563572
}

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,16 @@ static void isr_aux_setup(void *param)
619619
static int isr_rx(struct lll_sync *lll, uint8_t node_type, uint8_t crc_ok, uint8_t rssi_ready,
620620
enum sync_status status)
621621
{
622+
uint8_t sched = 0U;
622623
int err;
623624

624625
/* Check CRC and generate Periodic Advertising Report */
625626
if (crc_ok) {
626627
struct node_rx_pdu *node_rx;
627628

628629
node_rx = ull_pdu_rx_alloc_peek(3);
629-
if (node_rx) {
630+
if (node_rx &&
631+
(lll->is_rx_enabled || (node_type == NODE_RX_TYPE_SYNC))) {
630632
struct node_rx_ftr *ftr;
631633
struct pdu_adv *pdu;
632634

@@ -660,25 +662,31 @@ static int isr_rx(struct lll_sync *lll, uint8_t node_type, uint8_t crc_ok, uint8
660662

661663
ull_rx_put(node_rx->hdr.link, node_rx);
662664

663-
#if defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX)
664-
(void)create_iq_report(lll, rssi_ready,
665-
BT_HCI_LE_CTE_CRC_OK);
666-
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */
667-
668-
ull_rx_sched();
665+
sched = 1U;
669666
} else {
670667
err = 0;
671668
}
669+
670+
#if defined(CONFIG_BT_CTLR_DF_SCAN_CTE_RX)
671+
(void)create_iq_report(lll, rssi_ready, BT_HCI_LE_CTE_CRC_OK);
672+
sched = 1U;
673+
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */
674+
672675
} else {
673676
#if defined(CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC)
674677
err = create_iq_report(lll, rssi_ready, BT_HCI_LE_CTE_CRC_ERR_CTE_BASED_TIME);
675678
if (!err) {
676-
ull_rx_sched();
679+
sched = 1U;
677680
}
678681
#endif /* CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC */
682+
679683
err = 0;
680684
}
681685

686+
if (sched) {
687+
ull_rx_sched();
688+
}
689+
682690
return err;
683691
}
684692

subsys/bluetooth/controller/ll_sw/ull_sync.c

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ uint8_t ll_sync_create(uint8_t options, uint8_t sid, uint8_t adv_addr_type,
227227
lll_sync->filter_policy = scan->per_scan.filter_policy;
228228
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
229229

230-
/* TODO: Add support for reporting initially enabled/disabled */
230+
/* Reporting initially enabled/disabled */
231231
lll_sync->is_rx_enabled =
232232
!(options & BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_REPORTS_DISABLED);
233233

@@ -361,8 +361,27 @@ uint8_t ll_sync_terminate(uint16_t handle)
361361

362362
uint8_t ll_sync_recv_enable(uint16_t handle, uint8_t enable)
363363
{
364-
/* TODO: Add support for reporting enable/disable */
365-
return BT_HCI_ERR_CMD_DISALLOWED;
364+
struct ll_sync_set *sync;
365+
struct lll_sync *lll;
366+
367+
sync = ull_sync_is_enabled_get(handle);
368+
if (!sync) {
369+
return BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER;
370+
}
371+
372+
/* Reporting enabled/disabled */
373+
lll = &sync->lll;
374+
lll->is_rx_enabled = (enable &
375+
BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_ENABLE) ?
376+
1U : 0U;
377+
378+
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC_ADI_SUPPORT)
379+
sync->nodups = (enable &
380+
BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_FILTER_DUPLICATE) ?
381+
1U : 0U;
382+
#endif
383+
384+
return 0;
366385
}
367386

368387
int ull_sync_init(void)
@@ -716,6 +735,7 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
716735
struct lll_sync *lll;
717736

718737
ftr = &rx->rx_ftr;
738+
lll = ftr->param;
719739

720740
#if defined(CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING)
721741
enum sync_status sync_status;
@@ -725,8 +745,6 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
725745
#else
726746
struct pdu_cte_info *rx_cte_info;
727747

728-
lll = ftr->param;
729-
730748
rx_cte_info = pdu_cte_info_get((struct pdu_adv *)((struct node_rx_pdu *)rx)->pdu);
731749
if (rx_cte_info != NULL) {
732750
sync_status = lll_sync_cte_is_allowed(lll->cte_type, lll->filter_policy,
@@ -741,14 +759,14 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
741759
* or the CTE type is incorrect and filter policy doesn't allow to continue scanning.
742760
*/
743761
if (sync_status != SYNC_STAT_READY_OR_CONT_SCAN) {
744-
#else
762+
#else /* !CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
763+
745764
if (1) {
746-
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
765+
#endif /* !CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
747766

748767
/* Set the sync handle corresponding to the LLL context passed in the node rx
749768
* footer field.
750769
*/
751-
lll = ftr->param;
752770
ull_sync = HDR_LLL2ULL(lll);
753771

754772
/* Prepare and dispatch sync notification */
@@ -783,15 +801,20 @@ void ull_sync_established_report(memq_link_t *link, struct node_rx_hdr *rx)
783801
* scanning is terminated due to wrong CTE type.
784802
*/
785803
if (sync_status != SYNC_STAT_TERM) {
786-
#else
804+
#else /* !CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
805+
787806
if (1) {
788-
#endif /* CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
807+
#endif /* !CONFIG_BT_CTLR_SYNC_PERIODIC_CTE_TYPE_FILTERING */
789808
/* Switch sync event prepare function to one reposnsible for regular PDUs receive */
790809
mfy_lll_prepare.fp = lll_sync_prepare;
791810

792-
/* Change node type to appropriately handle periodic advertising PDU report */
793-
rx->type = NODE_RX_TYPE_SYNC_REPORT;
794-
ull_scan_aux_setup(link, rx);
811+
if (lll->is_rx_enabled) {
812+
/* Change node type to appropriately handle periodic
813+
* advertising PDU report.
814+
*/
815+
rx->type = NODE_RX_TYPE_SYNC_REPORT;
816+
ull_scan_aux_setup(link, rx);
817+
}
795818
}
796819
}
797820

0 commit comments

Comments
 (0)