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

No scan response using latest version of pc-ble-driver v6.1.1 on nrf52832

We are using the latest pc-ble-driver with SoftDevice v6.1.1 and latest connectivity firmware on an nrf52832 (s132) which is connected via usb-uart.

We were previously using v5, but had some issues with setting TX power and so have updated to v6.1.1 which resolved that issue. But we are now no longer receiving any scan responses.

From what I've read so far, this might have something to do with the change in the API requiring the scan to be triggered each time a BLE_GAP_EVT_ADV_REPORT event occurs, and the connection being too slow to catch the scan responses. 

The parameters used for starting the scan are:

#define BLE_SCAN_EXTENDED 1

#define SCAN_INTERVAL 0x00A0 
#define SCAN_WINDOW 0x0050

static ble_gap_scan_params_t ble_scan_params = {
    #if NRF_SD_BLE_API >= 6
    .extended = BLE_SCAN_EXTENDED,
    .report_incomplete_evts = 0,
    #endif
    
    .active = 1,

    #if NRF_SD_BLE_API >= 6
    .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
    .scan_phys = BLE_GAP_PHY_1MBPS,
    #else
    .use_whitelist = 0, // TODO see if we can use this to pre-filter on service-uuid.
    .adv_dir_report = 0,
    #endif

    .interval = SCAN_INTERVAL, /**< Scan interval between 0x0004 and 0x4000 in 0.625 ms units (2.5 ms to 10.24 s). */
    .window = SCAN_WINDOW, /**< Scan window between 0x0004 and 0x4000 in 0.625 ms units (2.5 ms to 10.24 s). */
    .timeout = BLE_GAP_SCAN_TIMEOUT_UNLIMITED, /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */

    #if NRF_SD_BLE_API >= 6
    .channel_mask = { 0, 0, 0, 0, 0 },
    #endif
};

#if BLE_SCAN_EXTENDED == 1
static uint8_t m_scan_buffer_data[BLE_GAP_SCAN_BUFFER_EXTENDED_MAX];
#else
static uint8_t m_scan_buffer_data[BLE_GAP_SCAN_BUFFER_MAX];
#endif

static ble_data_t m_scan_buffer =
{
    m_scan_buffer_data,
#if BLE_SCAN_EXTENDED == 1
    BLE_GAP_SCAN_BUFFER_EXTENDED_MAX
#else
    BLE_GAP_SCAN_BUFFER_MAX
#endif
};

As you can see active is set to 1, which from my understanding should allow for scan requests to be sent automatically and scan responses coming in as BLE_GAP_EVT_ADV_REPORT events. (We've also tried with both extended being set to 1 and 0.) The scan is then started using:

uint32_t error_code = sd_ble_gap_scan_start(adapter, &ble_scan_params, &m_scan_buffer);

And continued in the callback when receiving

static void ble_evt_dispatch(adapter_t* adapter, ble_evt_t* p_ble_evt)
{
#if NRF_SD_BLE_API >= 6    
    if(p_ble_evt->header.evt_id == BLE_GAP_EVT_ADV_REPORT)
    {
        sd_ble_gap_scan_start(adapter, nullptr, &m_scan_buffer);
        LOG_DEBUG("Found beacon - (%d, %d).", p_ble_evt->evt.gap_evt.params.adv_report.type.scannable, p_ble_evt->evt.gap_evt.params.adv_report.type.scan_response);
    }
#endif

    ...
}

This pseudo-code only logs Found beacon - (1, 0) and sometimes Found beacon - (0, 0) - but I almost never see Found beacon - (1, 1). I haven't measured but let's say only once every 10000 detections.

Since I mostly see devices which are scannable, I would expect to see a lot more scan responses, I also have several devices running for which I know they are able to send scan responses (tested using iOS app). 

I came across this post: https://devzone.nordicsemi.com/f/nordic-q-a/50082/pc-ble-driver-no-scan-response which seems to be a similar issue. But since that post is from over a year ago I was hoping there might be a solution for this.

The scan responses are a vital part for an application we are developing, but I have not been able to find a solution to be able to get the scan responses.

Is there anything basic we are missing which is preventing the scan responses to come in through the callback? Is there any way to manually send a scan request and get the response for that?

  • Sorry for the delayed reply, it took a while to get to this. Unfortunately without good results.

    Depending on where I try to start the scan (tried with different calls) the result was either the scan not being resumed at all or the pc-ble-driver outputting the error:

    Failed to decode event, error code is 14/0xe

    Eventually I even tried to just add the application as an observer and start the scan from that callback by adding:

    static uint8_t m_scan_buffer_data[31];
    static ble_data_t m_scan_buffer = { m_scan_buffer_data, 31 };
    
    void test_ble_event_handle(ble_evt_t const * p_ble_evt, void * p_context)
    {
        sd_ble_gap_scan_start(nullptr, &m_scan_buffer);
    }
    
    int main(void)
    {
        ....
        NRF_SDH_BLE_OBSERVER(m_ble_observer, 0, test_ble_event_handle, NULL);
        
        ....
    }

    But unfortunately that yielded the same "Failed to decode event" error. 

    Any (other) tips or suggestions? 

    Sidenote;

    We were good to go with pc-ble-driver v5, were we don't have to restart the scan after each event - but we are now running in to the fact that does not appear to cooperate with the DFU examples given in that version of the SDK. 

  • Hello,

    I am sorry, but I am not sure exactly how to fix this. It is not trivial to manipulate the connectivity firmware, and as I mentioned, it is not certain that this would work at all. Perhaps it messes up the internal state machine and message flow.

     

    ttveldhuis said:
    We were good to go with pc-ble-driver v5, were we don't have to restart the scan after each event - but we are now running in to the fact that does not appear to cooperate with the DFU examples given in that version of the SDK. 

     Perhaps it would be either to either fix this, or put the important data in the advertising packet instead of the scan response?

    Why is the DFU not working? What observations do you see?

    BR,
    Edvin.

Related