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.

Parents
  • They advertise for 5 seconds ... central device that is scanning every 5 seconds

    That doesn't sound very likely to succeed: if the devices are only advertising for 5s, and the central is only listening for 5s, the chances that the central is listening at the same time that the device is advertising is quite slim!

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

    It tells you that the Whitelist uses only addresses  and, therefore, may require an IRK. whereas the scan filter can use names.

    So which sounds most appropriate to your requirement?

    how do I do that

    The thread referred you to examples which use each method ...

Reply
  • They advertise for 5 seconds ... central device that is scanning every 5 seconds

    That doesn't sound very likely to succeed: if the devices are only advertising for 5s, and the central is only listening for 5s, the chances that the central is listening at the same time that the device is advertising is quite slim!

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

    It tells you that the Whitelist uses only addresses  and, therefore, may require an IRK. whereas the scan filter can use names.

    So which sounds most appropriate to your requirement?

    how do I do that

    The thread referred you to examples which use each method ...

Children
No Data
Related