OH3 Bluetooth binding stops working with Asus USB-BT500

Hello.

I have OH3 installed on Raspbian running on RPi4. I have observed that the bluetooth binding stops working randomly. This is what I can see in openhab.log:

2021-02-28 23:34:48.234 [ERROR] [com.github.hypfvieh.DbusHelper      ] - Critical error while reading DBUS response (maybe no bluetoothd daemon running?)
org.freedesktop.dbus.exceptions.DBusExecutionException: The maximum number of pending replies per connection has been reached
        at jdk.internal.reflect.GeneratedConstructorAccessor177.newInstance(Unknown Source) ~[?:?]
        at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
        at org.freedesktop.dbus.errors.Error.getException(Error.java:157) ~[bundleFile:?]
        at org.freedesktop.dbus.errors.Error.throwException(Error.java:187) ~[bundleFile:?]
        at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:164) ~[bundleFile:?]
        at org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:228) ~[bundleFile:?]
        at com.sun.proxy.$Proxy175.Introspect(Unknown Source) ~[?:?]
        at com.github.hypfvieh.DbusHelper.findNodes(DbusHelper.java:44) [bundleFile:?]
        at com.github.hypfvieh.bluetooth.wrapper.BluetoothDevice.refreshGattServices(BluetoothDevice.java:82) [bundleFile:?]
        at com.github.hypfvieh.bluetooth.wrapper.BluetoothDevice.getGattServices(BluetoothDevice.java:70) [bundleFile:?]
        at org.openhab.binding.bluetooth.bluez.internal.BlueZBluetoothDevice.discoverServices(BlueZBluetoothDevice.java:395) [bundleFile:?]
        at org.openhab.binding.bluetooth.bluez.internal.BlueZBluetoothDevice.updateBlueZDevice(BlueZBluetoothDevice.java:113) [bundleFile:?]
        at org.openhab.binding.bluetooth.bluez.internal.BlueZBridgeHandler.initializeAndRefreshDevices(BlueZBridgeHandler.java:177) [bundleFile:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
        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) [?:?]
2021-02-28 23:34:58.288 [WARN ] [th.bluez.internal.BlueZBridgeHandler] - Unknown exception
java.lang.NullPointerException: null
        at com.github.hypfvieh.bluetooth.wrapper.BluetoothAdapter.isPowered(BluetoothAdapter.java:100) ~[bundleFile:?]
        at org.openhab.binding.bluetooth.bluez.internal.BlueZBridgeHandler.prepareAdapter(BlueZBridgeHandler.java:134) ~[bundleFile:?]
        at org.openhab.binding.bluetooth.bluez.internal.BlueZBridgeHandler.initializeAndRefreshDevices(BlueZBridgeHandler.java:162) [bundleFile:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
        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) [?:?]

I have to do systemctl restart bluetooth.service in order to resume the binding. This is kind of bad since the bluetooth binding dies, my OH3 instance stops receiving readings from bluetooth beacons.

Additionally, this is what I have in the system journal:

