# RadioLib: src/protocols/AX25/AX25.h Source File

AX25.h
#if !defined(_RADIOLIB_AX25_H)
#define _RADIOLIB_AX25_H
#include "../../TypeDef.h"
#if !RADIOLIB_EXCLUDE_AX25
#include "../PhysicalLayer/PhysicalLayer.h"
#include "../AFSK/AFSK.h"
#include "../BellModem/BellModem.h"
#include "../../utils/CRC.h"
#include "../../utils/FEC.h"
// maximum callsign length in bytes
#define RADIOLIB_AX25_MAX_CALLSIGN_LEN 6
// flag field MSB LSB DESCRIPTION
#define RADIOLIB_AX25_FLAG 0b01111110 // 7 0 AX.25 frame start/end flag
// address field
#define RADIOLIB_AX25_SSID_COMMAND_DEST 0b10000000 // 7 7 frame type: command (set in destination SSID)
#define RADIOLIB_AX25_SSID_COMMAND_SOURCE 0b00000000 // 7 7 command (set in source SSID)
#define RADIOLIB_AX25_SSID_RESPONSE_DEST 0b00000000 // 7 7 response (set in destination SSID)
#define RADIOLIB_AX25_SSID_RESPONSE_SOURCE 0b10000000 // 7 7 response (set in source SSID)
#define RADIOLIB_AX25_SSID_HAS_NOT_BEEN_REPEATED 0b00000000 // 7 7 not repeated yet (set in repeater SSID)
#define RADIOLIB_AX25_SSID_HAS_BEEN_REPEATED 0b10000000 // 7 7 repeated (set in repeater SSID)
#define RADIOLIB_AX25_SSID_RESERVED_BITS 0b01100000 // 6 5 reserved bits in SSID
#define RADIOLIB_AX25_SSID_HDLC_EXTENSION_CONTINUE 0b00000000 // 0 0 HDLC extension bit: next octet contains more address information
#define RADIOLIB_AX25_SSID_HDLC_EXTENSION_END 0b00000001 // 0 0 address field end
// control field
#define RADIOLIB_AX25_CONTROL_U_SET_ASYNC_BAL_MODE 0b01101100 // 7 2 U frame type: set asynchronous balanced mode (connect request)
#define RADIOLIB_AX25_CONTROL_U_SET_ASYNC_BAL_MODE_EXT 0b00101100 // 7 2 set asynchronous balanced mode extended (connect request with module 128)
#define RADIOLIB_AX25_CONTROL_U_DISCONNECT 0b01000000 // 7 2 disconnect request
#define RADIOLIB_AX25_CONTROL_U_DISCONNECT_MODE 0b00001100 // 7 2 disconnect mode (system busy or disconnected)
#define RADIOLIB_AX25_CONTROL_U_UNNUMBERED_ACK 0b01100000 // 7 2 unnumbered acknowledge
#define RADIOLIB_AX25_CONTROL_U_FRAME_REJECT 0b10000100 // 7 2 frame reject
#define RADIOLIB_AX25_CONTROL_U_UNNUMBERED_INFORMATION 0b00000000 // 7 2 unnumbered information
#define RADIOLIB_AX25_CONTROL_U_EXHANGE_IDENTIFICATION 0b10101100 // 7 2 exchange ID
#define RADIOLIB_AX25_CONTROL_U_TEST 0b11100000 // 7 2 test
#define RADIOLIB_AX25_CONTROL_POLL_FINAL_ENABLED 0b00010000 // 4 4 control field poll/final bit: enabled
#define RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED 0b00000000 // 4 4 disabled
#define RADIOLIB_AX25_CONTROL_S_RECEIVE_READY 0b00000000 // 3 2 S frame type: receive ready (system ready to receive)
#define RADIOLIB_AX25_CONTROL_S_RECEIVE_NOT_READY 0b00000100 // 3 2 receive not ready (TNC buffer full)
#define RADIOLIB_AX25_CONTROL_S_REJECT 0b00001000 // 3 2 reject (out of sequence or duplicate)
#define RADIOLIB_AX25_CONTROL_S_SELECTIVE_REJECT 0b00001100 // 3 2 selective reject (single frame repeat request)
#define RADIOLIB_AX25_CONTROL_INFORMATION_FRAME 0b00000000 // 0 0 frame type: information (I frame)
#define RADIOLIB_AX25_CONTROL_SUPERVISORY_FRAME 0b00000001 // 1 0 supervisory (S frame)
#define RADIOLIB_AX25_CONTROL_UNNUMBERED_FRAME 0b00000011 // 1 0 unnumbered (U frame)
// protocol identifier field
#define RADIOLIB_AX25_PID_ISO_8208 0x01
#define RADIOLIB_AX25_PID_TCP_IP_COMPRESSED 0x06
#define RADIOLIB_AX25_PID_TCP_IP_UNCOMPRESSED 0x07
#define RADIOLIB_AX25_PID_SEGMENTATION_FRAGMENT 0x08
#define RADIOLIB_AX25_PID_TEXNET_DATAGRAM_PROTOCOL 0xC3
#define RADIOLIB_AX25_PID_LINK_QUALITY_PROTOCOL 0xC4
#define RADIOLIB_AX25_PID_APPLETALK 0xCA
#define RADIOLIB_AX25_PID_APPLETALK_ARP 0xCB
#define RADIOLIB_AX25_PID_ARPA_INTERNET_PROTOCOL 0xCC
#define RADIOLIB_AX25_PID_ARPA_ADDRESS_RESOLUTION 0xCD
#define RADIOLIB_AX25_PID_FLEXNET 0xCE
#define RADIOLIB_AX25_PID_NET_ROM 0xCF
#define RADIOLIB_AX25_PID_NO_LAYER_3 0xF0
#define RADIOLIB_AX25_PID_ESCAPE_CHARACTER 0xFF
class AX25Frame {
public:
char destCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1];
uint8_t destSSID;
char srcCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1];
uint8_t srcSSID;
uint8_t numRepeaters;
uint8_t control;
uint8_t protocolID;
uint16_t infoLen;
uint8_t rcvSeqNumber;
uint16_t sendSeqNumber;
#if !RADIOLIB_STATIC_ONLY
uint8_t* info;
char** repeaterCallsigns;
uint8_t* repeaterSSIDs;
#else
uint8_t info[RADIOLIB_STATIC_ARRAY_SIZE];
char repeaterCallsigns[8][RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1];
uint8_t repeaterSSIDs[8];
#endif
AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control);
AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control, uint8_t protocolID, const char* info);
AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control, uint8_t protocolID, uint8_t* info, uint16_t infoLen);
AX25Frame(const AX25Frame& frame);
~AX25Frame();
AX25Frame& operator=(const AX25Frame& frame);
int16_t setRepeaters(char** repeaterCallsigns, uint8_t* repeaterSSIDs, uint8_t numRepeaters);
void setRecvSequence(uint8_t seqNumber);
void setSendSequence(uint8_t seqNumber);
};
class AX25Client {
public:
explicit AX25Client(PhysicalLayer* phy);
#if !RADIOLIB_EXCLUDE_AFSK
explicit AX25Client(AFSKClient* aud);
AX25Client(const AX25Client& ax25);
AX25Client& operator=(const AX25Client& ax25);
int16_t setCorrection(int16_t mark, int16_t space, float length = 1.0f);
#endif
// basic methods
int16_t begin(const char* srcCallsign, uint8_t srcSSID = 0x00, uint8_t preLen = 8);
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t transmit(String& str, const char* destCallsign, uint8_t destSSID = 0x00);
#endif
int16_t transmit(const char* str, const char* destCallsign, uint8_t destSSID = 0x00);
int16_t sendFrame(AX25Frame* frame);
#if !RADIOLIB_GODMODE
private:
#endif
friend class APRSClient;
PhysicalLayer* phyLayer;
#if !RADIOLIB_EXCLUDE_AFSK
AFSKClient* audio;
BellClient* bellModem;
#endif
char sourceCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1] = { 0 };
uint8_t sourceSSID = 0;
uint16_t preambleLen = 0;
void getCallsign(char* buff);
uint8_t getSSID();
};
#endif
#endif
AFSKClient
Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direc...
Definition: AFSK.h:16
APRSClient
Client for APRS communication.
Definition: APRS.h:85
AX25Client
Client for AX25 communication.
Definition: AX25.h:233
AX25Client::sendFrame
int16_t sendFrame(AX25Frame *frame)
Transmit arbitrary AX.25 frame.
Definition: AX25.cpp:283
AX25Client::setCorrection
int16_t setCorrection(int16_t mark, int16_t space, float length=1.0f)
Set AFSK tone correction offset. On some platforms, this is required to get the audio produced by the...
Definition: AX25.cpp:232
AX25Client::transmit
int16_t transmit(const char *str, const char *destCallsign, uint8_t destSSID=0x00)
Transmit unnumbered information (UI) frame.
Definition: AX25.cpp:270
AX25Client::operator=
AX25Client & operator=(const AX25Client &ax25)
Overload for assignment operator.
Definition: AX25.cpp:216
AX25Client::begin
int16_t begin(const char *srcCallsign, uint8_t srcSSID=0x00, uint8_t preLen=8)
Initialization method.
Definition: AX25.cpp:244
AX25Client::AX25Client
AX25Client(PhysicalLayer *phy)
Constructor for 2-FSK mode.
Definition: AX25.cpp:187
AX25Frame
Abstraction of AX.25 frame format.
Definition: AX25.h:71
AX25Frame::setSendSequence
void setSendSequence(uint8_t seqNumber)
Method to set send sequence number.
Definition: AX25.cpp:183
AX25Frame::AX25Frame
AX25Frame(const char *destCallsign, uint8_t destSSID, const char *srcCallsign, uint8_t srcSSID, uint8_t control)
Overloaded constructor, for frames without info field.
Definition: AX25.cpp:5
AX25Frame::repeaterCallsigns
char ** repeaterCallsigns
Array of repeater callsigns.
Definition: AX25.h:132
AX25Frame::srcCallsign
char srcCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN+1]
Callsign of the source station.
Definition: AX25.h:86
AX25Frame::setRecvSequence
void setRecvSequence(uint8_t seqNumber)
Method to set receive sequence number.
Definition: AX25.cpp:179
AX25Frame::sendSeqNumber
uint16_t sendSeqNumber
Send sequence number.
Definition: AX25.h:121
AX25Frame::srcSSID
uint8_t srcSSID
SSID of the source station.
Definition: AX25.h:91
AX25Frame::operator=
AX25Frame & operator=(const AX25Frame &frame)
Overload for assignment operator.
Definition: AX25.cpp:108
AX25Frame::control
uint8_t control
The control field.
Definition: AX25.h:101
AX25Frame::repeaterSSIDs
uint8_t * repeaterSSIDs
Array of repeater SSIDs.
Definition: AX25.h:137
AX25Frame::infoLen
uint16_t infoLen
Number of bytes in the information field.
Definition: AX25.h:111
AX25Frame::setRepeaters
int16_t setRepeaters(char **repeaterCallsigns, uint8_t *repeaterSSIDs, uint8_t numRepeaters)
Method to set the repeater callsigns and SSIDs.
Definition: AX25.cpp:143
AX25Frame::destCallsign
char destCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN+1]
Callsign of the destination station.
Definition: AX25.h:76
AX25Frame::info
uint8_t * info
The info field.
Definition: AX25.h:127
AX25Frame::protocolID
uint8_t protocolID
The protocol identifier (PID) field.
Definition: AX25.h:106
AX25Frame::~AX25Frame
~AX25Frame()
Default destructor.
Definition: AX25.cpp:90
AX25Frame::numRepeaters
uint8_t numRepeaters
Number of repeaters to be used.
Definition: AX25.h:96
AX25Frame::rcvSeqNumber
uint8_t rcvSeqNumber
Receive sequence number.
Definition: AX25.h:116
AX25Frame::destSSID
uint8_t destSSID
SSID of the destination station.
Definition: AX25.h:81
BellClient
Client for Bell modem communication. The public interface is the same as Arduino Serial.
Definition: BellModem.h:57
PhysicalLayer
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition: PhysicalLayer.h:135