Repository navigation
Conversation
The serial driver drops RFCOMM hosts that don't send a Pybricks message within 5 seconds (e.g. the macOS Bluetooth panel, which opens the port when connecting). On NXT, this disconnect also stopped the Bluetooth process, which was only meant to happen on shutdown. Nothing could connect after that until the hub was restarted. Drop just the connection and go back to listening, as on BTstack. A shutdown still waits for the connection to close.
If the host closes the connection while the hub is sending (e.g. stdout at the end of a program), the BC4 can stop taking data without dropping the stream. The transmission then never finishes, which stalls stdout on all transports and leaves the BC4 unable to accept a new connection. Give up after 1 second, as the USB driver does after 500 ms, and drop the link. The BC4 does not take commands in this state, so go straight to the reset that restarts it instead of closing the connection first.
The BC4 was reset after every connection. This drops the radio link without telling the host, which then fails to connect again for a while (e.g. macOS keeps trying the old link). Each failed attempt ended in another reset, so reconnecting could fail indefinitely. Once the BC4 reports the connection closed, wait for the next one without a reset. Only reset it if it stops responding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Bluetooth on NXT getting stuck after a disconnect:
Known limitation: disconnecting mid-transfer still needs a BC4 reset, after which macOS fails the first reconnect attempt. Unsubscribing before closing avoids this.
Tested on hardware with a macOS host.