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

  • Yes, as EricS says, you could take a look at the central examples, there is a simple (adv_report_parse) parser used to determine what device to connect to or not. This is in on_ble_evt -> case BLE_GAP_EVT_ADV_REPORT.

    Note that you have to set the active bit when scanning to do active scanning (ask for scan response packet).

Reply Children
No Data
Related