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
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.
It should complete without errors.
The make command will take about 10 minutes to complete on the raspberry PI.
Install the libraries on to the file system
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 HelloTinyB
Run 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.path
java.lang.UnsatisfiedLinkError: no tinyb in java.library.path
It is looking for these 2 files
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
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 bluezExport 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.
mkdir build cd build sudo -E cmake -DBUILDJAVA=ON -DCMAKE_INSTALL_PREFIX=/usr ..
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.
CMake Error at /usr/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message): Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) Call Stack (most recent call first): /usr/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.7/Modules/FindJNI.cmake:305 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) java/jni/CMakeLists.txt:1 (find_package) -- Configuring incomplete, errors occurred! See also "/home/pi/tinyb/build/CMakeFiles/CMakeOutput.log". See also "/home/pi/tinyb/build/CMakeFiles/CMakeError.log".
It should complete without errors.
The make command will take about 10 minutes to complete on the raspberry PI.
sudo make
Install the libraries on to the file system
sudo make installIt will install the jar file under
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 HelloTinyB
Run 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.path
java.lang.UnsatisfiedLinkError: no tinyb in java.library.path
It is looking for these 2 files
libjavatinyb.so
libtinyb.so
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