@@ -531,6 +531,11 @@ static inline void isr_radio_state_tx(void)
531
531
}
532
532
533
533
radio_tmr_end_capture ();
534
+
535
+ #if defined(CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_RSSI )
536
+ radio_rssi_measure ();
537
+ #endif /* CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_RSSI */
538
+
534
539
break ;
535
540
536
541
case ROLE_OBS :
@@ -578,6 +583,37 @@ static inline void isr_radio_state_tx(void)
578
583
}
579
584
}
580
585
586
+ #if defined(CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_NOTIFY )
587
+ static u32_t isr_rx_adv_sr_report (struct pdu_adv * pdu_adv_rx , u8_t rssi_ready )
588
+ {
589
+ struct radio_pdu_node_rx * radio_pdu_node_rx ;
590
+ struct pdu_adv * pdu_adv ;
591
+ u8_t pdu_len ;
592
+
593
+ radio_pdu_node_rx = packet_rx_reserve_get (3 );
594
+ if (radio_pdu_node_rx == 0 ) {
595
+ return 1 ;
596
+ }
597
+
598
+ /* Prepare the report (scan req) */
599
+ radio_pdu_node_rx -> hdr .handle = 0xffff ;
600
+ radio_pdu_node_rx -> hdr .type = NODE_RX_TYPE_SCAN_REQ ;
601
+
602
+ /* Make a copy of PDU into Rx node (as the received PDU is in the
603
+ * scratch buffer), and save the RSSI value.
604
+ */
605
+ pdu_adv = (struct pdu_adv * )radio_pdu_node_rx -> pdu_data ;
606
+ pdu_len = offsetof(struct pdu_adv , payload ) + pdu_adv_rx -> len ;
607
+ memcpy (pdu_adv , pdu_adv_rx , pdu_len );
608
+ ((u8_t * )pdu_adv )[pdu_len ] =
609
+ (rssi_ready ) ? (radio_rssi_get () & 0x7f ) : 0x7f ;
610
+
611
+ packet_rx_enqueue ();
612
+
613
+ return 0 ;
614
+ }
615
+ #endif /* CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_NOTIFY */
616
+
581
617
static inline u32_t isr_rx_adv (u8_t devmatch_ok , u8_t irkmatch_ok ,
582
618
u8_t irkmatch_id , u8_t rssi_ready )
583
619
{
@@ -591,13 +627,22 @@ static inline u32_t isr_rx_adv(u8_t devmatch_ok, u8_t irkmatch_ok,
591
627
(((_radio .advertiser .filter_policy & 0x01 ) == 0 ) ||
592
628
(devmatch_ok ) || (irkmatch_ok )) &&
593
629
(1 /** @todo own addr match check */ )) {
630
+
631
+ #if defined(CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_NOTIFY )
632
+ u32_t err ;
633
+
634
+ /* Generate the scan request event */
635
+ err = isr_rx_adv_sr_report (pdu_adv , rssi_ready );
636
+ if (err ) {
637
+ /* Scan Response will not be transmitted */
638
+ return err ;
639
+ }
640
+ #endif /* CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_NOTIFY */
641
+
594
642
_radio .state = STATE_CLOSE ;
595
643
596
644
radio_switch_complete_and_disable ();
597
645
598
- /* TODO use rssi_ready to generate proprietary scan_req event */
599
- ARG_UNUSED (rssi_ready );
600
-
601
646
/* use the latest scan data, if any */
602
647
if (_radio .advertiser .scan_data .first != _radio .
603
648
advertiser .scan_data .last ) {
@@ -829,6 +874,31 @@ static inline u32_t isr_rx_adv(u8_t devmatch_ok, u8_t irkmatch_ok,
829
874
return 1 ;
830
875
}
831
876
877
+ static u32_t isr_rx_obs_report (u8_t rssi_ready )
878
+ {
879
+ struct radio_pdu_node_rx * radio_pdu_node_rx ;
880
+ struct pdu_adv * pdu_adv_rx ;
881
+
882
+ radio_pdu_node_rx = packet_rx_reserve_get (3 );
883
+ if (radio_pdu_node_rx == 0 ) {
884
+ return 1 ;
885
+ }
886
+
887
+ /* Prepare the report (adv or scan resp) */
888
+ radio_pdu_node_rx -> hdr .handle = 0xffff ;
889
+ radio_pdu_node_rx -> hdr .type = NODE_RX_TYPE_REPORT ;
890
+
891
+ /* save the RSSI value */
892
+ pdu_adv_rx = (struct pdu_adv * )radio_pdu_node_rx -> pdu_data ;
893
+ ((u8_t * )pdu_adv_rx )[offsetof(struct pdu_adv , payload ) +
894
+ pdu_adv_rx -> len ] =
895
+ (rssi_ready ) ? (radio_rssi_get () & 0x7f ) : 0x7f ;
896
+
897
+ packet_rx_enqueue ();
898
+
899
+ return 0 ;
900
+ }
901
+
832
902
static inline u32_t isr_rx_obs (u8_t irkmatch_id , u8_t rssi_ready )
833
903
{
834
904
struct pdu_adv * pdu_adv_rx ;
@@ -1084,23 +1154,14 @@ static inline u32_t isr_rx_obs(u8_t irkmatch_id, u8_t rssi_ready)
1084
1154
(pdu_adv_rx -> type == PDU_ADV_TYPE_SCAN_IND )) &&
1085
1155
(_radio .observer .scan_type != 0 ) &&
1086
1156
(_radio .observer .conn == 0 )) {
1087
- struct radio_pdu_node_rx * radio_pdu_node_rx ;
1088
1157
struct pdu_adv * pdu_adv_tx ;
1089
-
1090
- radio_pdu_node_rx = packet_rx_reserve_get (3 );
1091
- if (radio_pdu_node_rx == 0 ) {
1092
- return 1 ;
1093
- }
1094
-
1095
- /* save the RSSI value */
1096
- ((u8_t * )pdu_adv_rx )[offsetof(struct pdu_adv , payload ) +
1097
- pdu_adv_rx -> len ] =
1098
- (rssi_ready ) ? (radio_rssi_get () & 0x7F ) : 0x7F ;
1158
+ u32_t err ;
1099
1159
1100
1160
/* save the adv packet */
1101
- radio_pdu_node_rx -> hdr .handle = 0xffff ;
1102
- radio_pdu_node_rx -> hdr .type = NODE_RX_TYPE_REPORT ;
1103
- packet_rx_enqueue ();
1161
+ err = isr_rx_obs_report (rssi_ready );
1162
+ if (err ) {
1163
+ return err ;
1164
+ }
1104
1165
1105
1166
/* prepare the scan request packet */
1106
1167
pdu_adv_tx = (struct pdu_adv * )radio_pkt_scratch_get ();
@@ -1143,22 +1204,13 @@ static inline u32_t isr_rx_obs(u8_t irkmatch_id, u8_t rssi_ready)
1143
1204
((pdu_adv_rx -> type == PDU_ADV_TYPE_SCAN_RSP ) &&
1144
1205
(_radio .observer .scan_state != 0 ))) &&
1145
1206
(pdu_adv_rx -> len != 0 ) && (!_radio .observer .conn )) {
1146
- struct radio_pdu_node_rx * radio_pdu_node_rx ;
1147
-
1148
- radio_pdu_node_rx = packet_rx_reserve_get (3 );
1149
- if (radio_pdu_node_rx == 0 ) {
1150
- return 1 ;
1151
- }
1152
-
1153
- /* save the RSSI value */
1154
- ((u8_t * )pdu_adv_rx )[offsetof(struct pdu_adv , payload ) +
1155
- pdu_adv_rx -> len ] =
1156
- (rssi_ready ) ? (radio_rssi_get () & 0x7f ) : 0x7f ;
1207
+ u32_t err ;
1157
1208
1158
1209
/* save the scan response packet */
1159
- radio_pdu_node_rx -> hdr .handle = 0xffff ;
1160
- radio_pdu_node_rx -> hdr .type = NODE_RX_TYPE_REPORT ;
1161
- packet_rx_enqueue ();
1210
+ err = isr_rx_obs_report (rssi_ready );
1211
+ if (err ) {
1212
+ return err ;
1213
+ }
1162
1214
}
1163
1215
/* invalid PDU */
1164
1216
else {
@@ -8196,6 +8248,11 @@ void radio_rx_dequeue(void)
8196
8248
switch (radio_pdu_node_rx -> hdr .type ) {
8197
8249
case NODE_RX_TYPE_DC_PDU :
8198
8250
case NODE_RX_TYPE_REPORT :
8251
+
8252
+ #if defined(CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_NOTIFY )
8253
+ case NODE_RX_TYPE_SCAN_REQ :
8254
+ #endif /* CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_NOTIFY */
8255
+
8199
8256
case NODE_RX_TYPE_CONNECTION :
8200
8257
case NODE_RX_TYPE_CONN_UPDATE :
8201
8258
case NODE_RX_TYPE_ENC_REFRESH :
@@ -8250,6 +8307,11 @@ void radio_rx_mem_release(struct radio_pdu_node_rx **radio_pdu_node_rx)
8250
8307
switch (_radio_pdu_node_rx_free -> hdr .type ) {
8251
8308
case NODE_RX_TYPE_DC_PDU :
8252
8309
case NODE_RX_TYPE_REPORT :
8310
+
8311
+ #if defined(CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_NOTIFY )
8312
+ case NODE_RX_TYPE_SCAN_REQ :
8313
+ #endif /* CONFIG_BLUETOOTH_CONTROLLER_SCAN_REQ_NOTIFY */
8314
+
8253
8315
case NODE_RX_TYPE_CONNECTION :
8254
8316
case NODE_RX_TYPE_CONN_UPDATE :
8255
8317
case NODE_RX_TYPE_ENC_REFRESH :
0 commit comments