3

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!

asked Mar 20, 2014 at 19:48
0

1 Answer 1

3

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.

answered Apr 9, 2014 at 17:31
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.