Matthias Ringwald
unread,Jun 4, 2014, 4:51:07 PM6/4/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to btsta...@googlegroups.com
Hi there
There are two new features in BTstack that we didn’t mention here before: GATT Client and Java Client
- The GATT Client allows to query a remote GATT Server e.g. from an LE Peripheral. It is modeled after the Bluetooth Spec and looks similar to the APIs on iOS and Android. There isn’t any documentation yet, but ble/gatt_client.h should get you started and there’s example/libusb/gatt_browser.c that scans for Advertisements and connects to the first device that it finds. It then gets a list of Primary Services and their Characteristics and prints them on the console.
What’s missing for a full LE implementation is the Security Manager for the Central Role. That’s next on our list.
- The Java Client provides access to a BTstack daemon over TCP or Unix Domain Sockets (Android only) without native code or helper libraries. If we ignore Android for a bit, I’d say it’s the only Java BLE implementation out there. Speaking of LE, BTstack currently doesn’t have a way to create an (G)ATT Database dynamically, so it’s not possible to implement an LE Peripheral via the BTstack deamon and therefore via pure Java. All in all, creating this client has been an interesting and fruitful exercise in writing a code generator. It parses the C source and header files (using only regex, of course) and generates Java classes for all Bluetooth commands and events. As the BTstack source code doesn’t list command parameter names, "arg1, arg2, arg3…" is used as a default. I’ve added doxygen/javadoc style comments to provide proper names, but this is incomplete at the moment. Similarly, events are not specified at all, so most events are not available as Java event classes yet (doxygen style comments allow to define them, too)
To try the Java client, you can run ANT in the java folder. It will generate some classes and then compile everything, before running a GATT Client test application. The example assumes that you have BTstack daemon running in TCP mode. You can do this by compiling BTstack with configure/make/make install and then
$ src/BTdaemon —tcp
Aside from Java, it shouldn’t be much effort to adapt the code generator to produce clients for other languages like Python, Ruby, node.js, or …
Let us know, what are you using the new Java client for. Testing comes to my mind first.
Best
Matthias