Closed 30p87 closed 1 month ago
Hey @30p87, thanks for the report.
I didn't fully understand your explanation, but I think the following PR is the one that solved this: https://github.com/OpenBluetoothToolbox/SimpleBLE/pull/321
Feel free to reopen the issue if more recent versions don't work.
Basically any action involving interfaces, eg. SimpleBLE::Peripheral.mtu() and SimpleBLE::Peripheral.services() will result in an Exception::InterfaceNotFoundException thrown by simpledbus/src/advanced/Proxy.cpp::interface_get. It's the correct response to the required interfaces, respectively "org.bluez.GattCharacteristic1" and "org.bluez.GattService1", not being in simpledbus/include/simpledbus/advanced/Proxy.h::_interfaces. In fact, at runtime of the named functions, only "org.bluez.MediaEndpoint1", "org.freedesktop.DBus.Introspectable" and "org.freedesktop.DBus.Properties" are present. However, watching _interfaces with breakpoints in simpledbus/src/advanced/Proxy.cpp::interfaces_load, it seems that _interfaces is being initialized multiple times, "building up" values until it is cleared at some time, being reinitialized again and again, without "org.bluez.GattService1" etc. however.
First use of SimpleBLE::Adapter (eg. SimpleBLE::Adapter::bluetooth_enabled()) will start initialization of simpledbus/src/advanced/Proxy.cpp::Proxy
_interfaces will change like this over time: 1: "org.bluez.AgentManager1", "org.bluez.ProfileManager1", "org.freedesktop.DBus.Introspectable" 2: "org.bluez.Adapter1", "org.bluez.GattManager1", "org.bluez.LEAdvertisingManager1", "org.bluez.Media1", "org.bluez.NetworkServer1", "org.freedesktop.DBus.Introspectable", "org.freedesktop.DBus.Properties" 3: "org.bluez.Device1", "org.bluez.Input1", "org.freedesktop.DBus.Introspectable", "org.freedesktop.DBus.Properties" 4: "org.bluez.Device1", "org.bluez.MediaControl1", "org.freedesktop.DBus.Introspectable", "org.freedesktop.DBus.Properties" 5: "org.bluez.Device1", "org.bluez.MediaControl1", "org.bluez.Network1", "org.freedesktop.DBus.Introspectable", "org.freedesktop.DBus.Properties" 6: "org.bluez.Device1", "org.bluez.MediaControl1", "org.freedesktop.DBus.Introspectable", "org.freedesktop.DBus.Properties"
Connecting to a peripheral will work fine
Calling anything depending on interface_get will crash the program
I do not know the inner workings of simpledbus, especially Proxy, so I do not know how _interfaces should behave.
I'm using Bluez 5.66-1 on Arch Linux kernel 6.2.12.arch1-1. My device is a Dell Latitude E5470 with a "8087:0a2b Intel Corp. Bluetooth wireless interface". Comparable examples, such as a implementation in Python using Bluez, https://github.com/ThePBone/GalaxyBuds-BatteryLevel/blob/master/buds_battery.py, works flawlessly. This occurs in my own implementation, but also in the example connect (neither safe nor plain c version) code.