Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Porting BLE under android using bluez

I’m new bluez user , I ‘m trying to use the bluez API and develop a native code c using NDK in order to make android 4.0.3 support BLE I read the code source of Bluez but I can’t find exactly what functions should I use like connecting to the GATT . Any help will be appreciated.

Thanks!

like image 267
user3432104 Avatar asked May 26 '26 18:05

user3432104


1 Answers

I think you're on the right track in trying to figure out what you need through reading the Bluez source code, but you need to know what you're looking for exactly. If you want to solely implement BLE functionality, then get the bluez package from here, and look at the two specific source files which implement most of the BLE functions:

  • tools/hcitool.c
  • attrib/gatttool.c

Generally, the basic blueZ shell commands are:

hcitool lescan                                #scanning for LE devices
hcitool lecc                                  #connecting to LE devices
hcitool ledc                                  #disconnecting from LE devices
gatttool -b <MAC Address> --primary           #discover primary services
gatttool -b <MAC Address> --characteristics   #discover characteristics
gatttool -b <MAC Address> --char-read         #read characteristic value
gatttool -b <MAC Address> --char-write        #write to a characteristic value

You can then do some reverse engineering by looking for those commands in the aforementioned source files and see how they are implemented there.

I hope that this at least points you in the right direction.

like image 189
Youssif Saeed Avatar answered May 28 '26 08:05

Youssif Saeed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!