Refactor: Replace RemoteDebug with custom Logger and Telnet server#824
Open
robertlipe wants to merge 4 commits intoPlummersSoftwareLLC:mainfrom
Open
Refactor: Replace RemoteDebug with custom Logger and Telnet server#824robertlipe wants to merge 4 commits intoPlummersSoftwareLLC:mainfrom
robertlipe wants to merge 4 commits intoPlummersSoftwareLLC:mainfrom
Conversation
This commit removes the external RemoteDebug dependency and replaces it with a lightweight, project-tailored logging and console management infrastructure. Key changes: - Created ConsoleManager and ConsoleSession for multiplexing Serial and Telnet I/O with support for ANSI colors and line-ending policies. - Implemented a custom Logger that hooks into the ESP-IDF esp_log vprintf system, ensuring all system and library logs are captured and routed to all active console sessions. - Added a robust, BSD-socket based Telnet server (RFC 854) with protocol negotiation (WILL ECHO, WILL SGA) and state-machine based IAC/CRLF filtering. - Rewrote DebugCLI to use the new console system, featuring a zero-allocation tokenizer and improved tab completion. - Updated main.cpp and TaskManager to integrate the new services. - Removed RemoteDebug from platformio.ini. This change reduces binary size, improves memory efficiency, and provides a more reliable and extensible debugging interface.
This fixes the build error where F_GETFL, F_SETFL, and O_NONBLOCK were undefined in include/globals.h after the removal of RemoteDebug.h, which previously provided these headers.
…nding The variadic Logger template was attempting to bind a reference to packed struct fields in src/network.cpp (esp-now), which is an error. By passing by value in the default Unwrap case, we avoid this issue while still correctly specializing for String and std::string types.
The use of Args&&... in the variadic template was still attempting to bind references to packed struct fields before they reached Unwrap. By changing the template to take Args... (by value), we ensure all arguments are copied before binding, satisfying the compiler's restrictions on packed members.
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.
Description
This PR replaces the
RemoteDebuglibrary with a custom-built, lightweight logging and console management system. WhileRemoteDebugserved us well, it brought along unnecessary complexity and dependencies that didn't perfectly align with the project's long-term architectural goals.Key Improvements
ConsoleManager,ConsoleSession,Logger) that fits the project's specific needs.Loggerhooks directly into the ESP-IDFesp_logsystem. This means that logs from the system, third-party libraries, and our owndebugXmacros are all consistently captured and broadcast.std::string_viewfor zero-allocation parsing, and tab completion has been improved for both commands and effect names.Technical Details
vprintfhook uses a two-pass approach to measure and then allocate exactly the required heap memory for log lines.std::recursive_mutexinConsoleManagerto ensure thread-safe access to sinks during broadcasts and session management.\r\0/\r\nsequences correctly, even when split across packet boundaries.Validation
Verified on hardware: