|
LCC Fusion Project 1.0
LCC Automation
|
General-purpose input handler for text-based packets over multiple transports. More...
#include <SerialIO.h>

Public Member Functions | |
| void | onHelpRequest (const HelpHandler &cb) |
| Install a callback to run whenever the user sends just "?". More... | |
| void | onTestRequest (const TestHandler &cb) |
| Install a callback to run whenever the user sends just "T". More... | |
| void | onProgramRequest (const ProgramHandler &cb) |
| Install a callback to run whenever the user sends just "P". More... | |
| void | begin (uint8_t baseAddr=0, uint8_t sdaPin=0, uint8_t sclPin=0, uint8_t addrPin1=0, uint8_t addrPin2=0, uint8_t addrPin3=0) |
| Initialize all requested interfaces. More... | |
| const char * | getWebSSID () const |
| Retrieve the WebSerial SSID in use. More... | |
| String | getWebURL () const |
| Get the URL for the WebSerial interface. More... | |
| const char * | getBTName () const |
| Get the active Bluetooth device name (with I²C suffix if present). More... | |
| bool | available () const |
| Check if any input interface has pending data. More... | |
| bool | read () |
| Read one complete packet from any interface. More... | |
| void | parse_reset () |
| Reset the internal parse state so the next parse(...) call starts from the beginning of commandBuffer. | |
| template<typename... Outs> | |
| int | parse (bool expectBrackets, Outs &...outs) |
| Token-pointer parser: split space-delimited args, optionally requiring <...>. More... | |
| void | displayConnectionInfo () |
| Print currently active connection endpoints to all consoles. More... | |
| uint8_t | getI2cOffset () |
| Return the current I²C address offset (0..7) determined from pins. More... | |
| void | print (const char *msg) |
| Print a string to all active consoles. More... | |
| void | sprintf (const char *fmt,...) |
| printf-style logging to all active consoles (no newline). More... | |
| void | sprintlnf (const char *fmt,...) |
| printf-style logging with newline (like println()). More... | |
| void | println (const char *msg) |
| Print a line (with \n) to all active consoles. More... | |
| template<typename... Args> | |
| void | printf (const char *fmt, Args... args) |
| printf-style logging to all active consoles (no newline). More... | |
Public Attributes | |
| char | commandBuffer [CMD_BUF_SIZE] = {0} |
| Raw command content without '<' or '>'. | |
Private Member Functions | |
| bool | _readSerial () |
| Read from UART into commandBuffer until '>' is received. More... | |
| bool | _readBluetooth () |
| Read from BluetoothSerial into commandBuffer until '>' is received. More... | |
| void | _vprintfAll (bool withNl, const char *fmt, va_list ap) |
| Internal helper: format once and fan-out to all enabled consoles. More... | |
Static Private Member Functions | |
| static uint8_t | _computeI2cAddr (uint8_t base, uint8_t pin1, uint8_t pin2, uint8_t pin3) |
| Compute I²C address from base + three address pins (active-low). More... | |
| static void | _onI2cReceive (int) |
| I²C receive ISR callback: buffers chars between '<' and '>'. More... | |
| static void | _onWebReceive (uint8_t *data, size_t len) |
| WebSerial message callback: buffers chars between '<' and '>'. More... | |
General-purpose input handler for text-based packets over multiple transports.
Commands are ASCII strings wrapped in angle brackets:
The brackets are not stored; payload is placed in commandBuffer as a C string.
Definition at line 97 of file SerialIO.h.
|
inlinestaticprivate |
Compute I²C address from base + three address pins (active-low).
Each pin is sampled with INPUT_PULLUP. A LOW reads as '1' in the offset. The resulting 3-bit offset (0..7) is added to base.
| base | Base 7-bit I²C address. |
| pin1 | LSB select pin (active-low). |
| pin2 | Middle select pin (active-low). |
| pin3 | MSB select pin (active-low). |
Definition at line 725 of file SerialIO.h.

|
inlinestaticprivate |
I²C receive ISR callback: buffers chars between '<' and '>'.
Incoming bytes are appended into a static buffer. A '<' clears the buffer. A '>' marks end-of-packet; the function leaves the buffer intact for read(). Extra characters beyond CMD_BUF_SIZE-1 are dropped.
Definition at line 747 of file SerialIO.h.

|
inlinestaticprivate |
WebSerial message callback: buffers chars between '<' and '>'.
Accumulates characters into a static buffer; '<' clears, '>' ends. Content is later consumed by read() if useWeb_ is true.
Definition at line 840 of file SerialIO.h.

|
inlineprivate |
Read from BluetoothSerial into commandBuffer until '>' is received.
Definition at line 806 of file SerialIO.h.

|
inlineprivate |
Read from UART into commandBuffer until '>' is received.
Definition at line 776 of file SerialIO.h.

|
inlineprivate |
Internal helper: format once and fan-out to all enabled consoles.
| withNl | If true, append a single '\n' to the formatted message. |
| fmt | printf-style format string. |
| ap | varargs list. |
Definition at line 872 of file SerialIO.h.


