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

Only receiving a single BLE_GAP_EVT_ADV_REPORT

Hello,

I want to add central-role features to my peripheral firmware. I've already managed to get this work. The strange thing, I only get one BLE_GAP_EVT_ADV_REPORT. So the firmeware receives one advertisement and then it stops receiving.

The documentation says that it stops/pauses scanning when an ADV_REPORT is received and BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA is not set. But I'm not even in extended mode.

I'm using a nRF52832-DK and the SDK is 15.3.0 with Softdevice 6.1.1. Here is my code:

Init and start:

void scanning_init(nrf_ble_scan_t scan) 
{
    ret_code_t err_code;

    m_scan = scan;

    ble_gap_scan_params_t scan_params;
    memset(&scan_params, 0, sizeof(scan_params)); 
    scan_params.active    = 0; 
    scan_params.interval  = 160;
    scan_params.window    = 80;
    scan_params.timeout   = BLE_GAP_SCAN_TIMEOUT_UNLIMITED;
    scan_params.scan_phys = BLE_GAP_PHY_1MBPS;
    scan_params.extended  = 0;

    nrf_ble_scan_init_t init_scan; 
    memset(&init_scan, 0, sizeof(init_scan)); 
    
    init_scan.connect_if_match = false,
    init_scan.p_conn_param = NULL,
    init_scan.conn_cfg_tag = NULL,
    init_scan.p_scan_param = &scan_params,


    err_code = nrf_ble_scan_init(&m_scan, &init_scan, evt_hdler);
    APP_ERROR_CHECK(err_code);
}

void scanning_start() 
{
    ret_code_t err_code;
    err_code = nrf_ble_scan_start(&m_scan);
    APP_ERROR_CHECK(err_code);
}

void on_ble_central_evt(ble_evt_t const * p_ble_evt)
{
    ret_code_t err_code;
    // For readability
    ble_gap_evt_t const        * p_gap_evt   = &p_ble_evt->evt.gap_evt;
    ble_gap_addr_t const * const p_peer_addr = &p_gap_evt->params.adv_report.peer_addr;


    switch (p_ble_evt->header.evt_id)
    {
        ...

        case BLE_GAP_EVT_ADV_REPORT:
        {
            NRF_LOG_INFO("Advertisement received");
        }
        break; // BLE_GAP_ADV_REPORT

        ...

        default:
            // No implementation needed.
            break;
    }
}

I can see "Advertisement received" in the log, but only once.

Any ideas? Thanks for your help in advance!

Parents
  • This is because the scanner has paused when you get the advertising report and you need to call sd_ble_gap_scan_start for it continue as it mentioned in the linked documentation.

    The scanner will automatically stop in the following cases:
    sd_ble_gap_scan_stop is called.
    sd_ble_gap_connect is called.
    A BLE_GAP_EVT_TIMEOUT with source set to BLE_GAP_TIMEOUT_SRC_SCAN is received.
    When a BLE_GAP_EVT_ADV_REPORT event is received and ble_gap_adv_report_type_t::status is not set to BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. In this case scanning is only paused to let the application access received data. The application must call this function to continue scanning, or call sd_ble_gap_scan_stop to stop scanning.
    If a BLE_GAP_EVT_ADV_REPORT event is received with ble_gap_adv_report_type_t::status set to BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, the scanner will continue scanning, and the application will receive more reports from this advertising event. The following reports will include the old and new received data.
    

  • I don't understand why it pauses. I don't use extended mode, so I don't get incomplete data. 

  • Please download the softdevice documents here

    In the migration guide Section s132_nrf52_6.0.0-> Updated scanner API

    When the application receives a , it must now resume scanning by calling sd_ble_gap_scan_start

    So this functionality was changed in S132_6.0 and the later softdevices inherit this new functionality. 

    This means that when you get ADV_REPORT, the app must now resume the scanner explicitly by calling sd_ble_gap_scan_start.

    In the older versions, the scanner was continuously scanning and our benchmarks showed that a lot of scanner slot was wasted before even the application had a chance to process the adv report. 

Reply
  • Please download the softdevice documents here

    In the migration guide Section s132_nrf52_6.0.0-> Updated scanner API

    When the application receives a , it must now resume scanning by calling sd_ble_gap_scan_start

    So this functionality was changed in S132_6.0 and the later softdevices inherit this new functionality. 

    This means that when you get ADV_REPORT, the app must now resume the scanner explicitly by calling sd_ble_gap_scan_start.

    In the older versions, the scanner was continuously scanning and our benchmarks showed that a lot of scanner slot was wasted before even the application had a chance to process the adv report. 

Children
No Data
Related