B4J Library jBluetooth library

Discussion in 'B4J Libraries & Classes' started by Erel, Nov 9, 2015.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    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: http://www.b4x.com/android/forum/posts/379631/

    Don't confuse it with jSerial library: http://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: http://snapshot.bluecove.org/distri...2.1.1-SNAPSHOT.62/bluecove-2.1.1-SNAPSHOT.jar
    Copy it together with the library to the additional libs folder.

    The B4A project is also included.

    Attached Files:

    Last edited: Nov 10, 2015
    TnP, Toley, GMan and 15 others like this.
  2. Osp

    Osp Member Licensed 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?
  3. Erel

    Erel Administrator Staff Member Licensed User

  4. Osp

    Osp Member Licensed User

    Thank you, awesome :)
  5. KMatle

    KMatle Expert Licensed User

    If you run into problems:


    astream.InitializePrefix(connection.InputStream, True, connection.OutputStream, "AStream")

    astream.Initialize(connection.InputStream, connection.OutputStream, "AStream")
    Beja, taktrashe and spairo like this.
  6. Zlgo

    Zlgo Member

    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
  7. Erel

    Erel Administrator Staff Member Licensed User

    This means that the Bluetooth driver is not supported by this library. Use jSerial instead.
  8. GMan

    GMan Well-Known Member Licensed User

    Works fine, even when using 3 BT-Connections at the same time :)
  9. Zlgo

    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.
  10. GMan

    GMan Well-Known Member Licensed User

    Whats about the Baudrate between them ?
  11. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for your question.
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice