Changes to connection_manager to handle Bluetooth on reset#122
Open
odessa19-code wants to merge 1 commit intotuanchris:mainfrom
Open
Changes to connection_manager to handle Bluetooth on reset#122odessa19-code wants to merge 1 commit intotuanchris:mainfrom
odessa19-code wants to merge 1 commit intotuanchris:mainfrom
Conversation
Fixed BT connection issues caused by sending $Bye to reset. changes to connect_device device_init perform_soft_reset_sync
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.
Fixed BT connection issues caused by sending $Bye to reset.
Key Structural Changes:
The current version now includes the Strict Match Check to prevent unnecessary reboots:
Original: Always performed a soft reset and wait, then checked if homing was needed.
Current: Now queries machine position first. If the coordinates (rounded to 2 decimal places) match the saved state, it returns True immediately, bypassing the reset entirely to preserve the Bluetooth link.
This function was completely rewritten to be "connection-aware":
Original: Used a complex exponential backoff and looked for specific string responses ("Grbl", "FluidNC") which often failed when the Bluetooth buffer cleared during a reboot.
Current: * Catches Exceptions: It now specifically handles the Input/output error (Errno 5) that occurs when the ESP32 drops the Bluetooth link during a reboot.
Stabilization Sleep: Adds a mandatory time.sleep(2.0) after sending $Bye to allow the OS and Bluetooth driver to stabilize.
Kept New Diagnostics: It still retains the improved logging for firmware versions and pre-reset positions from the repo update.
Bluetooth Delay: Added a time.sleep(3.0) specifically for rfcomm ports to ensure the handshake is complete before sending the first G-code command.
Init Flag: The signature was changed to connect_device(homing=True, init=True), allowing for more granular control over whether the device initializes or just establishes a socket connection.