Skip to content

MiPDebug

github-actions[bot] edited this page Aug 11, 2026 · 9 revisions

Class MiPDebug

Telnet and Serial debug server for real-time remote diagnostics.

Table of Contents


Public Functions

begin

Signature: void begin(const String &hostname, uint8_t startingDebugLevel=VERBOSE)

Summary: Initializes and starts the telnet debug server.

Parameters:

Parameter Description
hostname Hostname broadcast by the telnet service.
startingDebugLevel Initial active debug threshold (default: VERBOSE).

stop

Signature: void stop()

Summary: Stops the telnet debug server and disconnects active clients.


handle

Signature: void handle()

Summary: Service loop handler for maintaining telnet client connections and processing commands.


setSerialEnabled

Signature: void setSerialEnabled(bool enable)

Summary: Configures whether debug messages are echoed to HardwareSerial.

Parameters:

Parameter Description
enable true to duplicate output to Serial, false for telnet only.

setResetCmdEnabled

Signature: void setResetCmdEnabled(bool enable)

Summary: Configures whether the telnet server allows remote system reset commands.

Parameters:

Parameter Description
enable true to allow remote ESP8266 reset via telnet command.

setHelpProjectsCmds

Signature: void setHelpProjectsCmds(const String &help)

Summary: Sets custom project help text displayed on telnet help command.

Parameters:

Parameter Description
help Formatting string detailing sketch-specific commands.

setCallBackProjectCmds

Signature: void setCallBackProjectCmds(void(*callback)())

Summary: Registers a callback handler for custom sketch/project telnet commands.

Parameters:

Parameter Description
callback Function pointer executed when a custom command is received.

getLastCommand

Signature: String getLastCommand() const

Summary: Retrieves the last command string received from the connected telnet client.

Returns: String containing command text.


clearLastCommand

Signature: void clearLastCommand()

Summary: Clears internal last-command buffer string.


showTime

Signature: void showTime(bool show)

Summary: Configures whether timestamps (in ms) are prepended to log outputs.

Parameters:

Parameter Description
show true to show timestamps, false to omit.

showProfiler

Signature: void showProfiler(bool show, uint32_t minTime=0)

Summary: Configures execution profiler logging between consecutive prints.

Parameters:

Parameter Description
show true to show elapsed execution time, false to omit.
minTime Minimum elapsed time threshold in ms required to trigger profiler output.

showDebugLevel

Signature: void showDebugLevel(bool show)

Summary: Configures whether debug severity tags ([INFO], [DEBUG], etc.) are prepended.

Parameters:

Parameter Description
show true to show level tags, false to omit.

showColors

Signature: void showColors(bool show)

Summary: Configures whether ANSI color codes are included in log output.

Parameters:

Parameter Description
show true to enable color codes, false for plain text.

autoProfilerLevel

Signature: void autoProfilerLevel(uint32_t millisElapsed)

Summary: Automatically switches logging level to PROFILER if elapsed time exceeds threshold.

Parameters:

Parameter Description
millisElapsed Threshold duration in ms between loop iterations.

setFilter

Signature: void setFilter(const String &filter)

Summary: Applies a text filter string to debug outputs.

Parameters:

Parameter Description
filter Substring filter; only log lines containing this string will print.

setNoFilter

Signature: void setNoFilter()

Summary: Removes any active text filter string.


isActive

Signature: bool isActive(uint8_t debugLevel=DEBUG)

Summary: Checks if logging output is active for the specified debug level.

Parameters:

Parameter Description
debugLevel Target debug level to check (default: DEBUG).

Returns: true if level meets or exceeds active threshold; false otherwise.


write

Signature: size_t write(uint8_t byte) override


write

Signature: size_t write(const uint8_t *buffer, size_t size) override


expand

Signature: String expand(const String &string)

Summary: Helper method to expand CR/LF control characters into literal "\r" and "\n".

Parameters:

Parameter Description
string Input string containing raw control characters.

Returns: String with CR/LF replaced by escaped representations.


Public Variables

PROFILER

Signature: constexpr uint8_t PROFILER

Summary: Execution timing section profiling.


VERBOSE

Signature: constexpr uint8_t VERBOSE

Summary: Detailed verbose messages.


DEBUG

Signature: constexpr uint8_t DEBUG

Summary: Standard debug messages.


INFO

Signature: constexpr uint8_t INFO

Summary: Informational status messages.


WARNING

Signature: constexpr uint8_t WARNING

Summary: Warning messages.


ERROR

Signature: constexpr uint8_t ERROR

Summary: Critical error messages.


ANY

Signature: constexpr uint8_t ANY

Summary: Messages output unconditionally.


TELNET_PORT

Signature: constexpr uint16_t TELNET_PORT

Summary: Default TCP telnet port (23).


Clone this wiki locally