RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
AX25.h
1#if !defined(_RADIOLIB_AX25_H)
2#define _RADIOLIB_AX25_H
3
4#include "../../TypeDef.h"
5
6#if !RADIOLIB_EXCLUDE_AX25
7
8#include "../PhysicalLayer/PhysicalLayer.h"
9#include "../AFSK/AFSK.h"
10#include "../BellModem/BellModem.h"
11#include "../../utils/CRC.h"
12
13// maximum callsign length in bytes
14#define RADIOLIB_AX25_MAX_CALLSIGN_LEN 6
15
16// flag field MSB LSB DESCRIPTION
17#define RADIOLIB_AX25_FLAG 0b01111110 // 7 0 AX.25 frame start/end flag
18
19// address field
20#define RADIOLIB_AX25_SSID_COMMAND_DEST 0b10000000 // 7 7 frame type: command (set in destination SSID)
21#define RADIOLIB_AX25_SSID_COMMAND_SOURCE 0b00000000 // 7 7 command (set in source SSID)
22#define RADIOLIB_AX25_SSID_RESPONSE_DEST 0b00000000 // 7 7 response (set in destination SSID)
23#define RADIOLIB_AX25_SSID_RESPONSE_SOURCE 0b10000000 // 7 7 response (set in source SSID)
24#define RADIOLIB_AX25_SSID_HAS_NOT_BEEN_REPEATED 0b00000000 // 7 7 not repeated yet (set in repeater SSID)
25#define RADIOLIB_AX25_SSID_HAS_BEEN_REPEATED 0b10000000 // 7 7 repeated (set in repeater SSID)
26#define RADIOLIB_AX25_SSID_RESERVED_BITS 0b01100000 // 6 5 reserved bits in SSID
27#define RADIOLIB_AX25_SSID_HDLC_EXTENSION_CONTINUE 0b00000000 // 0 0 HDLC extension bit: next octet contains more address information
28#define RADIOLIB_AX25_SSID_HDLC_EXTENSION_END 0b00000001 // 0 0 address field end
29
30// control field
31#define RADIOLIB_AX25_CONTROL_U_SET_ASYNC_BAL_MODE 0b01101100 // 7 2 U frame type: set asynchronous balanced mode (connect request)
32#define RADIOLIB_AX25_CONTROL_U_SET_ASYNC_BAL_MODE_EXT 0b00101100 // 7 2 set asynchronous balanced mode extended (connect request with module 128)
33#define RADIOLIB_AX25_CONTROL_U_DISCONNECT 0b01000000 // 7 2 disconnect request
34#define RADIOLIB_AX25_CONTROL_U_DISCONNECT_MODE 0b00001100 // 7 2 disconnect mode (system busy or disconnected)
35#define RADIOLIB_AX25_CONTROL_U_UNNUMBERED_ACK 0b01100000 // 7 2 unnumbered acknowledge
36#define RADIOLIB_AX25_CONTROL_U_FRAME_REJECT 0b10000100 // 7 2 frame reject
37#define RADIOLIB_AX25_CONTROL_U_UNNUMBERED_INFORMATION 0b00000000 // 7 2 unnumbered information
38#define RADIOLIB_AX25_CONTROL_U_EXHANGE_IDENTIFICATION 0b10101100 // 7 2 exchange ID
39#define RADIOLIB_AX25_CONTROL_U_TEST 0b11100000 // 7 2 test
40#define RADIOLIB_AX25_CONTROL_POLL_FINAL_ENABLED 0b00010000 // 4 4 control field poll/final bit: enabled
41#define RADIOLIB_AX25_CONTROL_POLL_FINAL_DISABLED 0b00000000 // 4 4 disabled
42#define RADIOLIB_AX25_CONTROL_S_RECEIVE_READY 0b00000000 // 3 2 S frame type: receive ready (system ready to receive)
43#define RADIOLIB_AX25_CONTROL_S_RECEIVE_NOT_READY 0b00000100 // 3 2 receive not ready (TNC buffer full)
44#define RADIOLIB_AX25_CONTROL_S_REJECT 0b00001000 // 3 2 reject (out of sequence or duplicate)
45#define RADIOLIB_AX25_CONTROL_S_SELECTIVE_REJECT 0b00001100 // 3 2 selective reject (single frame repeat request)
46#define RADIOLIB_AX25_CONTROL_INFORMATION_FRAME 0b00000000 // 0 0 frame type: information (I frame)
47#define RADIOLIB_AX25_CONTROL_SUPERVISORY_FRAME 0b00000001 // 1 0 supervisory (S frame)
48#define RADIOLIB_AX25_CONTROL_UNNUMBERED_FRAME 0b00000011 // 1 0 unnumbered (U frame)
49
50// protocol identifier field
51#define RADIOLIB_AX25_PID_ISO_8208 0x01
52#define RADIOLIB_AX25_PID_TCP_IP_COMPRESSED 0x06
53#define RADIOLIB_AX25_PID_TCP_IP_UNCOMPRESSED 0x07
54#define RADIOLIB_AX25_PID_SEGMENTATION_FRAGMENT 0x08
55#define RADIOLIB_AX25_PID_TEXNET_DATAGRAM_PROTOCOL 0xC3
56#define RADIOLIB_AX25_PID_LINK_QUALITY_PROTOCOL 0xC4
57#define RADIOLIB_AX25_PID_APPLETALK 0xCA
58#define RADIOLIB_AX25_PID_APPLETALK_ARP 0xCB
59#define RADIOLIB_AX25_PID_ARPA_INTERNET_PROTOCOL 0xCC
60#define RADIOLIB_AX25_PID_ARPA_ADDRESS_RESOLUTION 0xCD
61#define RADIOLIB_AX25_PID_FLEXNET 0xCE
62#define RADIOLIB_AX25_PID_NET_ROM 0xCF
63#define RADIOLIB_AX25_PID_NO_LAYER_3 0xF0
64#define RADIOLIB_AX25_PID_ESCAPE_CHARACTER 0xFF
65
70class AX25Frame {
71 public:
75 char destCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1];
76
80 uint8_t destSSID;
81
85 char srcCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1];
86
90 uint8_t srcSSID;
91
95 uint8_t numRepeaters;
96
100 uint8_t control;
101
105 uint8_t protocolID;
106
110 uint16_t infoLen;
111
116
121
122 #if !RADIOLIB_STATIC_ONLY
126 uint8_t* info;
127
132
137 #else
141 uint8_t info[RADIOLIB_STATIC_ARRAY_SIZE];
142
146 char repeaterCallsigns[8][RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1];
147
151 uint8_t repeaterSSIDs[8];
152 #endif
153
162 AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control);
163
174 AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control, uint8_t protocolID, const char* info);
175
187 AX25Frame(const char* destCallsign, uint8_t destSSID, const char* srcCallsign, uint8_t srcSSID, uint8_t control, uint8_t protocolID, const uint8_t* info, uint16_t infoLen);
188
193 AX25Frame(const AX25Frame& frame);
194
198 ~AX25Frame();
199
204 AX25Frame& operator=(const AX25Frame& frame);
205
213 int16_t setRepeaters(char** repeaterCallsigns, const uint8_t* repeaterSSIDs, uint8_t numRepeaters);
214
219 void setRecvSequence(uint8_t seqNumber);
220
225 void setSendSequence(uint8_t seqNumber);
226};
227
233 public:
238 explicit AX25Client(PhysicalLayer* phy);
239
240 #if !RADIOLIB_EXCLUDE_AFSK
245 explicit AX25Client(AFSKClient* aud);
246
251 AX25Client(const AX25Client& ax25);
252
257 AX25Client& operator=(const AX25Client& ax25);
258
267 int16_t setCorrection(int16_t mark, int16_t space, float length = 1.0f);
268 #endif
269
270 // basic methods
271
281 int16_t begin(const char* srcCallsign, uint8_t srcSSID = 0x00, uint8_t preLen = 8);
282
288 void setScrambler(uint32_t poly, uint32_t init = 0);
289
290 #if defined(RADIOLIB_BUILD_ARDUINO)
299 int16_t transmit(String& str, const char* destCallsign, uint8_t destSSID = 0x00);
300 #endif
301
310 int16_t transmit(const char* str, const char* destCallsign, uint8_t destSSID = 0x00);
311
317 int16_t sendFrame(AX25Frame* frame);
318
319#if !RADIOLIB_GODMODE
320 private:
321#endif
322 friend class APRSClient;
323
324 PhysicalLayer* phyLayer;
325 #if !RADIOLIB_EXCLUDE_AFSK
326 AFSKClient* audio;
327 BellClient* bellModem;
328 #endif
329
330 char sourceCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1] = { 0 };
331 uint8_t sourceSSID = 0;
332 uint16_t preambleLen = 0;
333 uint32_t scramblerInit = 0;
334 uint32_t scramblerPoly = 0;
335
336 void getCallsign(char* buff);
337 uint8_t getSSID();
338};
339
340#endif
341
342#endif
Client for audio-based transmissions. Requires Arduino tone() function, and a module capable of direc...
Definition AFSK.h:16
Client for APRS communication.
Definition APRS.h:85
Client for AX25 communication.
Definition AX25.h:232
void setScrambler(uint32_t poly, uint32_t init=0)
Set scrambling polynomail and initial value.
Definition AX25.cpp:266
int16_t sendFrame(AX25Frame *frame)
Transmit arbitrary AX.25 frame.
Definition AX25.cpp:290
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:234
int16_t transmit(const char *str, const char *destCallsign, uint8_t destSSID=0x00)
Transmit unnumbered information (UI) frame.
Definition AX25.cpp:277
AX25Client & operator=(const AX25Client &ax25)
Overload for assignment operator.
Definition AX25.cpp:218
int16_t begin(const char *srcCallsign, uint8_t srcSSID=0x00, uint8_t preLen=8)
Initialization method.
Definition AX25.cpp:246
Abstraction of AX.25 frame format.
Definition AX25.h:70
void setSendSequence(uint8_t seqNumber)
Method to set send sequence number.
Definition AX25.cpp:185
char ** repeaterCallsigns
Array of repeater callsigns.
Definition AX25.h:131
char srcCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN+1]
Callsign of the source station.
Definition AX25.h:85
void setRecvSequence(uint8_t seqNumber)
Method to set receive sequence number.
Definition AX25.cpp:181
uint16_t sendSeqNumber
Send sequence number.
Definition AX25.h:120
uint8_t srcSSID
SSID of the source station.
Definition AX25.h:90
AX25Frame & operator=(const AX25Frame &frame)
Overload for assignment operator.
Definition AX25.cpp:110
uint8_t control
The control field.
Definition AX25.h:100
uint8_t * repeaterSSIDs
Array of repeater SSIDs.
Definition AX25.h:136
uint16_t infoLen
Number of bytes in the information field.
Definition AX25.h:110
char destCallsign[RADIOLIB_AX25_MAX_CALLSIGN_LEN+1]
Callsign of the destination station.
Definition AX25.h:75
uint8_t * info
The info field.
Definition AX25.h:126
uint8_t protocolID
The protocol identifier (PID) field.
Definition AX25.h:105
~AX25Frame()
Default destructor.
Definition AX25.cpp:92
int16_t setRepeaters(char **repeaterCallsigns, const uint8_t *repeaterSSIDs, uint8_t numRepeaters)
Method to set the repeater callsigns and SSIDs.
Definition AX25.cpp:145
uint8_t numRepeaters
Number of repeaters to be used.
Definition AX25.h:95
uint8_t rcvSeqNumber
Receive sequence number.
Definition AX25.h:115
uint8_t destSSID
SSID of the destination station.
Definition AX25.h:80
Client for Bell modem communication. The public interface is the same as Arduino Serial.
Definition BellModem.h:54
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition PhysicalLayer.h:257