LCC Fusion Project 1.0
LCC Automation
Loading...
Searching...
No Matches
LccNodeSerialMonitor Class Reference

Provides monitoring and message output for serial, Bluetooth, and WebSerial. More...

#include <LccNodeSerialMonitor.h>

Inherits openlcb::Polling.

Public Member Functions

 LccNodeSerialMonitor (uint8_t monitorIntervalSec=1)
 Constructor. More...
 
void begin (const openlcb::NodeID nodeID, BluetoothSerial *serialBT)
 Initialize the monitor with the node ID and BluetoothSerial instance. More...
 
Polling * polling ()
 Expose this object for integration with the OpenLCB polling loop. More...
 
void poll_33hz (openlcb::WriteHelper *helper, Notifiable *done) OVERRIDE
 Poll callback (33Hz) - part of openlcb::Polling interface. More...
 
void sendColoredText (const char *text, const char *colorCode=BLACK_TEXT, bool crlf=true)
 Send colored text using ANSI escape sequences. More...
 
void setEcho (bool state)
 Enable or disable echo of received data back to source. More...
 
void processSerial ()
 Poll and process UART and Bluetooth data, routing accordingly.
 
void print (const char *format,...)
 Print a formatted message to all enabled outputs. More...
 
void println (const char *format,...)
 Print a formatted message followed by CRLF to all enabled outputs. More...
 
size_t available () const
 How many bytes are waiting to be read from the selected interface. More...
 
int read ()
 Read one character from whichever interface has data first. More...
 
String readLine (char terminator='\n', size_t maxLen=MAX_MESSAGE_SIZE)
 Read until a terminator (default '
') or maxLen, returning a trimmed Arduino String. More...
 

Private Member Functions

void _output (const char *msg)
 Internal method to send or queue output to interfaces. More...
 
void _flushBt ()
 Flush queued Bluetooth messages when a client is connected.
 

Detailed Description

Provides monitoring and message output for serial, Bluetooth, and WebSerial.

This class inherits from openlcb::Polling to integrate with the LCC event loop.

Definition at line 88 of file LccNodeSerialMonitor.h.

Constructor & Destructor Documentation

◆ LccNodeSerialMonitor()

LccNodeSerialMonitor::LccNodeSerialMonitor ( uint8_t  monitorIntervalSec = 1)
inline

Constructor.

Parameters
monitorIntervalSecInterval in seconds between polls

Definition at line 106 of file LccNodeSerialMonitor.h.

Member Function Documentation

◆ _output()

void LccNodeSerialMonitor::_output ( const char *  msg)
inlineprivate

Internal method to send or queue output to interfaces.

Parameters
msgNull-terminated string to output

Definition at line 332 of file LccNodeSerialMonitor.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ available()

size_t LccNodeSerialMonitor::available ( ) const
inline

How many bytes are waiting to be read from the selected interface.

Checks, in order:

  • Hardware Serial (if enabled)
  • BluetoothSerial (if enabled and connected)
  • WebSerial (if enabled)
Returns
total bytes available, or 0 if none

Definition at line 259 of file LccNodeSerialMonitor.h.

◆ begin()

void LccNodeSerialMonitor::begin ( const openlcb::NodeID  nodeID,
BluetoothSerial *  serialBT 
)
inline

Initialize the monitor with the node ID and BluetoothSerial instance.

Parameters
nodeIDIdentifier for the LCC node (for BT device naming).
serialBTPointer to a BluetoothSerial object for SPP communication.

Definition at line 114 of file LccNodeSerialMonitor.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poll_33hz()

void LccNodeSerialMonitor::poll_33hz ( openlcb::WriteHelper *  helper,
Notifiable *  done 
)
inline

Poll callback (33Hz) - part of openlcb::Polling interface.

Parameters
helperUnused write helper
doneNotifiable to signal completion

Definition at line 155 of file LccNodeSerialMonitor.h.

◆ polling()

Polling * LccNodeSerialMonitor::polling ( )
inline

Expose this object for integration with the OpenLCB polling loop.

Returns
Pointer to Polling interface

Definition at line 146 of file LccNodeSerialMonitor.h.

◆ print()

void LccNodeSerialMonitor::print ( const char *  format,
  ... 
)
inline

Print a formatted message to all enabled outputs.

Parameters
formatprintf-style format string
...Arguments for format

Definition at line 221 of file LccNodeSerialMonitor.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ println()

void LccNodeSerialMonitor::println ( const char *  format,
  ... 
)
inline

Print a formatted message followed by CRLF to all enabled outputs.

Parameters
formatprintf-style format string
...Arguments for format

Definition at line 236 of file LccNodeSerialMonitor.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

int LccNodeSerialMonitor::read ( )
inline

Read one character from whichever interface has data first.

Call available() first to know there’s data waiting.

Returns
the byte (0–255), or -1 if nothing was available

Definition at line 279 of file LccNodeSerialMonitor.h.

Here is the caller graph for this function:

◆ readLine()

String LccNodeSerialMonitor::readLine ( char  terminator = '\n',
size_t  maxLen = MAX_MESSAGE_SIZE 
)
inline

Read until a terminator (default '
') or maxLen, returning a trimmed Arduino String.

Parameters
terminatorcharacter to stop at (not included in result)
maxLenmaximum number of characters to collect
Returns
the collected String (empty if none available)

Definition at line 302 of file LccNodeSerialMonitor.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendColoredText()

void LccNodeSerialMonitor::sendColoredText ( const char *  text,
const char *  colorCode = BLACK_TEXT,
bool  crlf = true 
)
inline

Send colored text using ANSI escape sequences.

Parameters
textThe text to send
colorCodeANSI color code string (e.g. RED_TEXT)
crlfAppend CRLF if true

Definition at line 165 of file LccNodeSerialMonitor.h.

Here is the call graph for this function:

◆ setEcho()

void LccNodeSerialMonitor::setEcho ( bool  state)
inline

Enable or disable echo of received data back to source.

Parameters
stateTrue to echo input, false to suppress

Definition at line 175 of file LccNodeSerialMonitor.h.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: