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

Scanned BLE addresses print on comm port

Hi, 

I am using nrf52840 S140 PCA10056 SDK 15.2.0 version with example ble_app_multirole_lesc_S140_PCA10056 . i am using Segger Embedded studio IDE. So now problemis i am not able to retrieve the scanned device addresses . I want to retrieve the surrounding device addresses printed on comm port. Could any one tell me which function does that ? and where do i need to change in this example.

Parents
  • Hi,

    The example use the BLE scanner module with filtering, to only search for devices that match a given name, or includes the HRS UUID. To see any devices, you will have to disable filtering, by removing the following lines from scan_init():

    if (strlen(m_target_periph_name) != 0)
    {
        err_code = nrf_ble_scan_filter_set(&m_scan, 
                                           SCAN_NAME_FILTER, 
                                           m_target_periph_name);
        APP_ERROR_CHECK(err_code);
    }
    
    err_code = nrf_ble_scan_filter_set(&m_scan, 
                                       SCAN_UUID_FILTER, 
                                       &target_uuid);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_ble_scan_filters_enable(&m_scan, 
                                           NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER, 
                                           false);
    APP_ERROR_CHECK(err_code);

    You can the add a case to print the address to the log in scan_evt_handler():

    case NRF_BLE_SCAN_EVT_NOT_FOUND:
    {
        NRF_LOG_INFO("Received adv from: %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;
    

    Best regards,
    Jørgen

Reply
  • Hi,

    The example use the BLE scanner module with filtering, to only search for devices that match a given name, or includes the HRS UUID. To see any devices, you will have to disable filtering, by removing the following lines from scan_init():

    if (strlen(m_target_periph_name) != 0)
    {
        err_code = nrf_ble_scan_filter_set(&m_scan, 
                                           SCAN_NAME_FILTER, 
                                           m_target_periph_name);
        APP_ERROR_CHECK(err_code);
    }
    
    err_code = nrf_ble_scan_filter_set(&m_scan, 
                                       SCAN_UUID_FILTER, 
                                       &target_uuid);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_ble_scan_filters_enable(&m_scan, 
                                           NRF_BLE_SCAN_NAME_FILTER | NRF_BLE_SCAN_UUID_FILTER, 
                                           false);
    APP_ERROR_CHECK(err_code);

    You can the add a case to print the address to the log in scan_evt_handler():

    case NRF_BLE_SCAN_EVT_NOT_FOUND:
    {
        NRF_LOG_INFO("Received adv from: %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;
    

    Best regards,
    Jørgen

Children
Related