Maneesh N
Maneesh N

Reputation: 43

How to interact with BLE devices through Linux using C programs?

I am fairly new to the BLE world. Assuming I have a BLE device Eg: A heart rate monitor, How do I interact with that BLE device using C code.

I am able to see the Heart rate data using the command line tool 'bluetoothctl'. If I want connect to the same device through C code and see the Notified data, how do I go about it?

Though some codes on the Internet and GitHub helped me to scan for the device, I do not have any idea on how to connect to the device, read the GATT characteristics of the BLE device. I'd even appreaciate it if anyone points me to the API documentations of BlueZ, I literally have no clue what the programs are all about. Any assistance would be of great help.

Upvotes: 1

Views: 1262

Answers (1)

ukBaz
ukBaz

Reputation: 7954

The preferred API for BlueZ uses the D-Bus bindings. The documentation for those APIs are at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc

There are Python examples of how to use the D-Bus API at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test

bluetoothctl is written in C and the source is available at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/client

Upvotes: 2

Related Questions