How to perform low-power bluetooth scan through BlueZ C library

I am new to programming low energy Bluetooth using BlueZ.

I want to develop my own c code to scan nearby devices using the BlueZ API for Low Energy Bluetooth on Intel Edison. I saw this question , but the answer really does not help. Any tips?

+8
linux intel-edison bluetooth-lowenergy bluez
source share
3 answers

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

Edison (and Galileo) usually comes with pre-installed BlueZ libraries. You just need to associate them with your C code and program them in a similar way to another x86 platform.

For a complete C-shaped bluetooth scan example with BlueZ, see this link .

See this example for a BLE scan.

And the HCI API is here .

+7
source share

An example of another answer does not work for me, it stops at Scanning ...

The following link works for the c language, but has an error when issuing bytes containing information about the 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]); 

it should be:

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

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

+8
source share

The intel-edison scan.c code also works on Raspberry Pi.

It works to scan the Adafruit BLE UART friends module connected to the Arduino Uno.

On Pi you need to download bluez-5.33.tar.gz, libncurses-dev and libbluetooth-dev.

To compile scan.c, use

gcc scan.c -lbluetooth -o scan

0
source share

All Articles