Dbus bluetooth issue on 23.05

Hi All,

I have a problem with using ble2mqtt on a MAP-AC2200 and openwrt 23.05.03
But it looks like the problem is somewhat deeper in bluetoothd not being able to attach to dbus.

Sun May 12 18:40:27 2024 daemon.err ble2mqtt[9875]: 2024-05-12 18:40:27 WARNING: Restarting bluetoothd...
Sun May 12 18:40:27 2024 daemon.info bluetoothd[13328]: Bluetooth daemon 5.66
Sun May 12 18:40:27 2024 daemon.err bluetoothd[13328]: src/main.c:main() Unable to get on D-Bus
Sun May 12 18:40:36 2024 daemon.err ble2mqtt[9875]: 2024-05-12 18:40:36 WARNING: Restarting bluetoothd finished

I can see that bluetooth discovery works fine and I can see the appropriate devices:

root@testdev:~# hcitool lescan --duplicates
LE Scan ...
3C:60:00:xx:yy:ww (unknown)
54:13:79:xx:yy:vv (unknown)
4D:5E:62:xx:yy:zz (unknown)

Below is a link to a larger snippet of the logs.

Any suggestions?

totally different device, totally different goal but...

i was never able to get the bluetooth stack working perfectly using native openwrt (recent build btw, 23+ etc)... what i was able to do instead was spin up a debian docker container and do it through there.

not sure about the specs on those devices but if you have the space, spin up a debian container and go from there. you'll get a full fledged bluetooth stack working without any issues.

Sadly using that is not really an option. Only 128MB Storage and 256MB RAM on this thing.

IN the meantime I tried this and there is no more output after this:

root@testdev:~# bluetoothd -n
bluetoothd[15777]: Bluetooth daemon 5.66
bluetoothd[15777]: Starting SDP server
bluetoothd[15777]: profiles/audio/vcp.c:vcp_init() D-Bus experimental not enabled
bluetoothd[15777]: src/plugin.c:plugin_init() Failed to init vcp plugin
bluetoothd[15777]: profiles/audio/mcp.c:mcp_init() D-Bus experimental not enabled
bluetoothd[15777]: src/plugin.c:plugin_init() Failed to init mcp plugin
bluetoothd[15777]: profiles/audio/bap.c:bap_init() D-Bus experimental not enabled
bluetoothd[15777]: src/plugin.c:plugin_init() Failed to init bap plugin
bluetoothd[15777]: src/rfkill.c:rfkill_init() Failed to open RFKILL control device
bluetoothd[15777]: Bluetooth management interface 1.21 initialized
bluetoothd[15777]: Failed to set privacy: Rejected (0x0b)

I might have gotten it to work via more packages installed: bluez-utils-btmon and kmod-input-uinput (just tested this).

Now I can see that ble2mqtt posts

Tue May 14 09:51:04 2024 daemon.info bluetoothd[16911]: Terminating
Tue May 14 09:51:04 2024 daemon.info bluetoothd[16911]: Stopping SDP server
Tue May 14 09:51:04 2024 daemon.info bluetoothd[16911]: Exit
Tue May 14 09:51:55 2024 daemon.info bluetoothd[16977]: Bluetooth daemon 5.66
Tue May 14 09:51:55 2024 daemon.info bluetoothd[16977]: Starting SDP server
Tue May 14 09:51:55 2024 daemon.warn bluetoothd[16977]: profiles/audio/vcp.c:vcp_init() D-Bus experimental not enabled
Tue May 14 09:51:55 2024 daemon.err bluetoothd[16977]: src/plugin.c:plugin_init() Failed to init vcp plugin
Tue May 14 09:51:55 2024 daemon.warn bluetoothd[16977]: profiles/audio/mcp.c:mcp_init() D-Bus experimental not enabled
Tue May 14 09:51:55 2024 daemon.err bluetoothd[16977]: src/plugin.c:plugin_init() Failed to init mcp plugin
Tue May 14 09:51:55 2024 daemon.warn bluetoothd[16977]: profiles/audio/bap.c:bap_init() D-Bus experimental not enabled
Tue May 14 09:51:55 2024 daemon.err bluetoothd[16977]: src/plugin.c:plugin_init() Failed to init bap plugin
Tue May 14 09:51:55 2024 daemon.err bluetoothd[16977]: src/rfkill.c:rfkill_init() Failed to open RFKILL control device
Tue May 14 09:51:55 2024 daemon.info bluetoothd[16977]: Bluetooth management interface 1.21 initialized
Tue May 14 09:53:56 2024 daemon.err ble2mqtt[17101]: 2024-05-14 09:53:56 INFO: Starting BLE2MQTT version 0.2.2, bleak 0.21.1, adapter hci0
Tue May 14 09:53:56 2024 daemon.err ble2mqtt[17101]: 2024-05-14 09:53:56 INFO: Connected to 192.168.xxx.yyy

And here it is how the logs for such an associated device should look like

Tue May 14 13:17:49 2024 daemon.err ble2mqtt[17101]: 2024-05-14 13:17:49 INFO: [Xiaomi_ATC_AABBCC_a4c138aabbcc] send state={'linkquality': 94, 'temperature': 24.47, 'humidity': 39.64, 'battery': 28}
Tue May 14 13:18:49 2024 daemon.err ble2mqtt[17101]: 2024-05-14 13:18:49 INFO: [Xiaomi_ATC_AABBCC_a4c138aabbcc] send state={'linkquality': 94, 'temperature': 24.41, 'humidity': 39.84, 'battery': 28}

In this case the device ( Xiaomi LYWSD03MMC with custom ATC firmware) is added via the ble2mqtt configuration ( in /etc/ble2mqtt.json), without encrypted beacons (yet)

{
    "mqtt_host": "MQTT_SERVER_IP",
    "mqtt_port": 1883,
    "mqtt_user": "MQTT_USERNAME",
    "mqtt_password": "MQTT_PASS",
    "log_level": "INFO",
    "devices": [
        {
            "address": "A4:C1:38:AA:BB:CC",
            "type": "xiaomilywsd_atc",
            "interval": 30
        }
    ]
}

What did you pass to docker to instead of classic /run/dbus ? Whats is the socket for dbus in OpenWRT?

i used a vanilla debian container and installed dbus in there so there was no need to pass anything.

as far as using the bluetooth stack, i also did all that inside the container so there was no need to expose anything to the host running the container.

for what its worth my use case was actually fair advanced as i used the bluetooth stack to emulate a bluetooth remote control which connected to my android tv so i could send keystrokes much faster than using the adb internal keycode sender.

i no longer use this setup but when i did it worked beautifully for a number of years.