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_TX_REPLAY_ONESHOT_ENABLE 0
30
31/* Persistence policy */
32#define RL_PERSIST_ENABLE 1
33#define RL_PERSIST_DISABLE_WHEN_DEBUGGER 1
34
36#define RADIOLINK_WIRE_V3_HDR_LEN (RADIOLINK_WIRE_V3_HDR_LEN_DERIVED)
37
38// === WIRE_V3_CRYPTO_CONSTANTS (public routing; derived in radio_wire.h) ===
39#define RADIOLINK_W3_VERSION (RADIOLINK_WIRE_V3_VERSION)
40#define RADIOLINK_W3_HDR_LEN (RADIOLINK_WIRE_V3_HDR_LEN_DERIVED)
41#define RADIOLINK_W3_TAG_LEN (RADIOLINK_WIRE_V3_TAG_LEN)
42// === END WIRE_V3_CRYPTO_CONSTANTS ===
43
44
45// === RADIOLINK_CRYPTO_CONTEXT ===
49typedef struct radioLinkCryptoCtx_t {
50 uint8_t masterKey[16];
51 uint8_t encKey[16];
52 uint8_t macKey[16];
53 uint8_t keyIsValid; // 0/1
55
56
63bool RadioLink_SendString(SX1262_Handle *sx, const char *s);
64
73bool RadioLink_TryDecodeToString(const uint8_t *rx, uint8_t rx_len, char *out, uint8_t out_max);
74
82bool RadioLink_SendBytes(SX1262_Handle *sx, const uint8_t *buf, uint8_t len);
83
84// === WIRE_V3_CRYPTO ===
97bool RadioLink_BuildWireV3Frame(uint8_t *out, uint8_t outMax,
98 uint8_t nodeId,
99 uint32_t sessionSeqId,
100 uint32_t msgCounter,
101 const uint8_t *plain, uint8_t plainLen,
102 uint8_t *outLen);
103
113bool RadioLink_ParseWireV3Frame(const uint8_t *rx, uint8_t rxLen,
114 uint8_t *outPlain, uint8_t outPlainMax,
115 uint8_t *outPlainLen);
116
117// === END WIRE_V3_CRYPTO ===
118
119#endif /* RADIO_LINK_H_ */
MB85RS64B SPI FRAM public interface.
SX1262_Handle sx
Definition main.c:65
: Header for main.c file.This file contains the common defines of the application.
Wire v3 on-wire layout and derived offsets.
Hardware binding for a single SX1262 instance.
Definition sx1262.h:20
Runtime crypto context for RadioLink key material.
Definition radio_link.h:49
uint8_t encKey[16]
Definition radio_link.h:51
uint8_t masterKey[16]
Definition radio_link.h:50
uint8_t keyIsValid
Definition radio_link.h:53
uint8_t macKey[16]
Definition radio_link.h:52
SX1262 LoRa radio driver public interface.