Skip to content

Changes to connection_manager to handle Bluetooth on reset#122

Open
odessa19-code wants to merge 1 commit intotuanchris:mainfrom
odessa19-code:main
Open

Changes to connection_manager to handle Bluetooth on reset#122
odessa19-code wants to merge 1 commit intotuanchris:mainfrom
odessa19-code:main

Conversation

@odessa19-code
Copy link
Contributor

Fixed BT connection issues caused by sending $Bye to reset.

Key Structural Changes:

  1. device_init (Position Sync Logic)
    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.

  1. perform_soft_reset_sync (The Bluetooth Fix)
    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.

  1. connect_device (Stabilization)
    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.

Fixed BT connection issues caused by sending $Bye to reset. 

changes to 

connect_device
device_init
perform_soft_reset_sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant