add flash and monitor command
Fix #194
Description
This pull request adds a new "Flash & Monitor" feature to the TypeScript example application, allowing users to flash a device and immediately start monitoring its console output. The changes include updates to the UI, integration of new button logic, and enhancements to the ESPLoader class to support this workflow.
Flash & Monitor feature integration:
-
Added a new "Flash & Monitor" button to the UI (
index.html) and connected it in the TypeScript code, including logic to show/hide the button based on device connection state. [1] [2] [3] [4] [5] -
Implemented the handler for the "Flash & Monitor" button, which validates inputs, flashes selected files to the device, and then starts console monitoring at the specified baud rate. Progress bars and UI states are updated accordingly.
Console monitoring enhancements:
-
Added new methods to the
ESPLoaderclass:flashAndMonitor,startConsoleMonitoring, andstopConsoleMonitoring, enabling the ability to flash and then monitor the device console in one workflow, with error handling and support for custom baud rates. -
Updated console start/stop logic to use the new monitoring methods, display device info, and handle errors more robustly, including proper cleanup and UI state management after stopping the console. [1] [2] [3]
General improvements and cleanup:
-
Ensured device and loader objects are properly reset in the cleanup logic to prevent stale references after disconnecting.
-
Minor UI and error handling improvements throughout the program and flash workflows. [1] [2]
Testing
Click Connect device and then Flash & Monitor using examples/typescript project.
Checklist
Before submitting a Pull Request, please ensure the following:
- [ ] 🚨 This PR does not introduce breaking changes.
- [ ] All CI checks (GH Actions) pass.
- [ ] Documentation is updated as needed.
- [ ] Tests are updated or added as necessary.
- [ ] Code is well-commented, especially in complex areas.
- [ ] Git history is clean — commits are squashed to the minimum necessary.