Skip to content

[Bug] GATT operation failed for unknown reasons. with Spike Prime Hub #740

Closed

Description

@davidwu226

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:

  1. Check out pybricks-micropython at b83536e69693e64e312343ec6b9a79c513fdc24f
  2. Deploy to Spike Prime Hub.
  3. Go to beta.pybricks.com and connect via Bluetooth.
  4. See error.

Expected behavior
The editor should have connected to the hub via bluetooth.

Screenshots
Screen Shot 2022-10-19 at 4 41 41 PM

Activity

  1. added
    triage
    on Oct 19, 2022
  2. dlech commented on Oct 20, 2022

    @dlech
    Member

    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?

  3. added
    topic: bluetooth
    on Oct 20, 2022
  4. davidwu226 commented on Oct 20, 2022

    @davidwu226
    Author

    I'm on Mac OSX 12.4 (M1-based) with Chrome 106.0.5249.119.

    Here's from the copy error message:

    GATT operation failed for unknown reason.
    
  5. added
    OS: macOS
    and removed
    triage
    on Oct 20, 2022
  6. laurensvalk commented on Oct 20, 2022

    @laurensvalk
    Member

    Check out pybricks-micropython at pybricks/pybricks-micropython@b83536e

    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.
  7. davidwu226 commented on Oct 20, 2022

    @davidwu226
    Author

    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.

  8. laurensvalk commented on Oct 20, 2022

    @laurensvalk
    Member

    As I mentioned, the previous commit (ed2e584) worked without problems.

    Right, anything before those Bluetooth changes is supposed to work with https://beta.pybricks.com/ up to today.

    And yes, I did try the latest version of the master branch (which also does not work)

    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!

  9. davidwu226 commented on Oct 20, 2022

    @davidwu226
    Author

    Just tried pybricks/pybricks-micropython@57efb61 with pybricks/pybricks-code@7e726ff still not working:

    No Characteristics matching UUID c5f50003-8280-46da-89f4-6d8051e4aeef found in Service with UUID c5f50001-8280-46da-89f4-6d8051e4aeef.
    
  10. dlech commented on Oct 20, 2022

    @dlech
    Member

    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.

  11. davidwu226 commented on Oct 20, 2022

    @davidwu226
    Author

    Sure, here's the capture from PacketLogger:

    btcap.zip

  12. davidwu226 commented on Oct 20, 2022

    @davidwu226
    Author
  13. davidwu226 commented on Oct 20, 2022

    @davidwu226
    Author

    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.

  14. dlech commented on Oct 20, 2022

    @dlech
    Member

    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.

  15. laurensvalk commented on Oct 20, 2022

    @laurensvalk
    Member

    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.

    The REPL issue is also being worked on in #741.

    REPL shouldn't currently crash, so feel free to open an issue if that persists.

  16. laurensvalk commented on Oct 20, 2022

    @laurensvalk
    Member

    Thanks for testing on the cutting edge. Hopefully it doesn't spoil your first impression of Pybricks 😅 .

  17. dlech commented on Oct 20, 2022

    @dlech
    Member

    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.

    See #744 (comment) for workaround.

  18. dlech commented on Nov 26, 2022

    @dlech
    Member

    It seems like this issue is resolved. Let us know if it isn't.

  19. mrinalraghupathi commented on Jan 30, 2023

    @mrinalraghupathi

    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

    from pybricks.hubs import InventorHub
    from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor
    from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
    from pybricks.robotics import DriveBase
    from pybricks.tools import wait, StopWatch
    
    hub = InventorHub()
    
    hub.light.on(color=Color.RED)
    
    wait(1000)
    

    Error message

    GATT operation failed for unknown reason.
    
  20. mrinalraghupathi commented on Jan 30, 2023

    @mrinalraghupathi

    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).

  21. added theissue type on Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS: macOStopic: bluetooth

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions