F439_CPP_TX-RX_LoRa_Project
Loading...
Searching...
No Matches
radio_link.h File Reference

RadioLink framing, crypto, replay, and persistence interface. More...

#include <main.h>
#include <stdint.h>
#include <stdbool.h>
#include "ada1897_mb85rs64b.h"
#include "sx1262.h"
#include "radio_wire.h"
Include dependency graph for radio_link.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  radioLinkCryptoCtx_t
 Runtime crypto context for RadioLink key material. More...
 

Macros

#define RADIOLINK_CRYPTO_ENABLE   (1)
 
#define RADIOLINK_DEBUG_TAMPER_ENABLE   0
 
#define RADIOLINK_DEBUG_REPLAY_REJECT_ENABLE   0
 
#define RADIOLINK_DEBUG_TX_REPLAY_ONESHOT_ENABLE   0
 
#define RL_PERSIST_ENABLE   1
 
#define RL_PERSIST_DISABLE_WHEN_DEBUGGER   1
 
#define RADIOLINK_WIRE_V3_HDR_LEN   (RADIOLINK_WIRE_V3_HDR_LEN_DERIVED)
 Fixed Wire v3 header length in bytes.
 
#define RADIOLINK_W3_VERSION   (RADIOLINK_WIRE_V3_VERSION)
 
#define RADIOLINK_W3_HDR_LEN   (RADIOLINK_WIRE_V3_HDR_LEN_DERIVED)
 
#define RADIOLINK_W3_TAG_LEN   (RADIOLINK_WIRE_V3_TAG_LEN)
 

Typedefs

typedef struct radioLinkCryptoCtx_t radioLinkCryptoCtx_t
 Runtime crypto context for RadioLink key material.
 

Functions

bool RadioLink_SendString (SX1262_Handle *sx, const char *s)
 Encrypt, authenticate, and send a string payload.
 
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.
 
bool RadioLink_SendBytes (SX1262_Handle *sx, const uint8_t *buf, uint8_t len)
 Encrypt, authenticate, and send a raw byte payload.
 
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.
 
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.
 

Detailed Description

RadioLink framing, crypto, replay, and persistence interface.

Macro Definition Documentation

◆ RADIOLINK_CRYPTO_ENABLE

#define RADIOLINK_CRYPTO_ENABLE   (1)

◆ RADIOLINK_DEBUG_REPLAY_REJECT_ENABLE

#define RADIOLINK_DEBUG_REPLAY_REJECT_ENABLE   0

◆ RADIOLINK_DEBUG_TAMPER_ENABLE

#define RADIOLINK_DEBUG_TAMPER_ENABLE   0

◆ RADIOLINK_DEBUG_TX_REPLAY_ONESHOT_ENABLE

#define RADIOLINK_DEBUG_TX_REPLAY_ONESHOT_ENABLE   0

◆ RADIOLINK_W3_HDR_LEN

#define RADIOLINK_W3_HDR_LEN   (RADIOLINK_WIRE_V3_HDR_LEN_DERIVED)

◆ RADIOLINK_W3_TAG_LEN

#define RADIOLINK_W3_TAG_LEN   (RADIOLINK_WIRE_V3_TAG_LEN)

◆ RADIOLINK_W3_VERSION

#define RADIOLINK_W3_VERSION   (RADIOLINK_WIRE_V3_VERSION)

◆ RADIOLINK_WIRE_V3_HDR_LEN

#define RADIOLINK_WIRE_V3_HDR_LEN   (RADIOLINK_WIRE_V3_HDR_LEN_DERIVED)

Fixed Wire v3 header length in bytes.

◆ RL_PERSIST_DISABLE_WHEN_DEBUGGER

#define RL_PERSIST_DISABLE_WHEN_DEBUGGER   1

◆ RL_PERSIST_ENABLE

#define RL_PERSIST_ENABLE   1

Typedef Documentation

◆ radioLinkCryptoCtx_t

typedef struct radioLinkCryptoCtx_t radioLinkCryptoCtx_t

Runtime crypto context for RadioLink key material.

Function Documentation

◆ 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.

Parameters
outOutput frame buffer.
outMaxSize of the output frame buffer in bytes.
nodeIdSource node identifier.
sessionSeqIdSession sequence identifier.
msgCounterMonotonic message counter.
plainPlaintext payload buffer.
plainLenPlaintext payload length in bytes.
outLenOutput pointer for the final frame length.
Returns
true if the frame was built successfully, otherwise false.

◆ 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.

Parameters
rxPointer to the received frame bytes.
rxLenNumber of bytes in the received frame.
outPlainOutput plaintext buffer.
outPlainMaxSize of the output plaintext buffer in bytes.
outPlainLenOutput pointer for the plaintext length.
Returns
true if the frame was accepted and decrypted, otherwise false.

◆ RadioLink_SendBytes()

bool RadioLink_SendBytes ( SX1262_Handle * sx,
const uint8_t * buf,
uint8_t len )

Encrypt, authenticate, and send a raw byte payload.

Parameters
sxSX1262 driver handle used for transmission.
bufPayload buffer.
lenPayload length in bytes.
Returns
true if the frame was built and queued successfully, otherwise false.

Encrypt, authenticate, and send a raw byte payload.

◆ RadioLink_SendString()

bool RadioLink_SendString ( SX1262_Handle * sx,
const char * s )

Encrypt, authenticate, and send a string payload.

Parameters
sxSX1262 driver handle used for transmission.
sNUL-terminated string payload.
Returns
true if the frame was built and queued successfully, otherwise false.

Encrypt, authenticate, and send a string payload.

◆ 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.

Parameters
rxPointer to the received frame bytes.
rx_lenNumber of bytes in the received frame.
outOutput string buffer.
out_maxSize of the output buffer in bytes.
Returns
true if decoding succeeded, otherwise false.

Parse and decrypt a received Wire v3 frame into a string buffer.