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

How to get BLE scan result

Hi,

I am using nrf52832 development board with sdk 17.0.2 and S132 softdevice. My requirement is to scan and advertise at the same time. I am using the ble_app_template as a base code and added the  'nrf_ble_scan_init(&m_scan, NULL, NULL)' and ' nrf_ble_scan_start(&m_scan)' functions to test the scanning functionality. But how do I get the scanned devices name and other details? If that is possible, then I need to call it periodically and print it using UART.

Parents
  • Hi,

    Have you added any filter with nrf_ble_scan_filters_enable() and nrf_ble_scan_filter_set() (see for instance <nRF5 SDK>\examples\ble_central\ble_app_hrs_c\main.c)? If so you would get a NRF_BLE_SCAN_EVT_FILTER_MATCH event when the filter matched. I not and you want to get all advertising packets you could handle the BLE_GAP_EVT_ADV_REPORT event. You will get a pointer to a ble_gap_evt_adv_report_t with that event, giving you all the information from the advertising packet.

  • I have added the BLE_GAP_EVT_ADV_REPORT case in ble event. I am able to get the sr_data(scan response data) if I make the m_scan_param.active  = 1; but the device is not scanning all the BLE devices.(Note: all my BLE devices have scan response data). It scan's one device multiple times and the other device occasionally. My requirement is that my scanner(BLE) should scan all the nearby devices and get the scan response data, advertisement data, mac addr and device name so that I can manually filter them.

Reply
  • I have added the BLE_GAP_EVT_ADV_REPORT case in ble event. I am able to get the sr_data(scan response data) if I make the m_scan_param.active  = 1; but the device is not scanning all the BLE devices.(Note: all my BLE devices have scan response data). It scan's one device multiple times and the other device occasionally. My requirement is that my scanner(BLE) should scan all the nearby devices and get the scan response data, advertisement data, mac addr and device name so that I can manually filter them.

Children
Related