F439_CPP_TX-RX_LoRa_Project

Loading...
Searching...
No Matches
radio_link.h
Go to the documentation of this file.
1
7#ifndef RADIO_LINK_H_
8#define RADIO_LINK_H_
9
10#include <main.h>
11#include <stdint.h>
12#include <stdbool.h>
13#include "ada1897_mb85rs64b.h"
14
15#include "sx1262.h"
16#include "radio_wire.h"
17
18// === RADIOLINK_CRYPTO_ENABLE (compile-time) ===
19#ifndef RADIOLINK_CRYPTO_ENABLE
20#define RADIOLINK_CRYPTO_ENABLE (1)
21#endif
22
23/* Wire v3-only policy: legacy versions are not supported and have been removed. */
24
25/* Debug switches (set to 1 only during testing) */
26#define RADIOLINK_DEBUG_TAMPER_ENABLE 0
27
28#define RADIOLINK_DEBUG_REPLAY_REJECT_ENABLE 0
29#define RADIOLINK_DEBUG_RX_REJECT_REASON_ENABLE 1
30#define RADIOLINK_DEBUG_TX_REPLAY_ONESHOT_ENABLE 0
31
32/* Persistence policy */
33#define RL_PERSIST_ENABLE 1
34#define RL_PERSIST_DISABLE_WHEN_DEBUGGER 1
35
37#define RADIOLINK_WIRE_V3_HDR_LEN (RADIOLINK_WIRE_V3_HDR_LEN_DERIVED)
38
39// === WIRE_V3_CRYPTO_CONSTANTS (public routing; derived in radio_wire.h) ===
40#define RADIOLINK_W3_VERSION (RADIOLINK_WIRE_V3_VERSION)
41#define RADIOLINK_W3_HDR_LEN (RADIOLINK_WIRE_V3_HDR_LEN_DERIVED)
42#define RADIOLINK_W3_TAG_LEN (RADIOLINK_WIRE_V3_TAG_LEN)
44#define RADIOLINK_MAX_NODE_ID (255u)
45// === END WIRE_V3_CRYPTO_CONSTANTS ===
46
47
48// === RADIOLINK_CRYPTO_CONTEXT ===
52 typedef struct radioLinkCryptoCtx_t {
53 uint8_t masterKey[16];
54 uint8_t encKey[16];
55 uint8_t macKey[16];
56 uint8_t keyIsValid; // 0/1
57} radioLinkCryptoCtx_t;
58
59
66 bool RadioLink_SendString(SX1262_Handle *sx, const char *s);
67
76 bool RadioLink_TryDecodeToString(const uint8_t *rx, uint8_t rx_len, char *out, uint8_t out_max);
77
85 bool RadioLink_SendBytes(SX1262_Handle *sx, const uint8_t *buf, uint8_t len);
86
87// === WIRE_V3_CRYPTO ===
100 bool RadioLink_BuildWireV3Frame(uint8_t *out, uint8_t outMax,
101 uint8_t nodeId,
102 uint32_t sessionSeqId,
103 uint32_t msgCounter,
104 const uint8_t *plain, uint8_t plainLen,
105 uint8_t *outLen);
106
116 bool RadioLink_ParseWireV3Frame(const uint8_t *rx, uint8_t rxLen,
117 uint8_t *outPlain, uint8_t outPlainMax,
118 uint8_t *outPlainLen);
119
120// === END WIRE_V3_CRYPTO ===
121
122#endif /* RADIO_LINK_H_ */
ada1897_mb85rs64b.h
MB85RS64B SPI FRAM public interface.
sx
SX1262_Handle sx
Definition main.c:63
main.h
: Header for main.c file.This file contains the common defines of the application.
RadioLink_SendString
bool RadioLink_SendString(SX1262_Handle *sx, const char *s)
Encrypt, authenticate, and send a string payload.
Definition radio_link.c:1221
RadioLink_ParseWireV3Frame
bool RadioLink_ParseWireV3Frame(const uint8_t *rx, uint8_t rxLen, uint8_t *outPlain, uint8_t outPlainMax, uint8_t *outPlainLen)
Parse, authenticate, replay-check, and decrypt a Wire v3 frame.
Definition radio_link.c:1141
RadioLink_BuildWireV3Frame
bool RadioLink_BuildWireV3Frame(uint8_t *out, uint8_t outMax, uint8_t nodeId, uint32_t sessionSeqId, uint32_t msgCounter, const uint8_t *plain, uint8_t plainLen, uint8_t *outLen)
Build a Wire v3 frame from plaintext input.
Definition radio_link.c:1068
radioLinkCryptoCtx_t
struct radioLinkCryptoCtx_t radioLinkCryptoCtx_t
Runtime crypto context for RadioLink key material.
RadioLink_SendBytes
bool RadioLink_SendBytes(SX1262_Handle *sx, const uint8_t *buf, uint8_t len)
Encrypt, authenticate, and send a raw byte payload.
Definition radio_link.c:1274
RadioLink_TryDecodeToString
bool RadioLink_TryDecodeToString(const uint8_t *rx, uint8_t rx_len, char *out, uint8_t out_max)
Parse and decrypt a received Wire v3 frame into a string buffer.
Definition radio_link.c:1247
radio_wire.h
Wire v3 on-wire layout and derived offsets.
SX1262_Handle
Hardware binding for a single SX1262 instance.
Definition sx1262.h:20
radioLinkCryptoCtx_t
Runtime crypto context for RadioLink key material.
Definition radio_link.h:52
radioLinkCryptoCtx_t::encKey
uint8_t encKey[16]
Definition radio_link.h:54
radioLinkCryptoCtx_t::masterKey
uint8_t masterKey[16]
Definition radio_link.h:53
radioLinkCryptoCtx_t::keyIsValid
uint8_t keyIsValid
Definition radio_link.h:56
radioLinkCryptoCtx_t::macKey
uint8_t macKey[16]
Definition radio_link.h:55
sx1262.h
SX1262 LoRa radio driver public interface.