Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF5 SDK 15 adv_report

I see that a lot of things are changed in SDK 15 about BLE. I wonder if it is because of Bluetooth5.

But, the problem I am having is that I cannot find an example that shows me the structure of adv_report and how to read it. I was referring to ble_app_uart_c in SDK 14. I understand that now Nordic tries to cover the lower level with nrf_ble_scan.c. But my application actually needs to parse the beacon data. So I am still using the APIs in SDK 14 and trying to find them in SDK 15.

Right now, I have managed to initialize the ble stack and send beacons with the right payload(this is verified by the previous device). But I don't know how to scan and get the content. I have tried to HEX_DUMP every byte got from BLE_GAP_EVT_ADV_REPORT event. But I think it only contains part of the real beacons around me.

P.S.: I notice a strange thing in the nrf_ble_scan.c. It resumes scanning after parsing the adv_report like this: Should I do this if I am not using my own implementation instead of nrf_ble_scan.c

// Resume the scanning.
    UNUSED_RETURN_VALUE(sd_ble_gap_scan_start(NULL, &p_scan_ctx->scan_buffer));

Parents
  • Hi,

    I recommend you refer to the ble_app_hrc_c example to see how you can use the ble_advdata_* functions to parse the advertising data. If you want to do it without any helper functions you can access the full raw advertising data from ble_gap_evt_adv_report_t::data.p_data (length is ble_gap_evt_adv_report_t::data.len) when you get the BLE_GAP_EVT_ADV_REPORT event.

  • This is how I handle the ble_evt. I dumped all the adv_report it got but could not find the data I send by another device running SDK14. I am sure that the advertising of the SDK14 is correct.

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_ADV_REPORT:
            {
                ble_gap_evt_adv_report_t const * p_adv_report = &p_gap_evt->params.adv_report;
    			NRF_LOG_DEBUG("In parse"); 
            	NRF_LOG_DEBUG("%d", p_adv_report->data.len);
            	NRF_LOG_HEXDUMP_DEBUG(p_adv_report->data.p_data, p_adv_report->data.len);
            }break; // BLE_GAP_EVT_ADV_REPORT
    
            default:
                break;
        }
    }

    This is how I initialize the scan module.

    static void blend_ble_stack_init(void )
    {
        ret_code_t err_code;
    
        err_code = nrf_sdh_enable_request();
        APP_ERROR_CHECK(err_code);
    
        // Configure the BLE stack using the default settings.
        // Fetch the start address of the application RAM.
        uint32_t ram_start = 0;
        err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
        APP_ERROR_CHECK(err_code);
    
        // Enable BLE stack.
        err_code = nrf_sdh_ble_enable(&ram_start);
        APP_ERROR_CHECK(err_code);
    
        // Register a handler for BLE events.
        NRF_SDH_BLE_OBSERVER(_blend_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
    	_blend_scan_instance.scan_buffer.p_data = _blend_scan_instance.scan_buffer_data;
    	_blend_scan_instance.scan_buffer.len = NRF_BLE_SCAN_BUFFER;
    }

    Can you maybe check for me where I did wrong? Because this is the exact way I did in SDK14 and that was perfectly fine. I am not sure what has changed about the softdevice API during the upgrade.

Reply
  • This is how I handle the ble_evt. I dumped all the adv_report it got but could not find the data I send by another device running SDK14. I am sure that the advertising of the SDK14 is correct.

    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
    
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_ADV_REPORT:
            {
                ble_gap_evt_adv_report_t const * p_adv_report = &p_gap_evt->params.adv_report;
    			NRF_LOG_DEBUG("In parse"); 
            	NRF_LOG_DEBUG("%d", p_adv_report->data.len);
            	NRF_LOG_HEXDUMP_DEBUG(p_adv_report->data.p_data, p_adv_report->data.len);
            }break; // BLE_GAP_EVT_ADV_REPORT
    
            default:
                break;
        }
    }

    This is how I initialize the scan module.

    static void blend_ble_stack_init(void )
    {
        ret_code_t err_code;
    
        err_code = nrf_sdh_enable_request();
        APP_ERROR_CHECK(err_code);
    
        // Configure the BLE stack using the default settings.
        // Fetch the start address of the application RAM.
        uint32_t ram_start = 0;
        err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
        APP_ERROR_CHECK(err_code);
    
        // Enable BLE stack.
        err_code = nrf_sdh_ble_enable(&ram_start);
        APP_ERROR_CHECK(err_code);
    
        // Register a handler for BLE events.
        NRF_SDH_BLE_OBSERVER(_blend_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
    	_blend_scan_instance.scan_buffer.p_data = _blend_scan_instance.scan_buffer_data;
    	_blend_scan_instance.scan_buffer.len = NRF_BLE_SCAN_BUFFER;
    }

    Can you maybe check for me where I did wrong? Because this is the exact way I did in SDK14 and that was perfectly fine. I am not sure what has changed about the softdevice API during the upgrade.

Children
Related