Controller-side serial link used to exchange payloads with lsh-bridge.
More...
Classes | |
| struct | ReceiveResult |
Functions | |
| void | init () |
Initialize the serial port used to talk with lsh-bridge. | |
| auto | receiveAndDispatch (uint16_t maxBytesToConsume) -> ReceiveResult |
| Consume a bounded amount of serial input and dispatch at most one payload. | |
| void | tickSendIdleTimer (uint16_t elapsed_ms) |
Advance the ping idle timer used by canPing(). | |
| auto | canPing () -> bool |
| Check whether the bridge link may emit another heartbeat. | |
| void | updateLastSentTime () |
| Record that a payload has just been transmitted to the bridge. | |
| auto | isConnected () -> bool |
| Check whether the bridge is still considered connected. | |
Controller-side serial link used to exchange payloads with lsh-bridge.
| auto BridgeSerial::canPing | ( | ) | -> bool |
Check whether the bridge link may emit another heartbeat.
Heartbeats are rate-limited using PING_INTERVAL_MS so the controller does not flood the serial line when the rest of the loop is otherwise idle.

| void BridgeSerial::init | ( | ) |
Initialize the serial port used to talk with lsh-bridge.
The controller and the bridge share one hardware serial link. This helper applies the configured baud rate once during startup so every later send/receive path can assume the port is already ready.

| auto BridgeSerial::isConnected | ( | ) | -> bool |
Check whether the bridge is still considered connected.
The bridge is considered online only after the first valid payload has reset the receive idle age and only while the receive timeout window stays open. The age is advanced once by the main loop using the shared bridge-housekeeping delta, avoiding 32-bit timestamp subtraction in network-click routing.

| auto BridgeSerial::receiveAndDispatch | ( | uint16_t | maxBytesToConsume | ) | -> ReceiveResult |
Consume a bounded amount of serial input and dispatch at most one payload.
This helper is intentionally bounded both by bytes and by payload count. The caller can therefore keep the controller loop fair even if the UART is carrying noise, truncated frames or a long burst of valid commands.
| maxBytesToConsume | Maximum number of raw UART bytes this call may drain. |


| void BridgeSerial::tickSendIdleTimer | ( | uint16_t | elapsed_ms | ) |
Advance the ping idle timer used by canPing().
The main loop computes one cached elapsed time for bridge housekeeping and feeds it here. Reusing that delta avoids another 32-bit timestamp comparison in canPing() while keeping bridge-link liveness independent from the clickable scan policy.
| elapsed_ms | Milliseconds elapsed since the previous bridge housekeeping pass. |

| void BridgeSerial::updateLastSentTime | ( | ) |
Record that a payload has just been transmitted to the bridge.
Any successful send resets the idle age to zero so the next ping cannot be emitted until the serial line stayed quiet for the full heartbeat interval again.