RadioLib
Universal wireless communication library for Arduino
APRS.h
1 #if !defined(_RADIOLIB_APRS_H)
2 #define _RADIOLIB_APRS_H
3 
4 #include "../../TypeDef.h"
5 
6 #if !RADIOLIB_EXCLUDE_APRS
7 
8 #include "../PhysicalLayer/PhysicalLayer.h"
9 #include "../AX25/AX25.h"
10 
11 // APRS data type identifiers
12 #define RADIOLIB_APRS_DATA_TYPE_POSITION_NO_TIME_NO_MSG "!"
13 #define RADIOLIB_APRS_DATA_TYPE_GPS_RAW "$"
14 #define RADIOLIB_APRS_DATA_TYPE_ITEM ")"
15 #define RADIOLIB_APRS_DATA_TYPE_TEST ","
16 #define RADIOLIB_APRS_DATA_TYPE_POSITION_TIME_NO_MSG "/"
17 #define RADIOLIB_APRS_DATA_TYPE_MSG ":"
18 #define RADIOLIB_APRS_DATA_TYPE_OBJECT ";"
19 #define RADIOLIB_APRS_DATA_TYPE_STATION_CAPABILITES "<"
20 #define RADIOLIB_APRS_DATA_TYPE_POSITION_NO_TIME_MSG "="
21 #define RADIOLIB_APRS_DATA_TYPE_STATUS ">"
22 #define RADIOLIB_APRS_DATA_TYPE_QUERY "?"
23 #define RADIOLIB_APRS_DATA_TYPE_POSITION_TIME_MSG "@"
24 #define RADIOLIB_APRS_DATA_TYPE_TELEMETRY "T"
25 #define RADIOLIB_APRS_DATA_TYPE_MAIDENHEAD_BEACON "["
26 #define RADIOLIB_APRS_DATA_TYPE_WEATHER_REPORT "_"
27 #define RADIOLIB_APRS_DATA_TYPE_USER_DEFINED "{"
28 #define RADIOLIB_APRS_DATA_TYPE_THIRD_PARTY "}"
29 
36 #define RADIOLIB_APRS_MIC_E_TYPE_OFF_DUTY 0b00000111
37 
39 #define RADIOLIB_APRS_MIC_E_TYPE_EN_ROUTE 0b00000110
40 
42 #define RADIOLIB_APRS_MIC_E_TYPE_IN_SERVICE 0b00000101
43 
45 #define RADIOLIB_APRS_MIC_E_TYPE_RETURNING 0b00000100
46 
48 #define RADIOLIB_APRS_MIC_E_TYPE_COMMITTED 0b00000011
49 
51 #define RADIOLIB_APRS_MIC_E_TYPE_SPECIAL 0b00000010
52 
54 #define RADIOLIB_APRS_MIC_E_TYPE_PRIORITY 0b00000001
55 
57 #define RADIOLIB_APRS_MIC_E_TYPE_EMERGENCY 0b00000000
58 
63 // magic offset applied to encode extra bits in the Mic-E destination field
64 #define RADIOLIB_APRS_MIC_E_DEST_BIT_OFFSET 25
65 
66 // Mic-E data types
67 #define RADIOLIB_APRS_MIC_E_GPS_DATA_CURRENT '`'
68 #define RADIOLIB_APRS_MIC_E_GPS_DATA_OLD '\''
69 
70 // Mic-E telemetry flags
71 #define RADIOLIB_APRS_MIC_E_TELEMETRY_LEN_2 '`'
72 #define RADIOLIB_APRS_MIC_E_TELEMETRY_LEN_5 '\''
73 
74 // alias for unused altitude in Mic-E
75 #define RADIOLIB_APRS_MIC_E_ALTITUDE_UNUSED -1000000
76 
77 // special header applied for APRS over LoRa
78 #define RADIOLIB_APRS_LORA_HEADER "<\xff\x01"
79 #define RADIOLIB_APRS_LORA_HEADER_LEN (3)
80 
85 class APRSClient {
86  public:
91  explicit APRSClient(AX25Client* ax);
92 
97  explicit APRSClient(PhysicalLayer* phy);
98 
99  // basic methods
100 
109  int16_t begin(char sym, char* callsign = NULL, uint8_t ssid = 0, bool alt = false);
110 
121  int16_t sendPosition(char* destCallsign, uint8_t destSSID, char* lat, char* lon, char* msg = NULL, char* time = NULL);
122 
136  int16_t sendMicE(float lat, float lon, uint16_t heading, uint16_t speed, uint8_t type, uint8_t* telem = NULL, size_t telemLen = 0, char* grid = NULL, char* status = NULL, int32_t alt = RADIOLIB_APRS_MIC_E_ALTITUDE_UNUSED);
137 
145  int16_t sendFrame(char* destCallsign, uint8_t destSSID, char* info);
146 
147 #if !RADIOLIB_GODMODE
148  private:
149 #endif
150  AX25Client* axClient;
151  PhysicalLayer* phyLayer;
152 
153  // default APRS symbol (car)
154  char symbol = '>';
155  char table = '/';
156 
157  // source callsign when using APRS over LoRa
158  char src[RADIOLIB_AX25_MAX_CALLSIGN_LEN + 1] = { 0 };
159  uint8_t id = 0;
160 };
161 
162 #endif
163 
164 #endif
Client for APRS communication.
Definition: APRS.h:85
int16_t sendFrame(char *destCallsign, uint8_t destSSID, char *info)
Transmit generic APRS frame.
Definition: APRS.cpp:246
APRSClient(AX25Client *ax)
Constructor for "classic" mode using AX.25/AFSK.
Definition: APRS.cpp:7
int16_t begin(char sym, char *callsign=NULL, uint8_t ssid=0, bool alt=false)
Initialization method.
Definition: APRS.cpp:17
int16_t sendPosition(char *destCallsign, uint8_t destSSID, char *lat, char *lon, char *msg=NULL, char *time=NULL)
Transmit position.
Definition: APRS.cpp:37
int16_t sendMicE(float lat, float lon, uint16_t heading, uint16_t speed, uint8_t type, uint8_t *telem=NULL, size_t telemLen=0, char *grid=NULL, char *status=NULL, int32_t alt=RADIOLIB_APRS_MIC_E_ALTITUDE_UNUSED)
Transmit position using Mic-E encoding.
Definition: APRS.cpp:81
Client for AX25 communication.
Definition: AX25.h:233
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition: PhysicalLayer.h:54