42
42
#include <soc.h>
43
43
#include "hal/debug.h"
44
44
45
- /* Periodic advertisements filtering results. */
46
- enum sync_filtering_result {
47
- SYNC_ALLOWED ,
48
- SYNC_SCAN_CONTINUE ,
49
- SYNC_SCAN_TERM
50
- };
51
-
52
45
static int init_reset (void );
53
46
static void prepare (void * param );
54
47
static int create_prepare_cb (struct lll_prepare_param * p );
@@ -67,8 +60,7 @@ static int create_iq_report(struct lll_sync *lll, uint8_t rssi_ready,
67
60
uint8_t packet_status );
68
61
#endif /* CONFIG_BT_CTLR_DF_SCAN_CTE_RX */
69
62
static uint8_t data_channel_calc (struct lll_sync * lll );
70
- static enum sync_filtering_result sync_filtrate_by_cte_type (uint8_t cte_type_mask ,
71
- uint8_t filter_policy );
63
+ static enum sync_status sync_filtrate_by_cte_type (uint8_t cte_type_mask , uint8_t filter_policy );
72
64
73
65
static uint8_t trx_cnt ;
74
66
@@ -194,6 +186,57 @@ void lll_sync_aux_prepare_cb(struct lll_sync *lll,
194
186
}
195
187
}
196
188
189
+ enum sync_status lll_sync_cte_is_allowed (uint8_t cte_type_mask , uint8_t filter_policy ,
190
+ uint8_t rx_cte_time , uint8_t rx_cte_type )
191
+ {
192
+ bool cte_ok ;
193
+
194
+ if (cte_type_mask == BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_FILTERING ) {
195
+ return SYNC_STAT_ALLOWED ;
196
+ }
197
+
198
+ if (rx_cte_time > 0 ) {
199
+ if ((cte_type_mask & BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_CTE ) != 0 ) {
200
+ cte_ok = false;
201
+ } else {
202
+ switch (rx_cte_type ) {
203
+ case BT_HCI_LE_AOA_CTE :
204
+ cte_ok = !(cte_type_mask &
205
+ BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOA );
206
+ break ;
207
+ case BT_HCI_LE_AOD_CTE_1US :
208
+ cte_ok = !(cte_type_mask &
209
+ BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_1US );
210
+ break ;
211
+ case BT_HCI_LE_AOD_CTE_2US :
212
+ cte_ok = !(cte_type_mask &
213
+ BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_2US );
214
+ break ;
215
+ default :
216
+ /* Unknown or forbidden CTE type */
217
+ cte_ok = false;
218
+ }
219
+ }
220
+ } else {
221
+ /* If there is no CTEInfo in advertising PDU, Radio will not parse the S0 byte and
222
+ * CTESTATUS register will hold zeros only.
223
+ * Zero value in CTETime field of CTESTATUS may be used to distinguish between PDU
224
+ * that includes CTEInfo or not. Allowed range for CTETime is 2-20.
225
+ */
226
+ if ((cte_type_mask & BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ONLY_CTE ) != 0 ) {
227
+ cte_ok = false;
228
+ } else {
229
+ cte_ok = true;
230
+ }
231
+ }
232
+
233
+ if (!cte_ok ) {
234
+ return filter_policy ? SYNC_STAT_READY_OR_CONT_SCAN : SYNC_STAT_TERM ;
235
+ }
236
+
237
+ return SYNC_STAT_ALLOWED ;
238
+ }
239
+
197
240
static int init_reset (void )
198
241
{
199
242
return 0 ;
@@ -630,7 +673,7 @@ static int isr_rx(struct lll_sync *lll, uint8_t node_type, uint8_t crc_ok, uint8
630
673
631
674
static void isr_rx_adv_sync_estab (void * param )
632
675
{
633
- enum sync_filtering_result sync_ok ;
676
+ enum sync_status sync_ok ;
634
677
struct lll_sync * lll ;
635
678
uint8_t rssi_ready ;
636
679
uint8_t trx_done ;
@@ -651,7 +694,7 @@ static void isr_rx_adv_sync_estab(void *param)
651
694
/* Initiated as allowed, crc_ok takes precended during handling of PDU
652
695
* reception in the situation.
653
696
*/
654
- sync_ok = SYNC_ALLOWED ;
697
+ sync_ok = SYNC_STAT_ALLOWED ;
655
698
}
656
699
657
700
/* Clear radio rx status and events */
@@ -671,12 +714,12 @@ static void isr_rx_adv_sync_estab(void *param)
671
714
radio_tmr_ready_save (radio_tmr_ready_get ());
672
715
673
716
/* Handle regular PDU reception if CTE type is acceptable */
674
- if (sync_ok == SYNC_ALLOWED ) {
675
- err = isr_rx (lll , NODE_RX_TYPE_SYNC , crc_ok , rssi_ready , SYNC_STAT_FOUND );
717
+ if (sync_ok == SYNC_STAT_ALLOWED ) {
718
+ err = isr_rx (lll , NODE_RX_TYPE_SYNC , crc_ok , rssi_ready , SYNC_STAT_ALLOWED );
676
719
if (err == - EBUSY ) {
677
720
return ;
678
721
}
679
- } else if (sync_ok == SYNC_SCAN_TERM ) {
722
+ } else if (sync_ok == SYNC_STAT_TERM ) {
680
723
struct node_rx_pdu * node_rx ;
681
724
682
725
/* Verify if there are free RX buffers for:
@@ -702,7 +745,11 @@ static void isr_rx_adv_sync_estab(void *param)
702
745
}
703
746
704
747
isr_rx_done :
705
- isr_rx_done_cleanup (lll , crc_ok , sync_ok == SYNC_SCAN_TERM );
748
+ #if defined(CONFIG_BT_CTLR_CTEINLINE_SUPPORT )
749
+ isr_rx_done_cleanup (lll , crc_ok , sync_ok == SYNC_STAT_TERM );
750
+ #else
751
+ isr_rx_done_cleanup (lll , crc_ok , false);
752
+ #endif /* CONFIG_BT_CTLR_CTEINLINE_SUPPORT */
706
753
}
707
754
708
755
static void isr_rx_adv_sync (void * param )
@@ -745,7 +792,8 @@ static void isr_rx_adv_sync(void *param)
745
792
* affect sychronization even when new CTE type is not allowed by sync parameters.
746
793
* Hence the SYNC_STAT_READY is set.
747
794
*/
748
- err = isr_rx (lll , NODE_RX_TYPE_SYNC_REPORT , crc_ok , rssi_ready , SYNC_STAT_READY );
795
+ err = isr_rx (lll , NODE_RX_TYPE_SYNC_REPORT , crc_ok , rssi_ready ,
796
+ SYNC_STAT_READY_OR_CONT_SCAN );
749
797
if (err == - EBUSY ) {
750
798
return ;
751
799
}
@@ -798,7 +846,8 @@ static void isr_rx_aux_chain(void *param)
798
846
* affect sychronization even when new CTE type is not allowed by sync parameters.
799
847
* Hence the SYNC_STAT_READY is set.
800
848
*/
801
- err = isr_rx (lll , NODE_RX_TYPE_EXT_AUX_REPORT , crc_ok , rssi_ready , SYNC_STAT_READY );
849
+ err = isr_rx (lll , NODE_RX_TYPE_EXT_AUX_REPORT , crc_ok , rssi_ready ,
850
+ SYNC_STAT_READY_OR_CONT_SCAN );
802
851
803
852
if (err == - EBUSY ) {
804
853
return ;
@@ -840,8 +889,9 @@ static void isr_rx_done_cleanup(struct lll_sync *lll, uint8_t crc_ok, bool sync_
840
889
e -> type = EVENT_DONE_EXTRA_TYPE_SYNC ;
841
890
e -> trx_cnt = trx_cnt ;
842
891
e -> crc_valid = crc_ok ;
892
+ #if defined(CONFIG_BT_CTLR_CTEINLINE_SUPPORT )
843
893
e -> sync_term = sync_term ;
844
-
894
+ #endif /* CONFIG_BT_CTLR_CTEINLINE_SUPPORT */
845
895
if (trx_cnt ) {
846
896
e -> drift .preamble_to_addr_us = addr_us_get (lll -> phy );
847
897
e -> drift .start_to_address_actual_us =
@@ -935,57 +985,17 @@ static uint8_t data_channel_calc(struct lll_sync *lll)
935
985
data_chan_map , data_chan_count );
936
986
}
937
987
938
- static enum sync_filtering_result sync_filtrate_by_cte_type (uint8_t cte_type_mask ,
939
- uint8_t filter_policy )
988
+ static enum sync_status sync_filtrate_by_cte_type (uint8_t cte_type_mask , uint8_t filter_policy )
940
989
{
941
- if (cte_type_mask & BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_FILTERING ) {
942
- return SYNC_ALLOWED ;
943
- }
944
-
945
- #if defined(HAS_CTEINLINE_SUPPORT )
990
+ #if defined(CONFIG_BT_CTLR_CTEINLINE_SUPPORT )
946
991
uint8_t rx_cte_time ;
947
992
uint8_t rx_cte_type ;
948
- bool cte_ok ;
949
993
950
994
rx_cte_time = nrf_radio_cte_time_get (NRF_RADIO );
951
995
rx_cte_type = nrf_radio_cte_type_get (NRF_RADIO );
952
996
953
- /* If there is no CTEInfo in advertising PDU, Radio will not parse the S0 byte and
954
- * CTESTATUS register will hold zeros only.
955
- * Zero value in CTETime field of CTESTATUS may be used to distinguish between PDU that
956
- * includes CTEInfo or not. Allowed range for CTETime is 2-20.
957
- */
958
- if (rx_cte_time == 0 && cte_type_mask & BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ONLY_CTE ) {
959
- cte_ok = false;
960
- }
961
-
962
- if (rx_cte_time > 0 ) {
963
- if (cte_type_mask & BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_CTE ) {
964
- cte_ok = false;
965
- } else {
966
- switch (rx_cte_type ) {
967
- case BT_HCI_LE_AOA_CTE :
968
- cte_ok = !(cte_type_mask &
969
- BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOA );
970
- break ;
971
- case BT_HCI_LE_AOD_CTE_1US :
972
- cte_ok = !(cte_type_mask &
973
- BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_1US );
974
- break ;
975
- case BT_HCI_LE_AOD_CTE_2US :
976
- cte_ok = !(cte_type_mask &
977
- BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_2US );
978
- break ;
979
- default :
980
- /* Unknown or forbidden CTE type */
981
- cte_ok = false;
982
- }
983
- }
984
- }
997
+ return lll_sync_cte_is_allowed (cte_type_mask , filter_policy , rx_cte_time , rx_cte_type );
985
998
986
- if (!cte_ok ) {
987
- return filter_policy ? SYNC_SCAN_CONTINUE : SYNC_SCAN_TERM ;
988
- }
989
- #endif /* HAS_CTEINLINE_SUPPORT */
990
- return SYNC_ALLOWED ;
999
+ #endif /* CONFIG_BT_CTLR_CTEINLINE_SUPPORT */
1000
+ return SYNC_STAT_ALLOWED ;
991
1001
}
0 commit comments