How to import BITalino JAVA api?

Python, Java, Android OS, etc.
SichaoSong
Posts: 8
Joined: Tue May 17, 2016 1:52 am

How to import BITalino JAVA api?

Postby SichaoSong » Wed May 18, 2016 2:35 am

Hi,

I don't have many experience in JAVA and Eclipse. I downloaded the latest java api version from your website, and the file name is API_JAVA. I unzipped it and saw that the .jar file under lib folder is named bluecove-2.1.1-SNAPSHOT. I don't know whether I need to rename the api folder as BITalino or something else, and the .jar file as bluecove?

In addition, in eclipse I imported the bluecove.jar and added it to the build path, but I still not able to import BITalino library("the import BITalino cannot be resolved."). I checked the tutorial here http://bitalino.com/docs/java-api/index.html but it seems like a bit old and do no fit the latest version of eclipse. Could you please help me with the problem? Thank you in advance! :)

SichaoSong
Posts: 8
Joined: Tue May 17, 2016 1:52 am

Re: How to import BITalino JAVA api?

Postby SichaoSong » Wed May 18, 2016 3:08 am

I just figured out how to import BITalino folder into Eclipse, how stupid I am!

Now I am facing another problem. When I right click on test.java and run it as an application, the error messages showed up as follow:

dyld: lazy symbol binding failed: Symbol not found: _IOBluetoothLocalDeviceReadSupportedFeatures
Referenced from: /private/var/folders/r3/jrrbk73j7q3642s3l67fbn180000gn/T/bluecove_sichaos_0/libbluecove.jnilib
Expected in: /System/Library/Frameworks/IOBluetooth.framework/Versions/A/IOBluetooth

dyld: Symbol not found: _IOBluetoothLocalDeviceReadSupportedFeatures
Referenced from: /private/var/folders/r3/jrrbk73j7q3642s3l67fbn180000gn/T/bluecove_sichaos_0/libbluecove.jnilib
Expected in: /System/Library/Frameworks/IOBluetooth.framework/Versions/A/IOBluetooth

I am using a mac os X EI Capitan 10.11.2. I don't know whether it is the problem of the bluecove.jar with the mac os or the problem of version of my jdk. :?

SichaoSong
Posts: 8
Joined: Tue May 17, 2016 1:52 am

Re: How to import BITalino JAVA api?

Postby SichaoSong » Wed May 18, 2016 3:53 am

Progress update:

I just downloaded bluecove 2.1.2.jar and renamed it a bluecove-2.1.1-SNAPSHOT.jar, then I used it to replace the file in the lib folder.

This time test() works. However, it could not find the device. Part of the output in the console is as follow:

BlueCove version 2.1.1-SNAPSHOT on mac
javax.bluetooth.LocalDevice@7adf9f5f
[]

where there suppose to have the device name inside []. And after a while, errors pop out and the program shuts down. I don't know why it is like this, since the OpenSignal can receive the data from bitalino board.

Btw, I find that some times the bluetooth connection breaks down automatically.

BITalino
Site Admin
Posts: 567
Joined: Tue Aug 27, 2013 3:47 pm

Re: How to import BITalino JAVA api?

Postby BITalino » Wed May 18, 2016 7:02 am

Hi there,

Please check the version of the API available through the link bellow (if you haven't already):
http://bitalino.com/API/API_Java.zip

It already bundles the BlueCove jar (so you can even try to use that instead of the renamed version), and its in a configuration that has already worked in the past.

Nevertheless, we're not sure if BlueCove works in the latest versions of Mac OS... on Windows it should work.

Best regards,
The BITalino Team

SichaoSong
Posts: 8
Joined: Tue May 17, 2016 1:52 am

Re: How to import BITalino JAVA api?

Postby SichaoSong » Wed May 18, 2016 9:22 am

Hi BITalino!

Thank you for your reply. What I am using now is the latest version that downloaded from the link. I guess there is some problem with the bluecove and mac os system. I will later try windows, but I can still forget about using java api but try to use python. I will let you know if I have problems :D

BITalino
Site Admin
Posts: 567
Joined: Tue Aug 27, 2013 3:47 pm

Re: How to import BITalino JAVA api?

Postby BITalino » Wed May 18, 2016 9:24 am

Hi there,

If you have the chance Python is indeed the recommended and most straightforward way to get things up & running across platforms ;)

Best regards,
The BITalino Team

SichaoSong
Posts: 8
Joined: Tue May 17, 2016 1:52 am

Re: How to import BITalino JAVA api?

Postby SichaoSong » Thu May 19, 2016 2:42 am

Hi BITalino,

The python api code seems like not support bluetooth connection on Mac OS. Is there any way that I can use python api in Mac os, or I shall use it in windows?

Thank you!

BITalino
Site Admin
Posts: 567
Joined: Tue Aug 27, 2013 3:47 pm

Re: How to import BITalino JAVA api?

Postby BITalino » Thu May 19, 2016 3:12 am

Hi there,

On Mac OS you can connect to BITalino using the Python API via the Virtual COM Port.

Once you pair de device with the computer a new path should be available on the /dev folder.

By default it's either '/dev/tty.bitalino-DevB' or '/dev/tty.BITalino-DevB' (depending on the device).

If you use your particular path instead of the MAC address of the device, it should work.

Let us know if this works out for you and if you need additional support, just let us know.

Best regards,
The BITalino Team

SichaoSong
Posts: 8
Joined: Tue May 17, 2016 1:52 am

Re: How to import BITalino JAVA api?

Postby SichaoSong » Thu May 19, 2016 4:24 am

Hi, I set mac address:

macAddress = "/dev/tty.bitalino-DevB"

and it works now. Thank you so much!

It still have a little problem. The stop() function seems not working, and when I stop the program there are some error messages indicating that the

self.version()

in stop() function has some errors. So I comment out this line and then it shows some promising results as:

/usr/bin/python /Users/sichaos/Dropbox/project/python/python-api-master/BitalinoTest.py

version, BITalino_v3.3a_18032014
SeqN: [ 0. 1. 1. 1. 1. 0. 0. 448. 28. 0. 0.]
D3: [ 3. 1. 1. 1. 1. 0. 0. 433. 30. 0. 0.]

I will later try to play with the sensor data on-the-fly and see how to communicate with Processing. I guess I need to implement a filter in order to calculate the real-time heart beat. This is a good start for my study. ;)

BITalino
Site Admin
Posts: 567
Joined: Tue Aug 27, 2013 3:47 pm

Re: How to import BITalino JAVA api?

Postby BITalino » Thu May 19, 2016 4:55 am

Glad to hear you've managed to reach a viable setup. Someone from the tram should post here soon to follow-up on the issues with the stop() function.

As for the processing part indeed you'll have to code some filtering and feature extraction steps... a widely used algorithm is the Pan & Tompkins:
http://www.robots.ox.ac.uk/~gari/teachi ... mpkins.pdf

If you browser around it's likely that you find an implementation in multiple programming languages already.

Best regards,
The BITalino Team


Return to “Programming APIs”