This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Event detection for SCAN_REQ

Hello. I'm sorry for my bad English.
I'm currently working on a development using nRF52840 based on ble_app_blinky, which is an example of s140 and peripheral. So, I want to receive SCAN_REQ packet as an event from the demand of application. (I don't change anything about SCAN_REF).
I have consulted other questions posted in the past and the API reference, but I don't understand it.
(1) Can I receive SCAN_REQ as an event in the first place?
(2) If it is possible, please tell me the specific code, and it would be better if I can check it by outputting to NRF_LOG.

Best regards.

  • Hello,

    (1) Can I receive SCAN_REQ as an event in the first place?
    (2) If it is possible, please tell me the specific code, and it would be better if I can check it by outputting to NRF_LOG.

    Yes, you may use the BLE_GAP_EVT_SCAN_REQ_REPORT event for this.
    Please note that this event is generated whenever the device receives a scan request, which can be very frequently in a environment with a lot of BLE Centrals actively scanning. You may therefore need to filter the incoming requests on RSSI or peer address before proceeding with the application logic.
    This event will by default be forwarded to your ble_evt_handler in the blinky app if you are advertising as scannable, along with events such as BLE_GAP_EVT_CONNECTED etc.

    Best regards,
    Karl

  • Thanks for the reply ...But I haven't done it yet.
    I'm trying to use BLE_GAP_EVT_SCAN_REQ_REPORT in ble_evt_handler and use a case statement to output a simple statement to NRF_LOG_INFO. But it is not output.The advertised packets are scannable, and the peer address and RSSI of SCAN_REQ can be anything. I checked that SCAN_REQ is sent to peripheral and returns SCAN_RSP by using sniffer, so It may be that the event is not processed.

  • I finally did it, I just needed to enable scan request notifications.
    Thank you very much.

  • Hello again, noboru

    noboru said:
    I just needed to enable scan request notifications.

    My apologies - I should of course also have mentioned that you also need to make sure that scan_req_notification is set during the initialization of the advertisement.

    I am happy to hear that you were able to make this work with the BLE_GAP_EVT_SCAN_REQ_REPORT event. Great!

    Please do not hesitate to open another ticket if you should encounter any other issues or questions in the future.

    Good luck with your development!

    Best regards,
    Karl

Related