Skip to content

File syn_transport.h

FileList > net > syn_transport.h

Go to the source code of this file

Transport abstraction — pluggable send/receive (header-only). More...

  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_Transport
Abstract transport interface (send/receive function pointers).

Public Static Functions

Type Name
bool syn_transport_recv (SYN_Transport * t, uint8_t * data, size_t max_len, size_t * out_len)
Receive a packet via transport (non-blocking).
bool syn_transport_send (SYN_Transport * t, const uint8_t * data, size_t len)
Send a packet via transport.

Detailed Description

Defines a uniform interface for sending/receiving byte buffers over any physical layer: UART, CAN, SPI, USB, etc. Higher-level modules (router, heartbeat) consume transports without knowing the wire.

Usage:

// Option A: UART transport via COBS framing
static SYN_Transport tr;
syn_transport_from_uart(&tr, &uart, &cobs_dec, cobs_buf, sizeof(cobs_buf));

// Option B: Custom transport
static SYN_Transport tr = {
    .send = my_send_fn,
    .recv = my_recv_fn,
    .ctx  = &my_device,
};

Public Static Functions Documentation

function syn_transport_recv

Receive a packet via transport (non-blocking).

static inline bool syn_transport_recv (
    SYN_Transport * t,
    uint8_t * data,
    size_t max_len,
    size_t * out_len
) 

Parameters:

  • t Transport instance.
  • data Buffer for received data.
  • max_len Buffer capacity.
  • out_len [out] Actual received length.

Returns:

true if a complete packet was received.


function syn_transport_send

Send a packet via transport.

static inline bool syn_transport_send (
    SYN_Transport * t,
    const uint8_t * data,
    size_t len
) 

Parameters:

  • t Transport instance.
  • data Packet data.
  • len Packet length.

Returns:

true if sent successfully.



The documentation for this class was generated from the following file src/syntropic/net/syn_transport.h