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

How to get device details of BLE devices seen by NRF52?

My setup is a Android phone, Nordic NRF52, and random BLE devices in the area. What I want is, the Android NRF-UART app connects to the NRF52 and the NRF52 sends information about the BLE devices it sees around the area. How do I get this information?

This is what I've tried:

  1. getting the peer address like this: p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[X] and sending that to the phone, I get 6 bytes of information, is this what I want? How do I translate it?

  2. adv_report_parse(BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA, &adv_data, &type_data); support from thisisant pointed me to use this by using the input of what I want from ble_gap.h, but I have only found the BLE_GAP_AD_TYPE_FLAGS and BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA to work. All the other options reset the connection between nrf android app and nrf52.

Any help is appreciated, thanks!

  • You can get the full advertising packet from the scan response callback.

    Just parse the whole packet and extract whatever data you want to collect

  • Hi QDI,

    As Roger pointed out, the "proper" way would be to scan and log (or report over wired interface if you have it) all broadcasters. Usual way is to distinguish BLE devices by MAC address (aka Adv. address) which is 6-byte filed you mentioned. But some of them might not be static so it's question how useful this information will be. You can support it by logging whole content of ADV_xxx (and SCAN_RSP) data but these can also change any time so if some device wants to be immune to your tracking it can achieve it (of course;).

    Here is example of how to extract Adv. address from received packet in GAP Scanner/Central role (on BLE_GAP_EVT_ADV_REPORT event received):

    // Local variables.
    ble_evt_t *gsp_ble_evt;
    
    // ...
    
    // Extract Adv. address from the event structure.
    uint8_t * adv_address = (uint8_t *)gsp_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr;
    uint8_t adv_address_type = (uint8_t)gsp_ble_evt->evt.gap_evt.params.adv_report.peer_addr.addr_type;
    LOG_DEBUG("Adv. Address = 0x%02X:%02X:%02X:%02X:%02X:%02X.", adv_address[0],
                                                                 adv_address[1],
                                                                 adv_address[2],
                                                                 adv_address[3],
                                                                 adv_address[4],
                                                                 adv_address[5]);
    
    // ...
    

    Cheers Jan

  • Where to use this structure and what should be the initializing value of gsp_ble_evt.

Related