RadioLib
Universal wireless communication library for Arduino
APRS.h
1 #if !defined(_RADIOLIB_RADIOLIB_APRS_H)
2 #define _RADIOLIB_RADIOLIB_APRS_H
3 
4 #include "../../TypeDef.h"
5 
6 #if !defined(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 
35 #define RADIOLIB_APRS_MIC_E_TYPE_OFF_DUTY 0b00000111
36 #define RADIOLIB_APRS_MIC_E_TYPE_EN_ROUTE 0b00000110
37 #define RADIOLIB_APRS_MIC_E_TYPE_IN_SERVICE 0b00000101
38 #define RADIOLIB_APRS_MIC_E_TYPE_RETURNING 0b00000100
39 #define RADIOLIB_APRS_MIC_E_TYPE_COMMITTED 0b00000011
40 #define RADIOLIB_APRS_MIC_E_TYPE_SPECIAL 0b00000010
41 #define RADIOLIB_APRS_MIC_E_TYPE_PRIORITY 0b00000001
42 #define RADIOLIB_APRS_MIC_E_TYPE_EMERGENCY 0b00000000
47 // magic offset applied to encode extra bits in the Mic-E destination field
48 #define RADIOLIB_APRS_MIC_E_DEST_BIT_OFFSET 25
49 
50 // Mic-E data types
51 #define RADIOLIB_APRS_MIC_E_GPS_DATA_CURRENT '`'
52 #define RADIOLIB_APRS_MIC_E_GPS_DATA_OLD '\''
53 
54 // Mic-E telemetry flags
55 #define RADIOLIB_APRS_MIC_E_TELEMETRY_LEN_2 '`'
56 #define RADIOLIB_APRS_MIC_E_TELEMETRY_LEN_5 '\''
57 
58 // alias for unused altitude in Mic-E
59 #define RADIOLIB_APRS_MIC_E_ALTITUDE_UNUSED -1000000
60 
66 class APRSClient {
67  public:
73  explicit APRSClient(AX25Client* ax);
74 
75  // basic methods
76 
86  int16_t begin(char symbol, bool alt = false);
87 
105  int16_t sendPosition(char* destCallsign, uint8_t destSSID, char* lat, char* lon, char* msg = NULL, char* time = NULL);
106 
107  /*
108  \brief Transmit position using Mic-E encoding.
109 
110  \param lat Geographical latitude, positive for north, negative for south.
111 
112  \param lon Geographical longitude, positive for east, negative for west.
113 
114  \param heading Heading in degrees.
115 
116  \param speed Speed in knots.
117 
118  \param type Mic-E message type - see \ref mic_e_message_types.
119 
120  \param telem Pointer to telemetry array (either 2 or 5 bytes long). NULL when telemetry is not used.
121 
122  \param telemLen Telemetry length, 2 or 5. 0 when telemetry is not used.
123 
124  \param grid Maidenhead grid locator. NULL when not used.
125 
126  \param status Status message to send. NULL when not used.
127 
128  \param alt Altitude to send. RADIOLIB_APRS_MIC_E_ALTITUDE_UNUSED when not used.
129  */
130  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);
131 
143  int16_t sendFrame(char* destCallsign, uint8_t destSSID, char* info);
144 
145 #if !defined(RADIOLIB_GODMODE)
146  private:
147 #endif
148  AX25Client* _ax;
149 
150  // default APRS symbol (car)
151  char _symbol = '>';
152  char _table = '/';
153 };
154 
155 #endif
156 
157 #endif
Client for APRS communication.
Definition: APRS.h:66
int16_t sendFrame(char *destCallsign, uint8_t destSSID, char *info)
Transmit generic APRS frame.
Definition: APRS.cpp:218
APRSClient(AX25Client *ax)
Default constructor.
Definition: APRS.cpp:4
int16_t begin(char symbol, bool alt=false)
Initialization method.
Definition: APRS.cpp:8
int16_t sendPosition(char *destCallsign, uint8_t destSSID, char *lat, char *lon, char *msg=NULL, char *time=NULL)
Transmit position.
Definition: APRS.cpp:21
Client for AX25 communication.
Definition: AX25.h:279