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.

Parents
  • 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

Reply
  • 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

Children
Related