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

Parsing scan response with SDK 15.3

Hi everybody,

I am using nRF52832/40 with SDK 15.3 and softdevices S132/S140 v6.1.1.

One of my devices is performing active scanning, therefore sending scan requests, and the other one is replying with scan responses.

I can see clearly that this is happeing correctly using your BLE sniffer for Wireshark (btw, great tool!).

I am able to set the scan request and parse it on the peripheral side.

I am able to set the scan response, but I'm not able to parse it on the central side, and this is what I'd like to do. 

This is a snippet from my code:

static void on_adv_report(ble_gap_evt_adv_report_t const * p_adv_report)
{
    if (p_adv_report->type.scan_response)
    {
        // Parse scan response packet here

        led_blink(2,1,200);  //This is just for debugging
    }

    else
    {
        // Parse advertising packet here
    }
}

It seems like I'm never entering the first if, where scan response packets should be handled, while I'm always entering the second one (for regular advertising packets).

What am I doing wrong?


Thank you very much!

  • Hi Lorenzo, 

    Could you post your full code ? From where did you call on_adv_report() ? 
    Note that the scan request packet is treated separately from the advertising packet. So if you use any filter, for example UUID filter for your scanner and if the scan request doesn't have this UUID it will not match to the scanner filter and will be filtered out. So there is no link between the main advertising packet and the scan response packet. So most likely the filter in the scan module would remove the packet due to no match. Please try testing again without any filter. 

  • Hi Hung, 

    thanks for your answer. Unfortunately posting the full code is not possible at the moment since I'm working on top of a bigger project, but of course I can extract the necessary parts that are needed. Function on_adv_report() is called from the default ble_evt_handler():

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        ...
    
        case BLE_GAP_EVT_ADV_REPORT:
        
            on_adv_report(&p_gap_evt->params.adv_report);
        
        break;
        
        ...
    }

    About filters, if you are referring to the ones that can be set from the scan configuration, I am not using any:


    /**@brief Scan parameters requested for scanning and connection. */
    static ble_gap_scan_params_t m_scan_params = 
    {
        .active        = true, 
        .interval      = INITIAL_SCAN_INTERVAL,
        .window        = INITIAL_SCAN_WINDOW,
        .timeout       = SCAN_DURATION,
        .scan_phys     = BLE_GAP_PHY_1MBPS,
        .extended      = 0,
        .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
    };

    While I was replying to you, I've tried setting extended to true, but this didn't change the result.

    Is there any other configuration that I'm missing?

    Please let me know if I can help you by reproducing the situation in a lighter, sharable project (that would take me some time though Slight smile).

    Thank you and best regards!

  • Hi , 
    I would suggest to do a quick test in one of the central example we have. You can just try to remove any filter we have and print out any advertising packet you receive. I did a quick test here and I can see many packets with scan_response bit = 1. 

  • Hi Lorenzo, 
    I added this to the ble_app_multiplink_central: 

    And I can see that it can catch some scan response packets: 

    (I changed connect if match = false)

    I attached the main.c file (I tested on SDK v15.2 but I don't think it would be much different to SDK v15.3)

    ble_app_multilink_central_pca10056_s140.zip

  • Hi Hung, 

    thanks. I removed the previous answer because I noticed that the modified ble_app_multilink_central was correctly showing scan responses.

    Now I have to understand why I cannot catch them in my project. 

    Thank you for your help! I'll keep you posted.

Related