LSH-Core
Deterministic firmware core for Controllino-based Labo Smart Home nodes
 
Loading...
Searching...
No Matches
lsh::core::transport::MsgPackFrameReceiver Class Reference

Incremental receiver for the SLIP-like MsgPack framing used on the bridge serial link. More...

#include <msgpack_serial_framing.hpp>

Collaboration diagram for lsh::core::transport::MsgPackFrameReceiver:
Collaboration graph

Public Member Functions

 MsgPackFrameReceiver (char *buffer, uint16_t capacity) noexcept
 Construct one incremental MsgPack frame receiver around caller-owned storage.
 
void reset () noexcept
 Forget the current receive state and return to the idle state.
 
void resetIfIdle (uint32_t nowMs, uint32_t idleTimeoutMs) noexcept
 Drop a partially received frame that has been silent for too long.
 
auto consumeByte (uint8_t byte, uint32_t nowMs) -> MsgPackFrameConsumeResult
 Feed one raw serial byte into the framed MsgPack receiver.
 
auto frameData () const -> const uint8_t *
 Return the beginning of the completed payload buffer.
 
auto frameLength () const -> uint16_t
 Return the current payload length assembled by the receiver.
 

Detailed Description

Incremental receiver for the SLIP-like MsgPack framing used on the bridge serial link.

Constructor & Destructor Documentation

◆ MsgPackFrameReceiver()

lsh::core::transport::MsgPackFrameReceiver::MsgPackFrameReceiver ( char *  buffer,
uint16_t  capacity 
)
noexcept

Construct one incremental MsgPack frame receiver around caller-owned storage.

Parameters
bufferdestination storage used for the deframed payload bytes.
capacitymaximum number of payload bytes that fit in buffer.

Member Function Documentation

◆ consumeByte()

auto lsh::core::transport::MsgPackFrameReceiver::consumeByte ( uint8_t  byte,
uint32_t  nowMs 
) -> MsgPackFrameConsumeResult

Feed one raw serial byte into the framed MsgPack receiver.

The transport format is END + escaped(payload) + END. The receiver therefore understands only the delimiter and the two escaped reserved bytes; the payload itself remains pure MsgPack.

Parameters
byteraw serial byte just read from the UART.
nowMscurrent real-time tick in milliseconds.
Returns
MsgPackFrameConsumeResult describing whether a frame became ready or one malformed frame has just been dropped.

◆ frameData()

auto lsh::core::transport::MsgPackFrameReceiver::frameData ( ) const -> const uint8_t *

Return the beginning of the completed payload buffer.

Returns
const std::uint8_t * pointer to the first deframed payload byte.

◆ frameLength()

auto lsh::core::transport::MsgPackFrameReceiver::frameLength ( ) const -> uint16_t

Return the current payload length assembled by the receiver.

Returns
std::uint16_t number of valid payload bytes currently stored in frameBuffer.

◆ reset()

void lsh::core::transport::MsgPackFrameReceiver::reset ( )
noexcept

Forget the current receive state and return to the idle state.

The destination buffer content is left untouched because callers trust only the first frameLength() bytes after FrameComplete.

◆ resetIfIdle()

void lsh::core::transport::MsgPackFrameReceiver::resetIfIdle ( uint32_t  nowMs,
uint32_t  idleTimeoutMs 
)
noexcept

Drop a partially received frame that has been silent for too long.

This timeout is only a housekeeping guard for truncated frames. It is not part of the framing itself and never defines frame boundaries.

Parameters
nowMscurrent real-time tick in milliseconds.
idleTimeoutMsmaximum allowed silence while one frame is in progress.

The documentation for this class was generated from the following files: