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

Can you use scan response as an acknowledgment on peripheral device?

Can a peripheral device know when the client made a scan response request? I want to use scan response as a form of acknowledgment so the peripheral device knows that the client got the payload data in the advertising and scan response packets.

I am using the nRF5 SDK and want to know if there is any flag or variable that would change on the peripheral device when the scan response request is made from the client.

  • There are 3 aspects:

    1. Yes, APP on nRF5x on top of Soft Device running GAP Peripheral role will get event when there is active scanning (See BLE_GAP_EVT_SCAN_REQ_REPORT and ble_gap_evt_scan_req_report_t in S132 Soft Device API documentation). As you see there is Scanner's MAC address and RSSI visible to GAP Peripheral app.
    2. However you won't get any callback before SCAN_RSP packet is issued by the stack so you cannot change SCAN_RSP packet structure based on Scanner's MAC or other parameter, that must be set before Adv. interval occurs.
    3. In general Advertising and Scanning are not suited for acknowledged link and unless the point 1 above solves your problem then you would need to choose some open source stack (e.g. Zephyr or Mynewt projects) and try to manage SCAN_RSP data modification within these few microseconds you have between SCAN_REQ and SCAN_RSP. But that seems close to impossible.

    Cheers Jan

  • So I just wanted to clarify something. I am working with this BLE advertising tutorial and I got to the end where I add the scan response data. What I want to do is use the scan response as an ACK from the central device to the peripheral device. Using your answer, I attempted to add a case to the on_ble_evt() function in main.c, linked here but I found that I was never entering that case.

    To make it absolutely clear what I am trying to do, I want the peripheral device to raise a flag and change the content of the next advertising packet in the next advertising interval when it sees the scan response request. In this way, I plan on iterating through my payload data while ensuring that the central device does receive my payload data in the advertising packet.

    I would really appreciate any and all advice you have! I am very confused. Thank you!

  • You doesn't seem to be so much confused. Your idea make sense, you will not get full reliability or bi-directional link (that is possible only through connection) but what you propose is basically simulating what BLE is doing on LL layer during connection. I would say that using connection should be always preferred but you might achieve better power consumption with what you describe (definitely lower bandwidth and only one-way data transfer and only simple ACK in opposite direction).

    To your problem with BLE_GAP_EVT_SCAN_REQ_REPORT: you need to enable reporting from Soft Device first through SV (SD API) call. See this description(but make sure you use correct construction depending on SD type and version you are using).

Related