TinyModem
Header-only software audio modem library
Loading...
Searching...
No Matches
tinymodem::IL2P Class Reference

IL2P (Improved Layer 2 Protocol, as implemented by direwolf): an AX.25 frame is sent as a scrambled header with Reed-Solomon parity and a scrambled payload in Reed-Solomon blocks, without HDLC framing and NRZI. Header type 1 compresses the addresses and the control field of frames with 2 addresses, header type 0 carries the complete AX.25 frame as payload. More...

#include <AX25FEC.h>

Classes

struct  Blocks
 Partitioning of the payload into Reed-Solomon blocks. More...

Static Public Member Functions

static int encode (const uint8_t *frame, int len, bool max_fec, uint8_t *out)
static int decodeHeader (const uint8_t *received, uint8_t *hdr, int *corrected=nullptr)
static int decodeFrame (const uint8_t *hdr, const uint8_t *encoded, uint8_t *frame, int frame_size, int *corrected=nullptr)
static int payloadLength (const uint8_t *hdr)
static bool maxFec (const uint8_t *hdr)
static void scramble (const uint8_t *in, uint8_t *out, int len)
 Scrambles a block (the scrambler output is delayed by 5 bits).
static void descramble (const uint8_t *in, uint8_t *out, int len)

Static Public Attributes

static constexpr uint8_t PREAMBLE = 0x55
static constexpr uint32_t SYNC_WORD = 0xF15E48
static constexpr int HEADER_SIZE = 13
static constexpr int HEADER_PARITY = 2
static constexpr int MAX_PAYLOAD = 1023
static constexpr int MAX_ENCODED

Static Protected Member Functions

static bool blocks (int len, bool max_fec, Blocks &p)
static int encodePayload (const uint8_t *payload, int len, bool max_fec, uint8_t *out)
static bool decodePayload (const uint8_t *in, int len, bool max_fec, uint8_t *payload, int *corrected)
static int scrambleBit (int in, int &state)
static void setField (uint8_t *hdr, int bit, int lsb_index, int width, int value)
static int getField (const uint8_t *hdr, int bit, int lsb_index, int width)
static int encodePid (uint8_t pid)
static uint8_t decodePid (int pid)
static const uint8_t * uFrames ()
 U frame control fields (without poll/final) in the order of IL2P.
static int type1Header (const uint8_t *frame, int len, bool max_fec, uint8_t *hdr)
static int type1Frame (const uint8_t *hdr, uint8_t *frame)

Detailed Description

IL2P (Improved Layer 2 Protocol, as implemented by direwolf): an AX.25 frame is sent as a scrambled header with Reed-Solomon parity and a scrambled payload in Reed-Solomon blocks, without HDLC framing and NRZI. Header type 1 compresses the addresses and the control field of frames with 2 addresses, header type 0 carries the complete AX.25 frame as payload.

Member Function Documentation

◆ blocks()

bool tinymodem::IL2P::blocks ( int len,
bool max_fec,
Blocks & p )
inlinestaticprotected

◆ decodeFrame()

int tinymodem::IL2P::decodeFrame ( const uint8_t * hdr,
const uint8_t * encoded,
uint8_t * frame,
int frame_size,
int * corrected = nullptr )
inlinestatic

Decodes the frame from the decoded header and the encoded payload: returns the frame length (without FCS) or 0 if invalid

◆ decodeHeader()

int tinymodem::IL2P::decodeHeader ( const uint8_t * received,
uint8_t * hdr,
int * corrected = nullptr )
inlinestatic

Corrects and descrambles a received header (15 bytes): returns the encoded payload length or -1 if the header is invalid

◆ decodePayload()

bool tinymodem::IL2P::decodePayload ( const uint8_t * in,
int len,
bool max_fec,
uint8_t * payload,
int * corrected )
inlinestaticprotected

◆ decodePid()

uint8_t tinymodem::IL2P::decodePid ( int pid)
inlinestaticprotected

◆ descramble()

void tinymodem::IL2P::descramble ( const uint8_t * in,
uint8_t * out,
int len )
inlinestatic

◆ encode()

int tinymodem::IL2P::encode ( const uint8_t * frame,
int len,
bool max_fec,
uint8_t * out )
inlinestatic

Encodes a frame (without FCS) into header and payload (without the sync word): returns the length or 0 if the frame can't be encoded

◆ encodePayload()

int tinymodem::IL2P::encodePayload ( const uint8_t * payload,
int len,
bool max_fec,
uint8_t * out )
inlinestaticprotected

◆ encodePid()

int tinymodem::IL2P::encodePid ( uint8_t pid)
inlinestaticprotected

◆ getField()

int tinymodem::IL2P::getField ( const uint8_t * hdr,
int bit,
int lsb_index,
int width )
inlinestaticprotected

◆ maxFec()

bool tinymodem::IL2P::maxFec ( const uint8_t * hdr)
inlinestatic

◆ payloadLength()

int tinymodem::IL2P::payloadLength ( const uint8_t * hdr)
inlinestatic

◆ scramble()

void tinymodem::IL2P::scramble ( const uint8_t * in,
uint8_t * out,
int len )
inlinestatic

Scrambles a block (the scrambler output is delayed by 5 bits).

◆ scrambleBit()

int tinymodem::IL2P::scrambleBit ( int in,
int & state )
inlinestaticprotected

◆ setField()

void tinymodem::IL2P::setField ( uint8_t * hdr,
int bit,
int lsb_index,
int width,
int value )
inlinestaticprotected

◆ type1Frame()

int tinymodem::IL2P::type1Frame ( const uint8_t * hdr,
uint8_t * frame )
inlinestaticprotected

AX.25 frame (addresses, control, pid) of a type 1 header: returns the length or 0 if invalid

◆ type1Header()

int tinymodem::IL2P::type1Header ( const uint8_t * frame,
int len,
bool max_fec,
uint8_t * hdr )
inlinestaticprotected

Type 1 header of a frame with 2 addresses: returns the position of the payload in the frame or -1 if a type 1 header is not possible

◆ uFrames()

const uint8_t * tinymodem::IL2P::uFrames ( )
inlinestaticprotected

U frame control fields (without poll/final) in the order of IL2P.

Member Data Documentation

◆ HEADER_PARITY

int tinymodem::IL2P::HEADER_PARITY = 2
staticconstexpr

◆ HEADER_SIZE

int tinymodem::IL2P::HEADER_SIZE = 13
staticconstexpr

◆ MAX_ENCODED

int tinymodem::IL2P::MAX_ENCODED
staticconstexpr
Initial value:
=
static constexpr int HEADER_PARITY
Definition AX25FEC.h:219
static constexpr int MAX_PAYLOAD
Definition AX25FEC.h:220
static constexpr int HEADER_SIZE
Definition AX25FEC.h:218

◆ MAX_PAYLOAD

int tinymodem::IL2P::MAX_PAYLOAD = 1023
staticconstexpr

◆ PREAMBLE

uint8_t tinymodem::IL2P::PREAMBLE = 0x55
staticconstexpr

◆ SYNC_WORD

uint32_t tinymodem::IL2P::SYNC_WORD = 0xF15E48
staticconstexpr

The documentation for this class was generated from the following file: