Open larsskj opened 1 year ago
I want to add that we know the same pylgbst
library with the similar code snippet works fine on other machines, specifically on Linux and Mac.
Also from linked issue:
Upgraded dbus-fast from 1.74.0 to 1.75.1 - no change.
I don't know if this could be relevant, but in order to be able to successfully write a characteristic (on Windows I think I was) I had to set the flag response=True
. So in your case, line 188 of pylgbst/comms/cbleak.py
would become:
await self._client.write_gatt_char(MOVE_HUB_HW_UUID_CHAR, data, True)
I don't know if this could be relevant also your scenario, but this solved my problems.
I want to add that we know the same
pylgbst
library with the similar code snippet works fine on other machines, specifically on Linux and Mac.
If it works on other Linux machines, the problem is probably a bug in BlueZ that has been fixed in more recent versions.
Sorry for being quite for a long time: I've been ill - and then we've had all the celebrations.
But now I've found the time: I've downloaded BlueZ 5.66 from kernel.org
and built it on my Raspberry Pi. According to bluetoothctl version
I am running 5.66 - but the problem persists and the result is the same as above.
If the LEGO hub still has the same Bluetooth bug where write without response still sends a response, it causes BlueZ to disconnect due to the unexpected response. You can confirm this by capturing Bluetooth packets with btmon
or hcidump
. Every call to BleakClient.write_gatt_char()
in pylgbst needs to be changed to include the response=True
argument, at least on Linux and for this particular hub. You could also have a look at Pybricks to run the train without having to be connected to a computer.
bluetoothctl -v
) in case of Linux: 5.55-3.1+rpt2Description
I'm trying to setup a Raspberry Pi 3+ to connect to a Lego tram from this year's Lego Christmas set. This requires Bluetooth control, and we're trying to set it up using the Python
pylgbst
library. Trying to run a minimal test as described in this issue, the code first connects and works, then disconnects with the messagebleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
.Debug messages can be found in the issue mentioned above, but I'll be happy to provide as much as needed here as well.
What I Did
The test script I use:
Logs
Wireshark won't run, unfortunately, as this Linux host has no GUI.
But the debug log for the above program shows: