How to perform a bluetooth low-energy scan via BlueZ C library

The example on the other answer does not work for me, it stops in Scanning...

The next link works for c language, but has an error when casting the bytes that have the information about de rssi signal. https://github.com/glock45/intel-edison-playground/blob/master/scan.c

this line 121:

printf("%s - RSSI %d\n", addr, (**char**)info->data[info->length]);

should be:

printf("%s - RSSI %d\n", addr, (**int8_t**)info->data[info->length]);

I found these by looking inside bluez-version/monitor/*.c, where btmon program is. You can see the data types and structs, hcidump.c is very useful and packets.c, and main.c too, but there are many to learn about the hci sockets


BLE programming with BlueZ on Galileo or Edison is similar to any other x86 platform.

Edison (and Galileo) usually comes with BlueZ libraries pre-installed. You just need to link with them with your C code, and program similar to other x86 platform.

For a full C code example bluetooth scan with BlueZ, see this link.

Please see this example for BLE scan

And the HCI API here.