F439_CPP_TX-RX_LoRa_Project
Loading...
Searching...
No Matches
radio_wire.h
Go to the documentation of this file.
8/*
9 * radio_wire.h
10 *
11 * Wire-format packet structs (protocol-level).
12 * Transport-agnostic by design (LoRa now, USB later).
13 *
14 * NOTE:
15 * - Intentionally may be unused for now (do not delete).
16- These represent the Wire v3 layout stub used for offsetof() derivation.
17 */
18
19#ifndef RADIO_WIRE_H_
20#define RADIO_WIRE_H_
21
22#pragma once
23
24#include <stdint.h>
25#include <stddef.h> /* offsetof */
26
27/*
28 * radio_wire.h
29 *
30 * Wire v3-only layout definitions.
31 *
32 * This header exists to provide:
33 * - The on-wire version constant
34 * - The fixed header length (derived)
35 * - The fixed tag length (CMAC)
36 * - Byte offsets used by RadioLink parsing/formatting
37 *
38 * IMPORTANT:
39 * - Offsets are derived using offsetof() from a packed layout stub.
40 * - Do not cast raw RX buffers to this struct type; it is for offsetof() only.
41 */
42
44#define RADIOLINK_WIRE_V3_VERSION (0x03u)
46#define RADIOLINK_WIRE_V3_TAG_LEN (16u)
47
51typedef struct __attribute__((packed)) radioWireV3_t {
52 uint8_t version; /* 0x03 */
53 uint8_t nodeId;
54 uint32_t sessionSeqId_le; /* LE32 on wire */
55 uint32_t msgCounter_le; /* LE32 on wire */
56 uint8_t payloadLen; /* plaintext/ciphertext length (bytes) */
57 uint8_t payload[1]; /* payload starts here (variable), followed by tag */
59
60/* Offsets used by RadioLink */
61#define RL_W3_OFF_VERSION (offsetof(radioWireV3_t, version))
62#define RL_W3_OFF_NODE_ID (offsetof(radioWireV3_t, nodeId))
63#define RL_W3_OFF_SESSION_SEQ_ID (offsetof(radioWireV3_t, sessionSeqId_le))
64#define RL_W3_OFF_MSG_COUNTER (offsetof(radioWireV3_t, msgCounter_le))
65#define RL_W3_OFF_PAYLOAD_LEN (offsetof(radioWireV3_t, payloadLen))
66#define RL_W3_OFF_PAYLOAD (offsetof(radioWireV3_t, payload))
67
69#define RADIOLINK_WIRE_V3_HDR_LEN_DERIVED (offsetof(radioWireV3_t, payload))
70
71_Static_assert(RADIOLINK_WIRE_V3_HDR_LEN_DERIVED == 11U, "Wire v3 header length must be 11 bytes");
72
74#define RADIOLINK_WIRE_RADIO_MAX_LEN (255u)
76#define RADIOLINK_WIRE_V3_OVERHEAD_LEN (RADIOLINK_WIRE_V3_HDR_LEN_DERIVED + RADIOLINK_WIRE_V3_TAG_LEN)
78#define RADIOLINK_WIRE_V3_MAX_PLAINTEXT_LEN (RADIOLINK_WIRE_RADIO_MAX_LEN - RADIOLINK_WIRE_V3_OVERHEAD_LEN)
79
80#endif /* RADIO_WIRE_H_ */
struct __attribute__((packed)) radioWireV3_t
Packed Wire v3 layout stub used only for offsetof()-based derivation.
Definition radio_wire.h:51
#define RADIOLINK_WIRE_V3_HDR_LEN_DERIVED
Derived Wire v3 fixed header length in bytes.
Definition radio_wire.h:69
radioWireV3_t
Definition radio_wire.h:58