Feb 28 23:34:48 openhab dbus-daemon[332]: [system] The maximum number of pending replies for ":1.35" (uid=109 pid=28190 comm="/usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr
Feb 28 23:34:48 openhab dbus-daemon[332]: [system] The maximum number of pending replies for ":1.35" (uid=109 pid=28190 comm="/usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr
Feb 28 23:34:48 openhab dbus-daemon[332]: [system] The maximum number of pending replies for ":1.35" (uid=109 pid=28190 comm="/usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr
Feb 28 23:34:48 openhab dbus-daemon[332]: [system] The maximum number of pending replies for ":1.35" (uid=109 pid=28190 comm="/usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr
Feb 28 23:34:48 openhab dbus-daemon[332]: [system] The maximum number of pending replies for ":1.35" (uid=109 pid=28190 comm="/usr/bin/java -XX:-UsePerfData -Dopenhab.home=/usr

(just a few lines, there’s a lot more of that in there)

So my question is: has anyone ever seen this happening their systems? Anyone have any idea what this is all about and how to fix this?

Okay now, this is starting to unfold. The thing is, I have an Asus USB-BT500 dongle which, apparently, isn’t fully / properly supported by the drivers present in Raspbian. Luckily though, Asus provides Linux drivers, although you have to compile them for your kernel. Some guy on Reddit had compiled easy to follow instructions for doing this so I just followed those and had the thing up and running in no time.

Now I’m hoping the binding stays up. I’ll keep an eye on it, and follow up in a few days.

Hey donjoe,

can you please paste the solution here in the thread?
I just received the “ASUS USB-BT500” and am just facing the question of integration.

I’ll read the page from your link again, but I didn’t quite understand at first.

Thanks in advance for this.

Greetings
Tobi

Hi Tobi!

The basic idea was to obtain the drivers for the RTL8761BU chipset present in the Asus BT500 dongle and use them. I did just that but, alas, it turned to not solve the intermittent connection issues.

In my setup I have 3 RuuviTags. The thing is, that sometimes the system works weeks on end without issues, and then, out of a sudden, my OH3 instance stops receiving readings (symptoms described my first post). And, what’s even worse is that even restarting bluetooth.service doesn’t really seem to fix it.

To me this seems like some issue with this particular chipset + drivers + udev + bluetoothd combination, which really falls outside of my expertise.

Anyway, what I ended up doing was a rule that’s being run every 15 minutes which checks if there are no humidity readings from any of the RuuviTags in the last 15 minutes and if so, reboots the whole RPi instance. Yes, it’s an ugly old Windows style hack, but so far it has worked. I lose the maximum of 15 minutes of data, which I can tolerate. And right now, the uptime of the RPi instance is 25 days, so this issue seems totally random.

If you’re interested I can share the rule for checking and rebooting the RPi and, of course, if you manage to get to the bottom of this I would be more than glad to hear about it!

– Panu

Hey donjoe,

thanks so much for your quick feedback! Unfortunately I’m the same and certainly even less experienced with Linux, so I already have problems that I get the driver installed if necessary.

Openhab is as far as I know a 32bit system and thus the 32-bit driver would be necessary. Is that correct? Did you have the driver installed on the RPI4? What is the safest way to do this?

Somewhere I had read that when using bluetooth sticks, the internal bluetooth must be turned off in the settings. Is that so, do you know?

I have to take the time the days and look deeper into this. I got the stick so that I can get the range extended from the RPI4 to the last room sensor if necessary. Haven’t found any other stick which is supposed to be compatible.

Kind regards and again my biggest thanks!

Hi!

I think the manual compilation of the drivers is not needed anymore. The kernel recognizes the chipset, but alas, is unable to load the firmware (Bug #1968604 “rtl8761b usb bluetooth doesn't work following rebo...” : Bugs : linux-firmware package : Ubuntu).

Here are instructions for using the firmware for RTL8761B, which is present already on RPi (Fix Bluetooth rtl8761b Problem on Linux (Ubuntu 22.04))

What I did was that I downloaded the driver package for BT500 from Asus website, extracted the relevant files (rtl8761bu_config and rtl8761bu_fw) and created symlinks in /lib/firmware/rtl_bt like so:

lrwxrwxrwx 1 root root   134 Jul 23 18:53 rtl8761bu_config.bin -> 20200806_LINUX_BT_DRIVER_RTL8761B_COEX_v0202/20200806_LINUX_BT_DRIVER_RTL8761B_COEX_v0202/rtkbt-firmware/lib/firmware/rtl8761bu_config
lrwxrwxrwx 1 root root   130 Jul 23 18:53 rtl8761bu_fw.bin -> 20200806_LINUX_BT_DRIVER_RTL8761B_COEX_v0202/20200806_LINUX_BT_DRIVER_RTL8761B_COEX_v0202/rtkbt-firmware/lib/firmware/rtl8761bu_fw

Both are from the 64bit driver package.

And yes, I have the internal bt disabled as it’s practically useless.

However, like I said, none of this has helped me at all. OH randomly stops receiving measurements, and nothing else but system reboot seems to help :face_with_diagonal_mouth:

– Panu