This is a very simple project. It seems that there is no BLE scanner example available for the Blue Gecko parts. Some of the examples involve scanning (for example the SPP example or throughput tester example) but I could not find a simple "hello world" type scanner example. So I decided to write one.
I tested the example on Thunderboard BG22 kit, but basically it should work on any kit. It is based on the soc-empty example. Only small modification is needed to the source code (app.c) to turn the soc-empty into a BLE scanner.
The source code is attached. To try it out:
When you run the example, it starts scanning immediately at boot (unlike the original soc-empty that starts advertising).
Scan responses are handled in function process_scan_response(). This is based on the code that I copied from the SPP example. I modified the code so that it looks for vendor specific advertising payloads (AD type = 0xFF) and prints the company ID to console. It recognizes Apple company ID (0x004C). If you need to look for any other company identifiers, then the complete list can be found at https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/
The example is intentionally left very simple. It includes the basic processing of advertising packets (you can detect device name or company ID). It should be simple to modify the code to parse any kind of packets (such as iBeacon format, or any custom format you might be working with).
Any questions or suggestions? Drop a note below.
Here's a sample of what the output looks like:
If the advertising data contains device name (either full or shortened), then the name is also printed to terminal.