Provides monitoring and message output for serial, Bluetooth, and WebSerial.
More...
#include <LccNodeSerialMonitor.h>
Inherits openlcb::Polling.
|
| | 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...
|
| |
|
| 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.
|
| |
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.
◆ LccNodeSerialMonitor()
| LccNodeSerialMonitor::LccNodeSerialMonitor |
( |
uint8_t |
monitorIntervalSec = 1 | ) |
|
|
inline |
Constructor.
- Parameters
-
| monitorIntervalSec | Interval in seconds between polls |
Definition at line 106 of file LccNodeSerialMonitor.h.
◆ _output()
| void LccNodeSerialMonitor::_output |
( |
const char * |
msg | ) |
|
|
inlineprivate |
Internal method to send or queue output to interfaces.
- Parameters
-
| msg | Null-terminated string to output |
Definition at line 332 of file LccNodeSerialMonitor.h.
◆ 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
-
| nodeID | Identifier for the LCC node (for BT device naming). |
| serialBT | Pointer to a BluetoothSerial object for SPP communication. |
Definition at line 114 of file LccNodeSerialMonitor.h.
◆ poll_33hz()
| void LccNodeSerialMonitor::poll_33hz |
( |
openlcb::WriteHelper * |
helper, |
|
|
Notifiable * |
done |
|
) |
| |
|
inline |
Poll callback (33Hz) - part of openlcb::Polling interface.
- Parameters
-
| helper | Unused write helper |
| done | Notifiable 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
-
| format | printf-style format string |
| ... | Arguments for format |
Definition at line 221 of file LccNodeSerialMonitor.h.
◆ println()
| void LccNodeSerialMonitor::println |
( |
const char * |
format, |
|
|
|
... |
|
) |
| |
|
inline |
Print a formatted message followed by CRLF to all enabled outputs.
- Parameters
-
| format | printf-style format string |
| ... | Arguments for format |
Definition at line 236 of file LccNodeSerialMonitor.h.
◆ 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.
◆ 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
-
| terminator | character to stop at (not included in result) |
| maxLen | maximum number of characters to collect |
- Returns
- the collected String (empty if none available)
Definition at line 302 of file LccNodeSerialMonitor.h.
◆ sendColoredText()
| void LccNodeSerialMonitor::sendColoredText |
( |
const char * |
text, |
|
|
const char * |
colorCode = BLACK_TEXT, |
|
|
bool |
crlf = true |
|
) |
| |
|
inline |
Send colored text using ANSI escape sequences.
- Parameters
-
| text | The text to send |
| colorCode | ANSI color code string (e.g. RED_TEXT) |
| crlf | Append CRLF if true |
Definition at line 165 of file LccNodeSerialMonitor.h.
◆ setEcho()
| void LccNodeSerialMonitor::setEcho |
( |
bool |
state | ) |
|
|
inline |
Enable or disable echo of received data back to source.
- Parameters
-
| state | True to echo input, false to suppress |
Definition at line 175 of file LccNodeSerialMonitor.h.
The documentation for this class was generated from the following file: