Thanks for reaching out!
As you may know, in order to interact with BLE devices you have to use gatttool. BlueZ by default does not include this module, so, usually I would recommend you to install a version of BlueZ that does as explained in https://software.intel.com/en-us/articles/using-the-generic-attribute-profile-gatt-in-bluetooth-low-energy-with-your-intel-edison. Nevertheless, since you are planning to use BlueZ's API to create a C script, you could find more appropriate to use LibGATT (https://github.com/jacklund/libgatt) which is simply the same code that gatttool uses but has been bundled into a public library. If you decide to do this, you should take a look at gatt.h (https://github.com/jacklund/libgatt/blob/master/src/gatt.h), in this file you will find the methods for connect, write, read, etc. This should get you started
I hope this information helps you,
Here are some links that may help you:
- For advertising and scanning: GitHub - sideralis/iot_ble_device at final
- For BLE spec: Legacy Specifications | Bluetooth Technology Website (core version 4.0) which will help you to understand the BlueZ API
- The BlueZ API source: bluez.git - Bluetooth protocol stack for Linux (look in tools\ folder to find some examples which may help you, and especially hcidump.c as it seems you are getting what your are looking for with this command)
- For issue with Bluetooth docker image for Edison (compiling issue): How to code samples not compiling. (See below note1)
- And last, you have to activate ble before being able to use it with c code. This is done with bash command: rfkill unblock bluetooth after each power up of your Edison board
Note1:To correct Bluetooth compilation errors from docker image (if it has not yet been solved by Intel)
- Start a bash
- Type « docker ps » to get your CONTAINER_ID
- Type « docker exec -it CONTAINER_ID bash» to open a bash in docker container
- Type « vi /usr/include/bluetooth/bluetooth.h» to correct error in this file
- Replace the 4 typeof at lines 161, 162, 169 et 170 by __typeof__
- exit and exit
it is a by the side project of me and i am still reading into this issue. And I am not sure if I would like to resolv it in scripting or c code. One thing I am sure to use the data of the air mentor I need to decode the raw string sended As a beacon payload.
i am still looking for some example code for the raw payload data. The scanning program for devices and the distance is working fine
I understand what you mean, sometimes it involves more trouble to create a C script than a shell script, even though shell scripting is a little bit more complex than C. I would personally try getting done everything manually and if I see that it can be done, I would choose shell scripting. This is because BlueZ's documentation isn't the best, and sometimes, if you are not very familiar with their API, it could be quite challenging to get things done.
Anyway, if you would like to get examples, you might be interested in contacting BlueZ directly to see if they can help you with this. You can do so in http://www.bluez.org/contact/.
I hope this helps and I hope to hear from you again. If you ever have any doubts, please don't hesitate to come back to the community, we'll try to help you in any way we can.