4#ifndef PROTOCORE_GATEWAY_H
5#define PROTOCORE_GATEWAY_H
113 void (*reset)(uint8_t *);
116 void (*set_topic_prefix)(uint8_t *,
const char *);
117 proto_bool (*uplink)(uint8_t *, uint8_t, uint16_t,
const uint8_t *, uint16_t, int16_t);
118 proto_bool (*downlink)(uint8_t *, uint8_t, uint16_t,
const uint8_t *, uint16_t);
160 uint16_t len, int16_t rssi);
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
proto_bool(* protocore_gateway_tx_fn)(uint8_t port_id, uint16_t dst_addr, const uint8_t *payload, uint16_t len, void *ctx)
Southbound transmit (downlink): send payload to dst_addr on port_id.
void protocore_gateway_get_stats(uint8_t *work, protocore_gateway_stats *out)
Copy the current gateway counters into out. The uplink rate window .
void protocore_gateway_set_topic_prefix(uint8_t *work, const char *prefix)
Set the topic prefix used by protocore_gateway_topic() .
void protocore_gateway_reset(uint8_t *work)
Clear all ports, the uplink sink, the topic prefix, and stats.
proto_bool protocore_gateway_add_port(uint8_t *work, const protocore_gateway_port_config *cfg)
Register a southbound port.
proto_bool(* protocore_gateway_uplink_fn)(const protocore_gateway_msg *msg, void *ctx)
Northbound publish: emit msg to MQTT / HTTP / WebSocket / UDP.
PROTOCORE_NS GatewayNs Gateway PROTOCORE_UNUSED
Module namespace.
uint8_t * protocore_gateway_span(void)
The PROTOCORE_GATEWAY_BORROW bytes this module's state lives in.
uint16_t protocore_gateway_topic(uint8_t *work, const protocore_gateway_msg *msg, char *buf, uint16_t buflen)
Format a northbound routing key <prefix>/<port>/<addr> for msg .
proto_bool protocore_gateway_uplink(uint8_t *work, uint8_t port_id, uint16_t src_addr, const uint8_t *payload, uint16_t len, int16_t rssi)
Bridge a received southbound frame northbound: envelope it and .
proto_bool protocore_gateway_downlink(uint8_t *work, uint8_t port_id, uint16_t dst_addr, const uint8_t *payload, uint16_t len)
Bridge a northbound command southbound: transmit it on port_id's .
void protocore_gateway_set_uplink_cb(uint8_t *work, protocore_gateway_uplink_fn fn, void *ctx)
Install the northbound publish callback (required to publish .
enum PROTO_ENUM_PACKED protocore_gateway_kind
Southbound radio / bus kind a port bridges (informational + topic hint).
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
A northbound message: a southbound frame enveloped with its routing metadata. payload points at the c...
uint8_t port_id
the port the frame arrived on
protocore_gateway_kind kind
protocore_gateway_kind of that port
uint16_t len
payload length
uint16_t src_addr
source node address on the radio
const uint8_t * payload
frame payload bytes
int16_t rssi
received signal strength (0 if the driver has none)
uint32_t seq
per-gateway uplink sequence (wraps)
Southbound port (radio / bus) configuration passed to protocore_gateway_add_port().
protocore_gateway_kind kind
protocore_gateway_kind.
void * ctx
opaque, forwarded to tx.
protocore_gateway_tx_fn tx
downlink transmit (may be null for a receive-only port).
uint8_t port_id
caller-assigned id (used in topics and up/down-link calls).
uint16_t rate_cap
max uplink frames/second from this port (0 = unlimited).
Gateway counters (monotonic since the last protocore_gateway_reset()).
uint32_t down_dropped
downlinks dropped (bad port / no tx / refused)
uint32_t up_in
protocore_gateway_uplink() calls
uint32_t up_dropped
uplinks dropped (rate cap / no sink / refused / bad port)
uint32_t down_in
protocore_gateway_downlink() calls
uint32_t down_sent
downlinks the port transmit accepted
uint32_t up_published
frames the uplink callback accepted
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS