0

I am using my raspberry pi to perform LEScan at fixed intervals and connect to new found BLE devices. Performing a general scan is easy and can be easily done by using the bluez libraries. http://people.csail.mit.edu/albert/bluez-intro/x45.html

But i can't figure out how to perform LE scan using Bluetooth programming in C language.

I have to find new BLE devices, connect to them and receive json data from the connected devices.

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
user2516582
  • 1
  • 1
  • 1
  • 1
    Take a look at `hcitool.c` in [bluez sources](http://git.kernel.org/cgit/bluetooth/bluez.git/tree/tools/hcitool.c) for scanning BLE devices. – istirbu Jun 23 '15 at 11:31
  • Please, use the DBus API and save yourself all the hcitool and gattool trouble. If your device is DBus capable you should use it. It gets as simple as calling StartDiscovery(). The bluetoothctl tool is a great example of this. The source you can find in the Bluez source code in the `client` folder; it's called `main.c` – Zimano Nov 23 '15 at 12:54

2 Answers2

1

To write a C program to scan BLE devices you can have a look at BlueZ hcitool sources.

To connect to the BLE device and interact with the GATT protocol you can either use the experimental DBUS Bluez API in Bluez v5.x (recommended to use v5.39+) or use a library like 'gattlib'.

OlivierM
  • 2,820
  • 24
  • 41
0

The link you are pointing is for classic bluetooth;for BLE lescan go

through scantest.c in link

https://github.com/carsonmcdonald/bluez-experiments/tree/master/experiments

Jagdish
  • 160
  • 3
  • 13