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

scanning with whitelist stops after one message received

I'm using scannig with whitelist on nRF52840 Dongle SDK V15.2 (usbd_ble_uart_freertos example)

when BLE_GAP_EVT_ADV_REPORT is called scanning stops, So it can scan just one message .

so each time i restart scanning and resetting the whitelist like is shown :

...
...
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    uint32_t err_code;
    ret_code_t ret;
    ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
    ble_gap_evt_adv_report_t const * p_adv_report = &p_gap_evt->params.adv_report;

    switch (p_ble_evt->header.evt_id)
    {   
         case BLE_GAP_EVT_ADV_REPORT:
            NRF_LOG_INFO("____________BLE_GAP_EVT_ADV_REPORT__________");
            scan_start();
            
    ...
...
static void scan_evt_handler(scan_evt_t const * p_scan_evt)
{
    ret_code_t err_code;
    ble_gap_evt_adv_report_t const * p_adv_report = p_scan_evt->params.filter_match.p_adv_report;
    switch(p_scan_evt->scan_evt_id)
    {
        case NRF_BLE_SCAN_EVT_WHITELIST_REQUEST:
         {
              NRF_LOG_INFO("NRF_BLE_SCAN_EVT_WHITELIST_REQUEST");
              ret_code_t   ret;
              //ret = nrf_ble_scan_params_set(&m_scan, &new_scan_param);
              ret = sd_ble_gap_whitelist_set(whitelistAdrss, 1);
              APP_ERROR_CHECK(ret);

         }break;
    ...
...

 is that a correct solution ? Does it negatively affect the scanning ??

Parents
  • Hello,

    By default, the scan is stopped every time you get an advertisement. However, the scanning module typically restarts the scanning in the BLE_GAP_EVT_ADV_REPORT in nrf_ble_scan.c. Did you do any changes in that file? It should call nrf_ble_scan_on_adv_report(); which will call sd_ble_gap_scan_start(); in the end (unless it actually decides to connect to the device.

    So did you change anything in nrf_ble_scan.c? Alternatively, can you see what sd_ble_gap_scan_start() returns in nrf_ble_scan.c?

    Best regards,

    Edvin

  • i have added BLE_GAP_EVT_ADV_REPORT case to ble_evt_handler() function, it doesn't existe in the original code .

    do i need to add nrf_ble_scan_on_adv_report();  instead of scan_start(); ??

  • If you add the BLE_GAP_EVT_ADV_REPORT case in ble_evt_handler() it will generate an interrupt in main.c as well as in nrf_ble_scan.c.

    What does your ble_evt_handler's BLE_GAP_EVT_ADV_REPORT case look like? Do you do any function calls in this event?

    Did you do any changes to nrf_ble_scan.c?

    Best regards,

    Edvin

  • in BLE_GAP_EVT_ADV_REPORT case i just printing message mac adresse and rssi ,as shown

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        uint32_t err_code;
        ret_code_t ret;
        ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
        ble_gap_evt_adv_report_t const * p_adv_report = &p_gap_evt->params.adv_report;
    
        switch (p_ble_evt->header.evt_id)
        {   
             case BLE_GAP_EVT_ADV_REPORT:
    //          NRF_LOG_INFO("____________BLE_GAP_EVT_ADV_REPORT__________");
                scan_start();
                NRF_LOG_INFO("adresse= %02x%02x%02x%02x%02x%02x",
                                           p_adv_report->peer_addr.addr[0],
                                           p_adv_report->peer_addr.addr[1],
                                           p_adv_report->peer_addr.addr[2],
                                           p_adv_report->peer_addr.addr[3],
                                           p_adv_report->peer_addr.addr[4],
                                           p_adv_report->peer_addr.addr[5]
                                           );
                int8_t RSSI = p_adv_report->rssi ;
                NRF_LOG_INFO("Rssi =%d ",RSSI);
            break ;
        ...
    ...

    and i didn't change anything in nrf_ble_scan.c

  • What happens if you remove scan_start()? Does the scan-start-function in nrf_ble_scan.c -> case BLE_GAP_EVT_ADV_REPORT get called? If not, why not? Does the function return before it is hit?

    Best regards,

    Edvin

Reply Children
No Data
Related