LSH-Core
Deterministic firmware core for Controllino-based Labo Smart Home nodes
 
Loading...
Searching...
No Matches
bridge_serial.hpp
Go to the documentation of this file.
1
21#ifndef LSH_CORE_COMMUNICATION_BRIDGE_SERIAL_HPP
22#define LSH_CORE_COMMUNICATION_BRIDGE_SERIAL_HPP
23
24#include <stdint.h>
25
27
31namespace BridgeSerial
32{
39
40extern uint16_t receiveIdleAge_ms;
41
42void init(); // Initialize the hardware serial link used by the bridge.
43auto receiveAndDispatch(uint16_t maxBytesToConsume)
44 -> ReceiveResult; // Consume up to N bytes and dispatch at most one complete bridge payload.
45void tickSendIdleTimer(uint16_t elapsed_ms); // Advance the ping idle timer using the elapsed bridge-housekeeping time.
46[[nodiscard]] auto canPing() -> bool; // Return true when another heartbeat may be emitted.
47void updateLastSentTime(); // Reset the ping idle timer after a payload transmission.
48[[nodiscard]] auto isConnected() -> bool; // Return true when the bridge is still considered online.
49} // namespace BridgeSerial
50
51#endif // LSH_CORE_COMMUNICATION_BRIDGE_SERIAL_HPP
Declares the function that deserializes and dispatches commands received from lsh-bridge.
Controller-side serial link used to exchange payloads with lsh-bridge.
Definition bridge_serial.cpp:32
void init()
Initialize the serial port used to talk with lsh-bridge.
Definition bridge_serial.cpp:67
auto canPing() -> bool
Check whether the bridge link may emit another heartbeat.
Definition bridge_serial.cpp:229
uint16_t receiveIdleAge_ms
Elapsed idle time since the last valid payload was received, saturated at 65535 ms.
Definition bridge_serial.cpp:39
void updateLastSentTime()
Record that a payload has just been transmitted to the bridge.
Definition bridge_serial.cpp:242
auto isConnected() -> bool
Check whether the bridge is still considered connected.
Definition bridge_serial.cpp:259
void tickSendIdleTimer(uint16_t elapsed_ms)
Advance the ping idle timer used by canPing().
Definition bridge_serial.cpp:211
auto receiveAndDispatch(uint16_t maxBytesToConsume) -> ReceiveResult
Consume a bounded amount of serial input and dispatch at most one payload.
Definition bridge_serial.cpp:81
Definition bridge_serial.hpp:34
Deserializer::DispatchResult dispatch
Effects produced by one successfully dispatched payload.
Definition bridge_serial.hpp:35
uint16_t consumedBytes
Raw UART bytes consumed during this receive attempt.
Definition bridge_serial.hpp:36
bool payloadDispatched
True only when one full payload was parsed and dispatched.
Definition bridge_serial.hpp:37
Represents the result of a dispatch operation.
Definition deserializer.hpp:36