4#ifndef PROTOCORE_WISUN_H
5#define PROTOCORE_WISUN_H
38#define WISUN_COAP_CON 0
39#define WISUN_COAP_NON 1
40#define WISUN_COAP_GET 1
41#define WISUN_COAP_PUT 3
65 size_t (*
build_coap)(
const uint8_t *, uint8_t, uint8_t, uint16_t,
const uint8_t *, uint8_t,
const char *,
66 const uint8_t *, size_t, uint8_t *, size_t);
91 const uint8_t *token, uint8_t tkl,
const char *uri_path,
const uint8_t *payload,
92 size_t plen, uint8_t *out,
size_t cap);
Layer 3 (Network) - a family-tagged IP address (IPv4 or IPv6) with RFC-faithful text parsing,...
#define PROTOCORE_UNUSED
Suppress the unused warning. Every module ends in a namespace most callers only partly use.
#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.
The FAN connector state over a caller-owned node table.
protocore_ip border_router
the border router / devboard address.
One FAN mesh node behind the border router.
embed_bool joined
true once the node joined the FAN.
uint32_t last_seen
tick of the last contact.
protocore_ip addr
the node's IPv6 address on the mesh.
Dispatch table. Addressed by offset, so the layout is asserted below.
void(* init)(const uint8_t *, WisunFan *, const protocore_ip *, WisunNode *, size_t)
size_t(* build_coap)(const uint8_t *, uint8_t, uint8_t, uint16_t, const uint8_t *, uint8_t, const char *, const uint8_t *, size_t, uint8_t *, size_t)
size_t(* joined_count)(const uint8_t *, const WisunFan *)
size_t(* nodes_json)(const uint8_t *, const WisunFan *, char *, size_t)
int(* node_register)(uint8_t *, WisunFan *, const protocore_ip *, uint32_t)
embed_bool(* node_find)(const uint8_t *, const WisunFan *, const protocore_ip *, size_t *)
A v4 or v6 address in network (big-endian) byte order.
size_t protocore_wisun_joined_count(const uint8_t *work, const WisunFan *fan)
Number of joined nodes.
size_t protocore_wisun_build_coap(const uint8_t *work, uint8_t type, uint8_t code, uint16_t msg_id, const uint8_t *token, uint8_t tkl, const char *uri_path, const uint8_t *payload, size_t plen, uint8_t *out, size_t cap)
Build a CoAP client request: header + Uri-Path options (one per / .
size_t protocore_wisun_nodes_json(const uint8_t *work, const WisunFan *fan, char *out, size_t cap)
Serialize the node table as [{"addr":"..","joined":bool},...] for .
void protocore_wisun_init(const uint8_t *work, WisunFan *fan, const protocore_ip *border_router, WisunNode *storage, size_t cap)
Initialize the connector over caller storage.
int protocore_wisun_node_register(uint8_t *work, WisunFan *fan, const protocore_ip *addr, uint32_t now)
Register (or refresh) a node by address; sets joined + last_seen.
embed_bool protocore_wisun_node_find(const uint8_t *work, const WisunFan *fan, const protocore_ip *addr, size_t *idx)
Find a node by address. idx (may be null) receives the index. found.