|
inline |
Check if any input interface has pending data.
Definition at line 275 of file SerialIO.h.
|
inline |
Initialize all requested interfaces.
Brings up any subset of:
Serial),HAS_BT_CLASSIC==1 and BT_DEVICE_NAME is defined),WEB_SSID is defined; optional WEB_PASS),baseAddr > 0; address select pins provide offset 0..7).Configuration is controlled at compile time:
BT_DEVICE_NAME as a string literal (e.g., -DBT_DEVICE_NAME="LccFusion") and set HAS_BT_CLASSIC=1 on targets that support BT Classic (original ESP32). On targets without BT Classic (e.g., ESP32-S3), set HAS_BT_CLASSIC=0 and this feature is compiled out.WEB_SSID (and optionally WEB_PASS) to enable the Wi-Fi AP + WebSerial. When useI2C_ is true, the SSID is suffixed with the 7-bit I²C address.| baseAddr | Base 7-bit I²C address; 0 disables I²C target mode. |
| sdaPin | SDA pin for I²C. |
| sclPin | SCL pin for I²C. |
| addrPin1 | LSB I²C address select pin. |
| addrPin2 | Mid I²C address select pin. |
| addrPin3 | MSB I²C address select pin. |
HAS_BT_CLASSIC==0. Use USB-CDC or a BLE UART instead. Definition at line 167 of file SerialIO.h.


|
inline |
Print currently active connection endpoints to all consoles.
Prints Bluetooth device name (if BT active) and, if WebSerial is active, waits briefly for AP to start then prints SSID and URL. On error, prints a WebSerial-not-started message.
Definition at line 561 of file SerialIO.h.


|
inline |
Get the active Bluetooth device name (with I²C suffix if present).
Definition at line 265 of file SerialIO.h.

|
inline |
Return the current I²C address offset (0..7) determined from pins.
Definition at line 585 of file SerialIO.h.

|
inline |
Retrieve the WebSerial SSID in use.
Definition at line 240 of file SerialIO.h.

|
inline |
Get the URL for the WebSerial interface.
Definition at line 249 of file SerialIO.h.

|
inline |
Install a callback to run whenever the user sends just "?".
| cb | Callable invoked when a single-question-mark packet is received. The packet is swallowed and not returned by read(). |
Definition at line 112 of file SerialIO.h.

|
inline |
Install a callback to run whenever the user sends just "P".
| cb | Callable invoked when a single 'P' packet is received. The packet is swallowed and not returned by read(). |
Definition at line 132 of file SerialIO.h.

|
inline |
Install a callback to run whenever the user sends just "T".
| cb | Callable invoked when a single 'T' packet is received. The packet is swallowed and not returned by read(). |
Definition at line 122 of file SerialIO.h.

|
inline |
Token-pointer parser: split space-delimited args, optionally requiring <...>.
Accepts two input styles in commandBuffer: • Plain: "arg1 arg2 ..." • Bracketed: "< arg1 arg2 ... >"
Behavior:
expectBrackets is true, input MUST be framed with '<' ... '>'. Brackets are stripped before tokenizing. If missing/invalid, returns 0.expectBrackets is false, both styles are accepted. Well-formed brackets (if present) are stripped; otherwise '<' and '>' are ordinary chars.Delimiter: single space ' ' (tabs are not treated as delimiters).
| Outs | Variadic pack where every parameter is a char*& to receive a token pointer. |
| expectBrackets | Require "< ... >" framing if true. |
| outs | char*& outputs (pointers into commandBuffer tokens). |
outs (0..N).strtok on commandBuffer (modifies it). Returned pointers remain valid until commandBuffer is overwritten.Definition at line 470 of file SerialIO.h.

|
inline |
Print a string to all active consoles.
| msg | NUL-terminated C string to send (no newline appended). |
Definition at line 595 of file SerialIO.h.


|
inline |
printf-style logging to all active consoles (no newline).
| fmt | printf-style format string. |
| args | Arguments for fmt. |
Definition at line 668 of file SerialIO.h.


|
inline |
Print a line (with \n) to all active consoles.
| msg | NUL-terminated C string; a single '\n' is appended. |
Definition at line 640 of file SerialIO.h.


|
inline |
Read one complete packet from any interface.
Consumes characters until a closing '>' is seen (or a whole buffered packet is available from WebSerial/I²C). The payload between '<' and '>' is copied into commandBuffer as a C string. A single "?" packet triggers helpHandler_ (if installed) and is not returned to the caller.
Definition at line 300 of file SerialIO.h.


|
inline |
printf-style logging to all active consoles (no newline).
| fmt | NUL-terminated C string. |
Definition at line 617 of file SerialIO.h.


|
inline |
printf-style logging with newline (like println()).
| fmt | NUL-terminated C string. |
Definition at line 628 of file SerialIO.h.

