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

[nRF52832] scan Beacon buffer

hi guys,

I was just getting started with Nordic nRF52832,
I want to find buffer containing bluetooth scanning data (Beacon) to process but see the examples but can't see.
Can you show me how that function is used

thank a lot!

Parents
  • Hi,

    You do not say anything about which SDK version or which example you are using, but I will give you an example.

    Starting with the ble_app_blinky_c central application in SDK 16.0.0, you can get the advertising data of scanned devices that do not match the scan filer in scan_evt_handler, using the following code:

    static void scan_evt_handler(scan_evt_t const * p_scan_evt)
    {
        ret_code_t err_code;
    
        switch(p_scan_evt->scan_evt_id)
        {
            case NRF_BLE_SCAN_EVT_NOT_FOUND:
                NRF_LOG_INFO("Received advertising from: %02x:%02x:%02x:%02x:%02x:%02x:%02x", p_scan_evt->params.p_not_found->peer_addr.addr[0], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[1], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[2], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[3], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[4], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[5]);
                break;
            case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
                err_code = p_scan_evt->params.connecting_err.err_code;
                APP_ERROR_CHECK(err_code);
                break;
            default:
              break;
        }
    }

    This will print the address of the device that sent the advertising packet. Other beacon data can be accessed through the same struct.

    To avoid that the scanner connects to a BLE blinky device, you must disable the scan filer by commenting out/removing these lines in scan_init():

        // Setting filters for scanning.
    //    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_NAME_FILTER, false);
    //    APP_ERROR_CHECK(err_code);
    //
    //    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name);
    //    APP_ERROR_CHECK(err_code);

    ble_app_beacon_scanner.zip

    Best regards,
    Jørgen

Reply
  • Hi,

    You do not say anything about which SDK version or which example you are using, but I will give you an example.

    Starting with the ble_app_blinky_c central application in SDK 16.0.0, you can get the advertising data of scanned devices that do not match the scan filer in scan_evt_handler, using the following code:

    static void scan_evt_handler(scan_evt_t const * p_scan_evt)
    {
        ret_code_t err_code;
    
        switch(p_scan_evt->scan_evt_id)
        {
            case NRF_BLE_SCAN_EVT_NOT_FOUND:
                NRF_LOG_INFO("Received advertising from: %02x:%02x:%02x:%02x:%02x:%02x:%02x", p_scan_evt->params.p_not_found->peer_addr.addr[0], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[1], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[2], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[3], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[4], 
                                                                                              p_scan_evt->params.p_not_found->peer_addr.addr[5]);
                break;
            case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
                err_code = p_scan_evt->params.connecting_err.err_code;
                APP_ERROR_CHECK(err_code);
                break;
            default:
              break;
        }
    }

    This will print the address of the device that sent the advertising packet. Other beacon data can be accessed through the same struct.

    To avoid that the scanner connects to a BLE blinky device, you must disable the scan filer by commenting out/removing these lines in scan_init():

        // Setting filters for scanning.
    //    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_NAME_FILTER, false);
    //    APP_ERROR_CHECK(err_code);
    //
    //    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_NAME_FILTER, m_target_periph_name);
    //    APP_ERROR_CHECK(err_code);

    ble_app_beacon_scanner.zip

    Best regards,
    Jørgen

Children
No Data
Related