B4J Library jBluetooth library

Status
Not open for further replies.
This library allows you to discover and connect to Bluetooth devices. It is similar to B4A Serial library.
It is based on the BlueCove open project (Apache license): http://bluecove.org/
This library runs on Windows.
A modified version for Raspberry Pi is available here: https://www.b4x.com/android/forum/posts/379631/

Don't confuse it with jSerial library: https://www.b4x.com/android/forum/threads/jserial-library.34762/#content
jSerial library provides access to com ports (you can map a Bluetooth adapter to a virtual com and then use jSerial to connect with a Bluetooth device).

If full screen doesn't work then you can open the video with this link: https://www.facebook.com/130066193752502/videos/941113055981141/

The steps required to connect to a Bluetooth device:
1. Check that Bluetooth.IsEnabled returns true.
2. Start a discovery process.
3. Once Device_Found is raised you can connect to the device.
4. The Connected event will be raised with the BluetoothConnection object.
5. Use AsyncStreams with the input and output streams.

You can also listen to incoming connections. In that case you should call Bluetooth.Listen. The Connected event will be raised when a client is connected.

The library depends on the following jar file: https://repo1.maven.org/maven2/io/ultreia/bluecove/2.1.1/bluecove-2.1.1.jar
Copy it together with the library to the additional libs folder.

The B4A project is also included.
 

Attachments

  • B4J_BluetoothExample.zip
    3.2 KB · Views: 2,324
  • B4A_BluetoothExample.zip
    9.7 KB · Views: 2,000
  • jBluetooth.zip
    9.2 KB · Views: 1,079
Last edited:

Osp

Member
Licensed User
Longtime User
Hi, the link to bluecove-2.1.1-snapshot.jar ist not working and at the official site there is only an older version for download. Do you know how to get hold of the needed .jar?
 

KMatle

Expert
Licensed User
Longtime User

Zlgo

Member
Hi
I tried to run this example on my pc with installed BT adapter(not dongle one) and after try to connect on recognized device (LG K4) program throw :

Waiting for debugger to connect...
Program started.
BlueCove version 2.1.1-SNAPSHOT on winsock
Service search completed. Exit code: 4
Connected, success=false

On mob is Android 6.0.1
 

GMan

Well-Known Member
Licensed User
Longtime User
Works fine, even when using 3 BT-Connections at the same time :)
 

Zlgo

Member
Please correct me if I wrong use this example:

1. made pairing through WIN10 Settings with my LG K4
2. run example where in listview field show "LG K4(2017) B41DA858DF5"
3. choose this device and press "Connect"
After this step get return "Connected, success=false".
My first dilemma is do we need some application running in the same time on mob, and how implement jserial.lib in this situation. Bluetooth installed on my PC
is not virtual COM ,at least I can't detect any additional serial ports.
Examine Bluetooth driver stay that is Microsoft 10.0.17763292.
 

GMan

Well-Known Member
Licensed User
Longtime User
Whats about the Baudrate between them ?
 
Status
Not open for further replies.
Top