ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
sigfox.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4#ifndef PROTOCORE_SIGFOX_H
5#define PROTOCORE_SIGFOX_H
6
7#include "protocore_config.h" // the entry point: protocore_types.h for the widths
8
10
11/**
12 * @file sigfox.h
13 * @brief Sigfox modem AT-command codec (PROTOCORE_ENABLE_SIGFOX) - Wisol / Murata over UART.
14 *
15 * The tiny-uplink half of a Sigfox-to-web bridge. A Wisol (SFM10R) / Murata Sigfox modem
16 * is driven by AT commands over a UART: protocore_sigfox_build_uplink() formats an `AT$SF=<hex>`
17 * command for a payload (the Sigfox network caps a message at 12 bytes and ~140 messages
18 * per day, so uplinks are rare and small), and protocore_sigfox_parse_response() classifies the
19 * modem's reply as OK, ERROR, or still pending (nothing conclusive yet). Pure text codec -
20 * you carry the bytes over your UART - so it is fully host-testable. This is uplink-only
21 * (the common Sigfox use); a device sends readings up, it is not addressed downlink.
22 *
23 * @c work is bytes the CALLER holds. This module reads none of them: it carries nothing
24 * between calls, so there is no state to keep and nothing to wipe. The parameter is there so
25 * a caller drives every namespace the same way.
26 *
27 * @author Douglas Quigg (dstroy0)
28 * @date 2026
29 */
30
31// PROTOCORE_SIGFOX_BORROW - the bytes this module runs out of - is stated in protocore_config.h, which sums
32// it into its arena. Its size and its offset are each a static_assert, so a feature
33// combination that does not fit fails to compile rather than overrunning at run time.
34
35/** @brief Classification of a Sigfox modem response line. */
37{
38 SIGFOX_PENDING = 0, ///< nothing conclusive yet (echo / partial); keep reading
39 SIGFOX_OK = 1, ///< the modem accepted / completed the command
40 SIGFOX_ERROR = 2, ///< the modem reported an error
42
43/** @brief Dispatch table. Addressed by offset, so the layout is asserted below. */
44typedef struct
45{
46 uint16_t (*build_uplink)(uint8_t *, const uint8_t *, uint8_t, char *, uint16_t);
47 protocore_sigfox_result (*parse_response)(uint8_t *, const char *, uint16_t);
48} SigfoxNs;
49PROTOCORE_NS_LAYOUT(SigfoxNs, build_uplink, parse_response);
50
51/**
52 * @brief Format an `AT$SF=<hex>\r\n` uplink command for payload into out (a .
53 * @param work PROTOCORE_SIGFOX_BORROW bytes the caller took. Not held past the call.
54 * @param payload Payload
55 * @param len Len
56 * @param out Out
57 * @param cap Cap
58 * @return The uint16_t.
59 */
60uint16_t protocore_sigfox_build_uplink(uint8_t *work, const uint8_t *payload, uint8_t len, char *out, uint16_t cap);
61/**
62 * @brief Classify a modem reply (scans buf for "OK" / "ERROR").
63 * @param work PROTOCORE_SIGFOX_BORROW bytes the caller took. Not held past the call.
64 * @param buf Buf
65 * @param len Len
66 * @return The protocore_sigfox_result.
67 */
68protocore_sigfox_result protocore_sigfox_parse_response(uint8_t *work, const char *buf, uint16_t len);
69
70/** @brief Module namespace. */
73
75
76#endif // PROTOCORE_SIGFOX_H
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
#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.
protocore_sigfox_result protocore_sigfox_parse_response(uint8_t *work, const char *buf, uint16_t len)
Classify a modem reply (scans buf for "OK" / "ERROR").
@ SIGFOX_ERROR
the modem reported an error
Definition sigfox.h:40
@ SIGFOX_OK
the modem accepted / completed the command
Definition sigfox.h:39
@ SIGFOX_PENDING
nothing conclusive yet (echo / partial); keep reading
Definition sigfox.h:38
PROTOCORE_NS SigfoxNs Sigfox PROTOCORE_UNUSED
Module namespace.
Definition sigfox.h:71
uint16_t protocore_sigfox_build_uplink(uint8_t *work, const uint8_t *payload, uint8_t len, char *out, uint16_t cap)
Format an AT$SF=<hex>\r\n uplink command for payload into out (a .
enum PROTO_ENUM_PACKED protocore_sigfox_result
Classification of a Sigfox modem response line.
Dispatch table. Addressed by offset, so the layout is asserted below.
Definition sigfox.h:45
uint16_t(* build_uplink)(uint8_t *, const uint8_t *, uint8_t, char *, uint16_t)
Definition sigfox.h:46
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
#define PROTOCORE_END_DECLS
Definition types.h:97