1 #if !defined(_RADIOLIB_AX25_H) 2 #define _RADIOLIB_AX25_H 4 #include "../../TypeDef.h" 6 #if !defined(RADIOLIB_EXCLUDE_AX25) 8 #include "../PhysicalLayer/PhysicalLayer.h" 9 #include "../AFSK/AFSK.h" 12 #define SET_BIT_IN_ARRAY(A, k) ( A[(k/8)] |= (1 << (k%8)) ) 13 #define CLEAR_BIT_IN_ARRAY(A, k) ( A[(k/8)] &= ~(1 << (k%8)) ) 14 #define TEST_BIT_IN_ARRAY(A, k) ( A[(k/8)] & (1 << (k%8)) ) 15 #define GET_BIT_IN_ARRAY(A, k) ( (A[(k/8)] & (1 << (k%8))) ? 1 : 0 ) 18 #define XOR(A, B) ( ((A) || (B)) && !((A) && (B)) ) 19 #define CRC_CCITT_POLY 0x1021 // generator polynomial 20 #define CRC_CCITT_POLY_REVERSED 0x8408 // CRC_CCITT_POLY in reversed bit order 21 #define CRC_CCITT_INIT 0xFFFF // initial value 24 #define AX25_MAX_CALLSIGN_LEN 6 27 #define AX25_FLAG 0b01111110 // 7 0 AX.25 frame start/end flag 30 #define AX25_SSID_COMMAND_DEST 0b10000000 // 7 7 frame type: command (set in destination SSID) 31 #define AX25_SSID_COMMAND_SOURCE 0b00000000 // 7 7 command (set in source SSID) 32 #define AX25_SSID_RESPONSE_DEST 0b00000000 // 7 7 response (set in destination SSID) 33 #define AX25_SSID_RESPONSE_SOURCE 0b10000000 // 7 7 response (set in source SSID) 34 #define AX25_SSID_HAS_NOT_BEEN_REPEATED 0b00000000 // 7 7 not repeated yet (set in repeater SSID) 35 #define AX25_SSID_HAS_BEEN_REPEATED 0b10000000 // 7 7 repeated (set in repeater SSID) 36 #define AX25_SSID_RESERVED_BITS 0b01100000 // 6 5 reserved bits in SSID 37 #define AX25_SSID_HDLC_EXTENSION_CONTINUE 0b00000000 // 0 0 HDLC extension bit: next octet contains more address information 38 #define AX25_SSID_HDLC_EXTENSION_END 0b00000001 // 0 0 address field end 41 #define AX25_CONTROL_U_SET_ASYNC_BAL_MODE 0b01101100 // 7 2 U frame type: set asynchronous balanced mode (connect request) 42 #define AX25_CONTROL_U_SET_ASYNC_BAL_MODE_EXT 0b00101100 // 7 2 set asynchronous balanced mode extended (connect request with module 128) 43 #define AX25_CONTROL_U_DISCONNECT 0b01000000 // 7 2 disconnect request 44 #define AX25_CONTROL_U_DISCONNECT_MODE 0b00001100 // 7 2 disconnect mode (system busy or disconnected) 45 #define AX25_CONTROL_U_UNNUMBERED_ACK 0b01100000 // 7 2 unnumbered acknowledge 46 #define AX25_CONTROL_U_FRAME_REJECT 0b10000100 // 7 2 frame reject 47 #define AX25_CONTROL_U_UNNUMBERED_INFORMATION 0b00000000 // 7 2 unnumbered information 48 #define AX25_CONTROL_U_EXHANGE_IDENTIFICATION 0b10101100 // 7 2 exchange ID 49 #define AX25_CONTROL_U_TEST 0b11100000 // 7 2 test 50 #define AX25_CONTROL_POLL_FINAL_ENABLED 0b00010000 // 4 4 control field poll/final bit: enabled 51 #define AX25_CONTROL_POLL_FINAL_DISABLED 0b00000000 // 4 4 disabled 52 #define AX25_CONTROL_S_RECEIVE_READY 0b00000000 // 3 2 S frame type: receive ready (system ready to receive) 53 #define AX25_CONTROL_S_RECEIVE_NOT_READY 0b00000100 // 3 2 receive not ready (TNC buffer full) 54 #define AX25_CONTROL_S_REJECT 0b00001000 // 3 2 reject (out of sequence or duplicate) 55 #define AX25_CONTROL_S_SELECTIVE_REJECT 0b00001100 // 3 2 selective reject (single frame repeat request) 56 #define AX25_CONTROL_INFORMATION_FRAME 0b00000000 // 0 0 frame type: information (I frame) 57 #define AX25_CONTROL_SUPERVISORY_FRAME 0b00000001 // 1 0 supervisory (S frame) 58 #define AX25_CONTROL_UNNUMBERED_FRAME 0b00000011 // 1 0 unnumbered (U frame) 61 #define AX25_PID_ISO_8208 0x01 62 #define AX25_PID_TCP_IP_COMPRESSED 0x06 63 #define AX25_PID_TCP_IP_UNCOMPRESSED 0x07 64 #define AX25_PID_SEGMENTATION_FRAGMENT 0x08 65 #define AX25_PID_TEXNET_DATAGRAM_PROTOCOL 0xC3 66 #define AX25_PID_LINK_QUALITY_PROTOCOL 0xC4 67 #define AX25_PID_APPLETALK 0xCA 68 #define AX25_PID_APPLETALK_ARP 0xCB 69 #define AX25_PID_ARPA_INTERNET_PROTOCOL 0xCC 70 #define AX25_PID_ARPA_ADDRESS_RESOLUTION 0xCD 71 #define AX25_PID_FLEXNET 0xCE 72 #define AX25_PID_NET_ROM 0xCF 73 #define AX25_PID_NO_LAYER_3 0xF0 74 #define AX25_PID_ESCAPE_CHARACTER 0xFF 77 #define AX25_AFSK_MARK 1200 78 #define AX25_AFSK_SPACE 2200 81 #define AX25_AFSK_TONE_DURATION 833 140 #ifndef RADIOLIB_STATIC_ONLY 159 uint8_t info[RADIOLIB_STATIC_ARRAY_SIZE];
164 char repeaterCallsigns[8][AX25_MAX_CALLSIGN_LEN + 1];
169 uint8_t repeaterSSIDs[8];
185 AX25Frame(
const char* destCallsign, uint8_t destSSID,
const char* srcCallsign, uint8_t srcSSID, uint8_t control);
204 AX25Frame(
const char* destCallsign, uint8_t destSSID,
const char* srcCallsign, uint8_t srcSSID, uint8_t control, uint8_t protocolID,
const char* info);
225 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);
257 int16_t
setRepeaters(
char** repeaterCallsigns, uint8_t* repeaterSSIDs, uint8_t numRepeaters);
288 #if !defined(RADIOLIB_EXCLUDE_AFSK) 310 int16_t begin(
const char*
srcCallsign, uint8_t
srcSSID = 0x00, uint8_t preambleLen = 8);
334 #ifndef RADIOLIB_GODMODE 338 #if !defined(RADIOLIB_EXCLUDE_AFSK) 342 char _srcCallsign[AX25_MAX_CALLSIGN_LEN + 1] = {0, 0, 0, 0, 0, 0, 0};
343 uint8_t _srcSSID = 0;
344 uint16_t _preambleLen = 0;
346 static uint16_t getFrameCheckSequence(uint8_t* buff,
size_t len);
347 static uint8_t flipBits(uint8_t b);
348 static uint16_t flipBits16(uint16_t i);
~AX25Frame()
Default destructor.
Definition: AX25.cpp:56
AX25Frame & operator=(const AX25Frame &frame)
Overload for assignment operator.
Definition: AX25.cpp:74
Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direc...
Definition: AFSK.h:17
char ** repeaterCallsigns
Array of repeater callsigns.
Definition: AX25.h:149
uint8_t numRepeaters
Number of repeaters to be used.
Definition: AX25.h:113
int16_t setRepeaters(char **repeaterCallsigns, uint8_t *repeaterSSIDs, uint8_t numRepeaters)
Method to set the repeater callsigns and SSIDs.
Definition: AX25.cpp:109
uint8_t protocolID
The protocol identifier (PID) field.
Definition: AX25.h:123
uint16_t infoLen
Number of bytes in the information field.
Definition: AX25.h:128
void setRecvSequence(uint8_t seqNumber)
Method to set receive sequence number.
Definition: AX25.cpp:144
Abstraction of AX.25 frame format.
Definition: AX25.h:88
uint8_t destSSID
SSID of the destination station.
Definition: AX25.h:98
uint8_t * info
The info field.
Definition: AX25.h:144
uint8_t control
The control field.
Definition: AX25.h:118
uint8_t srcSSID
SSID of the source station.
Definition: AX25.h:108
char srcCallsign[AX25_MAX_CALLSIGN_LEN+1]
Callsign of the source station.
Definition: AX25.h:103
char destCallsign[AX25_MAX_CALLSIGN_LEN+1]
Callsign of the destination station.
Definition: AX25.h:93
uint16_t sendSeqNumber
Send sequence number.
Definition: AX25.h:138
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:4
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN...
Definition: PhysicalLayer.h:13
uint8_t * repeaterSSIDs
Array of repeater SSIDs.
Definition: AX25.h:154
void setSendSequence(uint8_t seqNumber)
Method to set send sequence number.
Definition: AX25.cpp:148
uint8_t rcvSeqNumber
Receive sequence number.
Definition: AX25.h:133
Client for AX25 communication.
Definition: AX25.h:279