|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
Wi-SUN FAN border-router connector (PROTOCORE_ENABLE_WISUN). More...
Go to the source code of this file.
Classes | |
| struct | WisunNode |
| One FAN mesh node behind the border router. More... | |
| struct | WisunFan |
| The FAN connector state over a caller-owned node table. More... | |
| struct | WisunNs |
| Dispatch table. Addressed by offset, so the layout is asserted below. More... | |
Macros | |
| #define | WISUN_COAP_CON 0 |
| CoAP message type + method codes (RFC 7252) used by the connector. | |
| #define | WISUN_COAP_NON 1 |
| Non-confirmable. | |
| #define | WISUN_COAP_GET 1 |
| method code 0.01. | |
| #define | WISUN_COAP_PUT 3 |
| method code 0.03. | |
Functions | |
| PROTOCORE_NS_LAYOUT (WisunNs, build_coap, init, node_register, node_find, joined_count, nodes_json) | |
| size_t | protocore_wisun_build_coap (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 / . | |
| void | protocore_wisun_init (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. | |
| proto_bool | protocore_wisun_node_find (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. | |
| size_t | protocore_wisun_joined_count (uint8_t *work, const WisunFan *fan) |
| Number of joined nodes. | |
| size_t | protocore_wisun_nodes_json (uint8_t *work, const WisunFan *fan, char *out, size_t cap) |
Serialize the node table as [{"addr":"..","joined":bool},...] for . | |
Variables | |
| PROTOCORE_NS WisunNs Wisun | PROTOCORE_UNUSED |
| Module namespace. | |
Wi-SUN FAN border-router connector (PROTOCORE_ENABLE_WISUN).
Wi-SUN FAN is an IPv6 / UDP / CoAP mesh, not a byte-level radio the ESP32 drives - the FAN radio is terminated by a border router / devboard and each mesh node is reached as an ordinary IPv6 CoAP endpoint. So the connector rides the existing IP stack: it keeps a table of the FAN nodes (their IPv6 protocore_ip addresses + join state) behind the border router, and builds the CoAP client requests to their resources (the CoAP service ships a server, so the client-request builder is here). The app sends the built PDU to the node's address over protocore_udp; the specific devboard only sets which border router you point at, not this code.
Pure: protocore_wisun_build_coap frames an RFC 7252 request (header + Uri-Path options + payload), the node registry tracks the mesh, and protocore_wisun_nodes_json exposes it to the web. No heap, no stdlib, host-testable.
work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.
Definition in file wisun.h.
| #define WISUN_COAP_CON 0 |
| PROTOCORE_NS_LAYOUT | ( | WisunNs | , |
| build_coap | , | ||
| init | , | ||
| node_register | , | ||
| node_find | , | ||
| joined_count | , | ||
| nodes_json | |||
| ) |
| size_t protocore_wisun_build_coap | ( | 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 / .
| work | PROTOCORE_WISUN_BORROW bytes the caller took. Not held past the call. |
| type | WISUN_COAP_CON / WISUN_COAP_NON |
| code | method code (WISUN_COAP_GET / WISUN_COAP_PUT) |
| msg_id | the 16-bit message id (echoed in the ACK) |
| token | correlation token (0..8 bytes; may be null if tkl == 0) |
| tkl | token length |
| uri_path | resource path, e.g. "sensors/temp" (leading / optional) |
| payload | request body (may be null if plen == 0) |
| plen | payload length |
| out | Out |
| cap | Cap |
| void protocore_wisun_init | ( | uint8_t * | work, |
| WisunFan * | fan, | ||
| const protocore_ip * | border_router, | ||
| WisunNode * | storage, | ||
| size_t | cap | ||
| ) |
Initialize the connector over caller storage.
| work | PROTOCORE_WISUN_BORROW bytes the caller took. Not held past the call. |
| fan | Fan |
| border_router | Border router |
| storage | Storage |
| cap | Cap |
| 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.
| work | PROTOCORE_WISUN_BORROW bytes the caller took. Not held past the call. |
| fan | Fan |
| addr | Addr |
| now | Now |
| proto_bool protocore_wisun_node_find | ( | 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.
| work | PROTOCORE_WISUN_BORROW bytes the caller took. Not held past the call. |
| fan | Fan |
| addr | Addr |
| idx | Idx |
| size_t protocore_wisun_joined_count | ( | uint8_t * | work, |
| const WisunFan * | fan | ||
| ) |
Number of joined nodes.
| work | PROTOCORE_WISUN_BORROW bytes the caller took. Not held past the call. |
| fan | Fan |
| size_t protocore_wisun_nodes_json | ( | uint8_t * | work, |
| const WisunFan * | fan, | ||
| char * | out, | ||
| size_t | cap | ||
| ) |
Serialize the node table as [{"addr":"..","joined":bool},...] for .
| work | PROTOCORE_WISUN_BORROW bytes the caller took. Not held past the call. |
| fan | Fan |
| out | Out |
| cap | Cap |
| PROTOCORE_NS WisunNs Wisun PROTOCORE_UNUSED |
Module namespace.