|
LSH-Core
A robust C++ framework for Arduino-based home automation nodes
|
Perform communication via Serial. More...
Functions | |
| void | init () |
| Init serial. | |
| void | sendJson (const JsonDocument &json) |
| Sends a JsonDocument via Serial. | |
| auto | receiveAndDispatch () -> Deserializer::DispatchResult |
| Reads from the communication serial port, processes complete messages, and dispatches commands. | |
| auto | canPing () -> bool |
| Ping minimum interval check. | |
| void | updateLastSentTime () |
| Set last time payload has been sent to now. | |
| auto | isConnected () -> bool |
| Checks if the ESP is considered connected. | |
Variables | |
| uint32_t | lastSentPayloadTime_ms = 0U |
| Last time a payload has been sent. | |
| uint32_t | lastReceivedPayloadTime_ms = 0U |
| Last time a valid payload has been received. | |
| bool | firstValidPayloadReceived = false |
| True after the first valid payload has been received. | |
| char | inputBuffer [constants::espComConfigs::RAW_INPUT_BUFFER_SIZE] |
| Raw buffer for incoming serial data. | |
| size_t | bytesRead = 0 |
| Number of bytes currently in the inputBuffer. | |
Perform communication via Serial.
| auto EspCom::canPing | ( | ) | -> bool |
Ping minimum interval check.


| auto EspCom::isConnected | ( | ) | -> bool |
Checks if the ESP is considered connected.
The assumption is based on having received a valid payload (like a PING or any other command) within the defined CONNECTION_TIMEOUT_MS.


| auto EspCom::receiveAndDispatch | ( | ) | -> Deserializer::DispatchResult |
Reads from the communication serial port, processes complete messages, and dispatches commands.
This function handles both MsgPack and JSON-newline protocols based on compilation flags. For JSON, it buffers incoming bytes until a newline is detected, then parses the message. For MsgPack, it attempts to deserialize directly from the stream. Upon receiving a valid message, it calls Deserializer::deserializeAndDispatch to execute the command.


| void EspCom::sendJson | ( | const JsonDocument & | json | ) |
Sends a JsonDocument via Serial.
| json | JsonDocument to be sent. |

