Downlink Encoding / Decoding¶
Functions¶
-
void
sfx_downlink_encode
(sfx_dl_plain to_encode, sfx_commoninfo common, sfx_dl_encoded *encoded)¶ generate raw Sigfox downlink frame from given contents, for given Sigfox object and its state
- Parameters
to_encode – content of raw Sigfox frame, only sfx_dl_plain::payload has to be set, all other members of sfx_dl_plain are ignored
common – general information about the Sigfox object and its state
encoded – output, raw Sigfox downlink frame, excluding preamble
-
void
sfx_downlink_decode
(sfx_dl_encoded encoded, sfx_commoninfo common, sfx_dl_plain *decoded)¶ retrieve contents of Sigfox downlink from given raw frame
- Attention
This function applies Forward Error Correction (FEC). If FEC has occurred during decoding, sfx_dl_plain::fec_corrected will be set to true in the output.
- Parameters
to_decode – the raw contents of the Sigfox downlink frame to decode
common – General information about the Sigfox object and its state. If a wrong NAK is provided, sfx_dl_plain::mac_ok will be false, but decoding will still work.
decoded – output, contents of Sigfox frame and whether MAC / CRC match
Inputs and outputs¶
-
struct
sfx_dl_plain
¶ properties that describe the plain contents of a downlink frame after decoding or before encoding
Public Members
-
uint8_t
payload
[SFX_DL_PAYLOADLEN
]¶ plaintext payload of downlink frame, always 8 bytes long
-
bool
crc_ok
¶ indicates whether CRC of downlink frame is valid, set by sfx_downlink_decode
-
bool
mac_ok
¶ indicates whether MAC of downlink frame is valid, set by sfx_downlink_decode
-
bool
fec_corrected
¶ indicates whether FEC was applied during decoding, set by sfx_downlink_decode
-
uint8_t
Preamble¶
The encoding / decoding functions handle downlinks excluding the preamble. However, the preamble content can be obtained from the following array:
-
uint8_t
SFX_DL_PREAMBLE
[]¶ content of Sigfox’s 13-byte (SFX_DL_PREAMBLELEN) downlink preamble
-
SFX_DL_PREAMBLELEN
¶ length of Sigfox’s downlink preamble, in bytes