Monday, 31 July 2017

The TinyB project is a bluetooth LE project for the Intel Edison. It is a project that communicates to bluez through DBUS. This library save you time writing your own JNI classes to interface with DBUS.
On the Intel Edison OS you are by default the root user so there is some change for raspberry pi and additional packages you need.

First upgrade your raspberry PI to the latest raspbian software which is Debian 9 Stretch at the moment. This will give you the latest Bluetooth software.

Install this software before building TinyB

sudo apt-get install openjdk-8-jdk libglib2.0-dev cmake bluez

Export the variable on the command line or add it to your ~/.bashrc and source it afterwards : source ~/.bashrc

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-armhf/

Read the guide from the github page.
https://github.com/intel-iot-devkit/tinyb

You will need to tweak it for the raspbian OS. Clone the project then change in to the project directory.

You need the -E parameter in there so sudo will use the JAVA_HOME you defined. If you do not use it then it the build will not be able to find the JNI headers because it will not have a JAVA_HOME to check. JNI is in JAVA_HOME under

This is the error you will receive when not using -E in he sudo command to use your JAVA_HOME.

Execute the example code to test your installation. It should prompt you include a device address.sudo java -cp examples/java/HelloTinyB.jar:/usr/lib/lib/java/tinyb.jar HelloTinyBRun with <device_address> argument

As an extra piece. If you want to install them locally instead of globally like it is done aboive and you get either of these errors. DO NOT DO THIS IF YOU DONE THE SETUP ABOVE.java.lang.UnsatisfiedLinkError: no javatinyb in java.library.pathjava.lang.UnsatisfiedLinkError: no tinyb in java.library.path

It is looking for these 2 files

libjavatinyb.so

libtinyb.so

locate what directory they are in then add them in the parameter
In my build directory i ran it like this. The 2 files are located in 2 different directories. This got it working for me.java -Djava.library.path=/usr/local/lib/:./java/jni/ -cp examples/java/HelloTinyB.jar:./java/tinyb.jar HelloTinyB