StreamFrameCodec

class StreamFrameCodec(onPacketReceived: (ByteArray) -> Unit, logTag: String = "StreamCodec")(source)

Meshtastic stream framing codec — pure Kotlin, no platform dependencies.

Implements the START1/START2 + 2-byte-length + payload framing protocol used for serial and TCP communication with Meshtastic radios.

Shared between Android (StreamInterface/TCPInterface) and Desktop (DesktopRadioInterfaceService).

Constructors

Link copied to clipboard
constructor(onPacketReceived: (ByteArray) -> Unit, logTag: String = "StreamCodec")

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun frameAndSend(payload: ByteArray, sendBytes: (ByteArray) -> Unit, flush: () -> Unit = {})

Frames a payload into the Meshtastic stream protocol format: START2LSB lenpayload.

Link copied to clipboard

Process a single incoming byte through the stream framing state machine.

Link copied to clipboard
fun reset()

Resets the framing state machine. Call when reconnecting.