How to get Bluetooth running?

  • Platform information:
    • OS: Debain Buster, BlueZ 5.43
    • openHAB version: 2.5.0

I’m trying to get the bluetooth binding to run, but already to get the bluetooth bridge running, which is required to attach the Ruuvi Tags later on.
BlueZ 5.43 is installed and the Ruuvi Tage is discovered if monitoring the bluetoothctl CLI output. Also, all changed posted by the Ruuvi tag recognized.
The bridge definition looks just like described in the dcoumentation, of course with my MAC address:

Bridge bluetooth:bluez:hci0 [ address="00:E1:8C:59:14:CD", discovery=false ]

The openhab.log shows this error:

2020-02-20 15:06:41.060 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler@1684c7fb': BlueZ JNI connection cannot be established.
java.lang.IllegalStateException: BlueZ JNI connection cannot be established.
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:98) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_242]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_242]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_242]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_242]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
Caused by: java.lang.UnsatisfiedLinkError: tinyb.BluetoothManager.getNativeAPIVersion()Ljava/lang/String;
	at tinyb.BluetoothManager.getNativeAPIVersion(Native Method) ~[?:?]
	at tinyb.BluetoothManager.getBluetoothManager(BluetoothManager.java:304) ~[?:?]
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:93) ~[?:?]
	... 10 more
2020-02-20 15:06:41.062 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'bluetooth:bluez:hci0': BlueZ JNI connection cannot be established.
java.lang.IllegalStateException: BlueZ JNI connection cannot be established.
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:98) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_242]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_242]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_242]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_242]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
Caused by: java.lang.UnsatisfiedLinkError: tinyb.BluetoothManager.getNativeAPIVersion()Ljava/lang/String;
	at tinyb.BluetoothManager.getNativeAPIVersion(Native Method) ~[?:?]
	at tinyb.BluetoothManager.getBluetoothManager(BluetoothManager.java:304) ~[?:?]
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:93) ~[?:?]
	... 10 more

The user openhab is member of the bluetooth group and access to bluetoothctl works when using

sudo -s openhab bluetoothctl

Anyone any idea?

Use the openhabian-config tool and select add needed packages, fix permissions, and any others that may apply.

This is not a openhabian installation, thus openhabian-config is not available.

But you can always add openhabian. :wink:

Per the Doc’s:

openHABian also supports general Debian/Ubuntu based systems on different platforms. Starting with a fresh installation of your operating system, install git, then clone the openHABian project and finally execute the openHABian configuration tool:

# install git
sudo apt-get update
sudo apt-get install git

# download and link
sudo git clone https://github.com/openhab/openhabian.git /opt/openhabian
sudo ln -s /opt/openhabian/openhabian-setup.sh /usr/local/bin/openhabian-config

# execute
sudo openhabian-config

Done, no changes:

2020-02-21 16:30:18.770 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler@6a06846e': BlueZ JNI connection cannot be established.
java.lang.IllegalStateException: BlueZ JNI connection cannot be established.
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:97) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_242]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_242]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_242]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_242]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
Caused by: java.lang.UnsatisfiedLinkError: tinyb.BluetoothManager.getNativeAPIVersion()Ljava/lang/String;
	at tinyb.BluetoothManager.getNativeAPIVersion(Native Method) ~[?:?]
	at tinyb.BluetoothManager.getBluetoothManager(BluetoothManager.java:304) ~[?:?]
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:92) ~[?:?]
	... 10 more
2020-02-21 16:30:18.775 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'bluetooth:bluez:b2914e34': BlueZ JNI connection cannot be established.
java.lang.IllegalStateException: BlueZ JNI connection cannot be established.
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:97) ~[?:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_242]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_242]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_242]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_242]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_242]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_242]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
Caused by: java.lang.UnsatisfiedLinkError: tinyb.BluetoothManager.getNativeAPIVersion()Ljava/lang/String;
	at tinyb.BluetoothManager.getNativeAPIVersion(Native Method) ~[?:?]
	at tinyb.BluetoothManager.getBluetoothManager(BluetoothManager.java:304) ~[?:?]
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:92) ~[?:?]
	... 10 more

Did you try restarting OH a few times and:

add openHAB to the “bluetooth” group.

sudo adduser openhab bluetooth

Also, in case you don’t want to manually enable your bluetooth adapters with bluetoothctl , ensure that it’s automatically enabled by setting the option AutoEnable in your /etc/bluetooth/main.conf to true . Restart running services for changes to take effect.

systemctl restart dbus
systemctl restart bluetooth
systemctl restart openhab2

All done, but no changes. Problem persists. :frowning:

Hello,
Did you fixed it ?
Thanks

Have the same issue here. Did anyone get this resolved? I am trying to use the regular Bluetooth binding as for some reason I have lost access to the market bindings for Bluetooth and Tinyb. https://community.openhab.org/t/eclipse-iot-market-bindings-not-available/100782/13

This is where I stand now.

I have already edited the /etc/dbus-1/system.d/bluetooth.conf to add the following.

  <policy group="bluetooth">
    <allow send_destination="org.bluez"/>
  </policy>

I did add user

sudo adduser openhab bluetooth

I also did these… and rebooted after that.

systemctl restart dbus
systemctl restart bluetooth
systemctl restart openhab2

Openhab does not find the Bluetooth controller. I am expecting OH to find them automatically per the documentation here. so I add the following line to a new bluetooth.things file

Bridge bluetooth:bluez:hci0 [ address="00:19:86:00:21:40", discovery=false ]

got the address from here…

localhost:~$ sudo bluetoothctl
[NEW} Controller 00:19:86:00:21:40 BlueZ 5.47 [default]
Agent registered

lsusb

localhost:~$ lsusb
...
Bus 003 Device 002: ID 0a5c:21e8 Broadcom Corp. BCM20702A0 Bluetooth 4.0
...

The error on openhab.log

2020-06-18 11:56:15.133 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler@4f59bdf7': BlueZ JNI connection cannot be established.
java.lang.IllegalStateException: BlueZ JNI connection cannot be established.
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:72) ~[?:?]
	at jdk.internal.reflect.GeneratedMethodAccessor94.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.UnsatisfiedLinkError: 'java.lang.String tinyb.BluetoothManager.getNativeAPIVersion()'
	at tinyb.BluetoothManager.getNativeAPIVersion(Native Method) ~[?:?]
	at tinyb.BluetoothManager.getBluetoothManager(BluetoothManager.java:304) ~[?:?]
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:67) ~[?:?]
	... 9 more
2020-06-18 11:56:15.134 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while initializing handler of thing 'bluetooth:bluez:hci0': BlueZ JNI connection cannot be established.
java.lang.IllegalStateException: BlueZ JNI connection cannot be established.
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:72) ~[?:?]
	at jdk.internal.reflect.GeneratedMethodAccessor94.invoke(Unknown Source) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
	at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.UnsatisfiedLinkError: 'java.lang.String tinyb.BluetoothManager.getNativeAPIVersion()'
	at tinyb.BluetoothManager.getNativeAPIVersion(Native Method) ~[?:?]
	at tinyb.BluetoothManager.getBluetoothManager(BluetoothManager.java:304) ~[?:?]
	at org.openhab.binding.bluetooth.bluez.handler.BlueZBridgeHandler.initialize(BlueZBridgeHandler.java:67) ~[?:?]
	... 9 more