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

Function to collate data from Advertisement and Scan Response packets?

If I understand correctly, a peripheral can distribute data such as UUID, device name, flags, appearance etc. between advertisement and scan response packets. To gather all the data provided by an advertising peripheral it is necessary to receive both packets and then extract and store this information.

Before I write my own function to do this, are there any existing functions (or examples) in the SDK to perform the task of collating data from advertisement and scan response packets?

Parents
  • Hi Chris,

    When scanning for devices using the S120 or S130, the SoftDevice provides an advertising report as a callback. I'm not 100% sure, but I believe scanning with automatically request a scan response from the device. If it provides one, then the scan response data will be provided as an additional advertising report event with its scan_rsp bit set to 1 indicating scan response data. You can check out this structure here: infocenter.nordicsemi.com/.../structble__gap__evt__adv__report__t.html

    I think you'll have to write your own structure to contain these bits of information but it could be something simple such as:

    struct advertising_data_s {
        uint8_t adv_data[32];
        uint8_t scn_data[32];
    }
    

    Then you can copy the data into the structure based on that scan_rsp parameter of the event and process it later.

    Hope this helps,

    Eric

  • AFAIK, there is only a function to encode advertising data in ble_advdata.c. The processing of reported data will have to be handled by your firmware. The advertising report does provide the MAC address though it could be a random private address so you'll need to check the address type for the MAC. The advertising packet has a very specific structure specified in the BT Core Specification but it is, annoyingly, spread across 3 different documents... I'd recommend looking at how the ble_advdata.c module encodes advertising data to get some sense of how to decode it. You also might check out the central examples to see how they process incoming advertising packets.

Reply
  • AFAIK, there is only a function to encode advertising data in ble_advdata.c. The processing of reported data will have to be handled by your firmware. The advertising report does provide the MAC address though it could be a random private address so you'll need to check the address type for the MAC. The advertising packet has a very specific structure specified in the BT Core Specification but it is, annoyingly, spread across 3 different documents... I'd recommend looking at how the ble_advdata.c module encodes advertising data to get some sense of how to decode it. You also might check out the central examples to see how they process incoming advertising packets.

Children
No Data
Related