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

Central device scanning for beacon adverts and printing out advert data

Hi,

My application is as follow:

I have 5 BLE buttons that behave like a beacon. They advertise for 5 seconds when the button is pressed. Each has a different name (Advert Data), eg Button01, Button02, Button03, etc. I have a central device that is scanning every 5 seconds. I basically want to print out the names of these buttons whenever it scans and finds any of these buttons advertising.

I am using the example in this thread to scan and also print out the all devices found on NRF Log.

https://devzone.nordicsemi.com/f/nordic-q-a/43747/nrf52832-ble-scan/171379#171379

I have added a line: NRF_LOG_INFO("Device found: %s", adv_data.p_data) inside the function device_to_list_add

However, this is scanning and printing out everything including other devices that are advertising. I only want to scan for devices with the name ButtonXX. Should I be implementing a whitelist or a scan filter? 

I read on this thread about the difference between whitelist and scan filter:

https://devzone.nordicsemi.com/f/nordic-q-a/45034/scan-with-whitelist-vs-scan-filtering

And it mentions the following:

A scan filter can be set using the function nrf_ble_scan_filter_set(..) in the nrf_ble_scan library, and you can perform filtering based on these types:

  • Names
  • Short names
  • Addresses
  • UUID's
  • Appearance

So in this case, should I be using a scan filter for Names? And how do I do that?

Thanks in advance.

Related