I am starting to create a simple BLE network with a microcontroller and raspberry pi (tardis BLE dongle). As a starting point, I'm looking for a simple C or C ++ example to read / write a BLE device, similar to what I can do on the command line. The examples I have found so far are quite complex. As a BLE beginner, I need some very simple examples to build before moving forward with a more complex design. I'm fine with hard-coded BLE device name, as in the gatttool example below.
Here's how I use Bluez command line options right now.
From the command line, I can use:
$ sudo hcitool lescan LE Scan ... BB:A0:50:02:18:07 MyDevice
Next, I can connect to the device on the command line using gatttool:
$ sudo gatttol -b BB:A0:50:02:18:07 -I [BB:A0:50:02:18:07][LE]> connect Attempting to connect to BB:A0:50:02:18:07 Connection successful
Finally, I can read and write using appropriate descriptors
[BB:A0:50:02:18:07][LE]> char-write-req 000f 0100 Characteristic value was written successfully [BB:A0:50:02:18:07][LE]> char-write-cmd 0011 4C467A
Some sites that I used for initial research and to get started:
http://people.csail.mit.edu/albert/bluez-intro/c404.html
https://github.com/carsonmcdonald/bluez-experiments/blob/master/experiments/scantest.c
c ++ c bluetooth raspberry-pi bluez
Cole wilson
source share