Skip to content

MiPDebug

github-actions[bot] edited this page Aug 10, 2026 · 7 revisions

Class MiPDebug

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

Detailed Description

Inherits from Arduino's Print class to support formatted output methods (print, println, printf) over telnet network connections and optional hardware Serial.

Table of Contents


Public Functions

begin

Signature: void begin(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 to route to 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, false to disallow.

setHelpProjectsCmds

Signature: void setHelpProjectsCmds(String help)

Summary: Sets custom project help text displayed when a telnet client sends the 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()

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

Returns: String containing the command text.


clearLastCommand

Signature: void clearLastCommand()

Summary: Clears the internal last-command buffer string.


showTime

Signature: void showTime(bool show)

Summary: Configures whether timestamps (in milliseconds) 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 milliseconds required to trigger profiler output.

showDebugLevel

Signature: void showDebugLevel(bool show)

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

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 telnet 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 milliseconds between loop iterations.

setFilter

Signature: void setFilter(String filter)

Summary: Applies a text filter string to debug outputs.

Parameters:

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

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 specified level meets or exceeds active threshold; false otherwise.


write

Signature: size_t write(uint8_t byte) override

Summary: Writes a single byte to active debug channels (Stream/Print override).

Parameters:

Parameter Description
byte Character byte to output.

Returns: Number of bytes written (1 on success).


write

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

Summary: Writes a byte buffer to active debug channels (Stream/Print override).

Parameters:

Parameter Description
buffer Pointer to character array to output.
size Number of bytes in buffer.

Returns: Number of bytes successfully written.


expand

Signature: String expand(String string)

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

Parameters:

Parameter Description
string Input string containing raw control characters.

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


Public Variables

PROFILER

Signature: const uint8_t PROFILER

Details:

Used to display execution timing of code sections (profiler).


VERBOSE

Signature: const uint8_t VERBOSE

Details:

Used to display detailed verbose messages.


DEBUG

Signature: const uint8_t DEBUG

Details:

Used to display standard debug messages.


INFO

Signature: const uint8_t INFO

Details:

Used to display informational status messages.


WARNING

Signature: const uint8_t WARNING

Details:

Used to display warning messages.


ERROR

Signature: const uint8_t ERROR

Details:

Used to display critical error messages.


ANY

Signature: const uint8_t ANY

Details:

Used to display messages unconditionally at any active level.


Clone this wiki locally