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

How can the central scan and print "device name"? Specifically in the example of ble_app_uart_c?

Hi,

The example is currently printing the device address

on_adv_report(ble_gap_evt_adv_report_t const * p_adv_report)
{
...
NRF_LOG_INFO("Connecting to target %02x%02x%02x%02x%02x%02x",
p_adv_report->peer_addr.addr[0],
p_adv_report->peer_addr.addr[1],
p_adv_report->peer_addr.addr[2],
p_adv_report->peer_addr.addr[3],
p_adv_report->peer_addr.addr[4],
p_adv_report->peer_addr.addr[5]

Is it possible to print also the device name? For example the one that is advertised by the ble_app_uart peripheral example?

Thanks

Avi

  • You can use the function ble_advdata_parse() in the ble_advdata.c library to achieve this. Input the advertising report data and length in addition to the AD type you want to search for, which will be either BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME or BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME in your case. In return, you will get a pointer to the device name. Check out this case.

    Best regards,

    Simon

Related