-
Notifications
You must be signed in to change notification settings - Fork 145
add onDeviceLostCallback to recover lost device #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Download the artifacts for this pull request: |
|
Hi @tyeth Thank you for testing and review this PR. I've added the configurable timeout and a retry loop with configurable max retries. Pleas take a look when you can. The reconnect button was an initial idea I had but is better that is does this automatically so I remove such idea, that was a leftover log output I also fixed. |
|
Thanks Brian, yeah you're right to call our the PID/VID changes, but my hope was that once the user has had the device in bootloader/JTAG-serial mode once, and additionally connected in normal running mode (circuitpython CDC / tinyusb serial) once, then we'd have access to both forever in reconnection terms. I should probably test that theory before getting too excited... With the C3 / huzzah32 v1, I wonder if there's a way to make the disconnect / timeout occur more quickly, or on a related note if we can detect timeouts more rapidly in the initial stages (before large reads/writes of the flash as that is obviously much more likely to timeout). I also wonder if we can do anything after a timeout in the early stages, like does disconnecting the serial port (even though the transport is dead) help at all, and would the board be able to run esptool again without physically disconnecting or rebooting the device. That of course assumes that calling disconnect or whatever doesn't stall indefinitely or for too long to be useful in UI feedback terms. |





Description
This pull request adds robust device reconnection support to the TypeScript example, improving the user experience when a serial device is unexpectedly disconnected. The main changes include tracking device info for reconnection, implementing a callback for device loss, and refactoring the console reading loop to support automatic reconnection.
Device reconnection and management:
deviceInfoto store USB vendor and product IDs, enabling identification and reconnection to the same device after disconnection. [1] [2] [3]Transportclass and set it up in the UI logic, allowing the app to detect when the device is lost and attempt to reconnect automatically. [1] [2] [3]Console reading and reconnection logic:
startConsoleReadingfunction, which handles errors and waits for reconnection if the device is lost.These changes make the application more resilient to device disconnects, providing a smoother workflow for users interacting with serial devices.
Checklist
Before submitting a Pull Request, please ensure the following: