user3432104
user3432104

Reputation: 81

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!

Upvotes: 3

Views: 993

Answers (1)

Youssif Saeed
Youssif Saeed

Reputation: 13285

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.

Upvotes: 3

Related Questions