You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] GATT operation failed for unknown reasons. with Spike Prime Hub #740
Describe the bug
After upgrading pybricks-micropython to b83536e69693e64e312343ec6b9a79c513fdc24f, when I try to use bluetooth to connect on code, I get an error GATT operation failed for unknown reason. The previous commit at ed2e5849f52211f0e3e98d269e861c4fb08752c2 seems to work fine.
To reproduce
Steps to reproduce the behavior:
Check out pybricks-micropython at b83536e69693e64e312343ec6b9a79c513fdc24f
Deploy to Spike Prime Hub.
Go to beta.pybricks.com and connect via Bluetooth.
See error.
Expected behavior
The editor should have connected to the hub via bluetooth.
This is in the middle of big revisions to the Bluetooth code.
Before digging into this, you may want to try:
pybricks/pybricks-micropython@0aeb8bf: This is just before we started revising bluetooth extensively. This will still work with beta.pybricks.com as it is today.
pybricks/pybricks-micropython@7d7434f: This is the latest version on the master branch. This completes the Bluetooth revisions but it is not yet compatible with beta.pybricks.com. This should come in a week or two when we release the next beta version.
Thanks @laurensvalk for responding so quickly! As I mentioned, the previous commit (ed2e584) worked without problems.
And yes, I did try the latest version of the master branch (which also does not work) -- that was what failed for me first so I decided to find the earliest commit that cause this to break (b83536e).
We changed the layout of the GATT attributes on the device and I have a hunch that macOS may be serving up a cached attribute database instead of reading it from the hub.
I was making a screencast to show folks how to use pybricks at the same time. It seems the error only happens when the screencast software is also running (OBS studio).
Activity
dlech commentedon Oct 20, 2022
What operating system are you using? Can you click the Copy Error Message button and paste the error here so we can see the full error?
davidwu226 commentedon Oct 20, 2022
I'm on Mac OSX 12.4 (M1-based) with Chrome 106.0.5249.119.
Here's from the copy error message:
laurensvalk commentedon Oct 20, 2022
This is in the middle of big revisions to the Bluetooth code.
Before digging into this, you may want to try:
davidwu226 commentedon Oct 20, 2022
Thanks @laurensvalk for responding so quickly! As I mentioned, the previous commit (ed2e584) worked without problems.
And yes, I did try the latest version of the master branch (which also does not work) -- that was what failed for me first so I decided to find the earliest commit that cause this to break (b83536e).
FWIW, I also tried pybricks/pybricks-micropython@b83536e against pybricks/pybricks-code@81d52db and it did not work either.
laurensvalk commentedon Oct 20, 2022
Right, anything before those Bluetooth changes is supposed to work with https://beta.pybricks.com/ up to today.
No matching Pybricks Code version was released (or even pushed) at the time, I think.
But since you are able to run Pybricks Code locally, it would be great if you want to try the latest version of the master branches of both, together.
To be specific, e.g.:
pybricks/pybricks-micropython@57efb61
with
pybricks/pybricks-code@7e726ff
I've been running those all day today. Would be great to know if the issue persists in that case.
Thanks!
davidwu226 commentedon Oct 20, 2022
Just tried pybricks/pybricks-micropython@57efb61 with pybricks/pybricks-code@7e726ff still not working:
dlech commentedon Oct 20, 2022
Can you do a Bluetooth packet capture as described at https://bleak.readthedocs.io/en/latest/troubleshooting.html#macos while trying to connect?
We changed the layout of the GATT attributes on the device and I have a hunch that macOS may be serving up a cached attribute database instead of reading it from the hub.
davidwu226 commentedon Oct 20, 2022
Sure, here's the capture from PacketLogger:
btcap.zip
davidwu226 commentedon Oct 20, 2022
@dlech I think your hunch is correct.
I cleared my Bluetooth cache and it seemed to work now:
https://stackoverflow.com/questions/20553957/how-can-i-clear-the-corebluetooth-cache-on-macos
davidwu226 commentedon Oct 20, 2022
Bummer... spoke too soon. Now the Bluetooth connects but the hub seems to crash and reset when I try to open up the interactive Python session.
dlech commentedon Oct 20, 2022
Thanks! I'm working on a fix to use random Bluetooth addresses to avoid the caching issues.
The REPL issue is also being worked on in #741.
laurensvalk commentedon Oct 20, 2022
REPL shouldn't currently crash, so feel free to open an issue if that persists.
laurensvalk commentedon Oct 20, 2022
Thanks for testing on the cutting edge. Hopefully it doesn't spoil your first impression of Pybricks 😅 .
dlech commentedon Oct 20, 2022
See #744 (comment) for workaround.
dlech commentedon Nov 26, 2022
It seems like this issue is resolved. Let us know if it isn't.
mrinalraghupathi commentedon Jan 30, 2023
I get the same error (randomly but not always) while running the following code on the robot inventor hub.
Mac OS: Ventura 13.2 (running Intel i5)
Chrome: Version 109.0.5414.119 (Official Build) (x86_64)
Code being run
Error message
mrinalraghupathi commentedon Jan 30, 2023
I was making a screencast to show folks how to use pybricks at the same time. It seems the error only happens when the screencast software is also running (OBS studio).