aprs.h
Go to the documentation of this file.
1 /*
2  * KubOS Core Flight Services
3  * Copyright (C) 2015 Kubos Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
32 #ifndef APRS_H
33 #define APRS_H
34 
35 #include <stdint.h>
36 
38 
39 #define APRS_DIGI_APRS ax25_addr_init("APRS")
40 #define APRS_DIGI_TCPIP ax25_addr_init("TCPIP*")
41 #define APRS_NOCALL ax25_addr_init("N0CALL")
42 
43 #define APRSIS_ADDRS(src_) { \
44  APRS_DIGI_APRS, \
45  ax25_addr_init(src_), \
46  APRS_DIGI_APRS, \
47  APRS_DIGI_TCPIP, \
48 }
49 
50 #define APRSIS_ADDRS_LEN 4
51 
52 // APRS position string
53 // POSITION = '/{time}h{location}O{course:03.0f}/{speed:03.0f}/A={alt:06.0f}'
54 // /HHMMSShDDMM.MMN/DDDMM.MMNOCCC/SSS/A=AAAAAA
55 
56 #define APRS_POSITION_LEN 43
57 
58 typedef struct aprs_position_s {
59  uint8_t hour;
60  uint8_t minute;
61  uint8_t second;
62  float latitude; // --90 -> 90 degrees
63  float longitude; // -180 -> 180 degrees
64  int16_t course; // degrees 1-360 clockwise from due north
65  int16_t speed; // in knots
66  int32_t altitude; // in feet
68 
69 int aprs_position_format(char* dest, aprs_position_t *position);
71 
72 // APRS telemetry string
73 // TELEMETRY = 'T#{id:03d},{r1:03d},{r2:03d},{r3:03d},{r4:03d},{r5:03d},{d:08b}'
74 // T#PPP,RRR,RRR,RRR,RRR,RRR,DDDDDDDD
75 
76 #define APRS_TELEMETRY_LEN 34
77 
78 #define APRS_T_ANALOG_MAXLENS { 7, 6, 5, 5, 4 }
79 #define APRS_T_DIGITAL_MAXLENS { 5, 4, 3, 3, 3, 2, 2, 2}
80 
81 typedef struct aprs_telemetry_desc_s {
82  char *name;
83  char *unit;
85 
86 typedef struct aprs_telemetry_s {
87  uint16_t packet_id;
88 
89  aprs_telemetry_desc_t analog_desc[5];
90  uint8_t analog[5];
91 
92  aprs_telemetry_desc_t digital_desc[8];
93  uint8_t digital;
95 
96 void aprs_telemetry_init(aprs_telemetry_t *telemetry);
97 void aprs_telemetry_add_analog(aprs_telemetry_t *telemetry, int field,
98  char *name, char *unit, uint8_t init_value);
99 void aprs_telemetry_add_digital(aprs_telemetry_t *telemetry, int bit,
100  char *name, char *unit, uint8_t bit_value);
101 
102 int aprs_telemetry_format(char* dest, aprs_telemetry_t *telemetry);
104 
105 // APRS Telemetry Parameter Name message
106 // :CCCCCCCCC:PARM.F1,F2,F3,F4,F5,B1,B2,B3,B4,B5,B6,B7,B8
107 
108 int aprs_telemetry_params_format(char *dest, char *callsign,
109  aprs_telemetry_t *telemetry);
110 int aprs_telemetry_units_format(char *dest, char *callsign,
111  aprs_telemetry_t *telemetry);
112 #endif
113 
114 /* @} */
uint8_t hour
Definition: aprs.h:59
struct aprs_telemetry_s aprs_telemetry_t
int aprs_telemetry_units_format(char *dest, char *callsign, aprs_telemetry_t *telemetry)
float longitude
Definition: aprs.h:63
int32_t altitude
Definition: aprs.h:66
void aprs_telemetry_init(aprs_telemetry_t *telemetry)
Definition: aprs.h:86
uint8_t digital
Definition: aprs.h:93
k_buffer_t * aprs_telemetry_build(aprs_telemetry_t *telemetry)
int aprs_telemetry_params_format(char *dest, char *callsign, aprs_telemetry_t *telemetry)
void aprs_telemetry_add_digital(aprs_telemetry_t *telemetry, int bit, char *name, char *unit, uint8_t bit_value)
uint16_t packet_id
Definition: aprs.h:87
struct aprs_position_s aprs_position_t
char * name
Definition: aprs.h:82
int16_t speed
Definition: aprs.h:65
int16_t course
Definition: aprs.h:64
void aprs_telemetry_add_analog(aprs_telemetry_t *telemetry, int field, char *name, char *unit, uint8_t init_value)
char * unit
Definition: aprs.h:83
struct aprs_telemetry_desc_s aprs_telemetry_desc_t
Definition: aprs.h:81
uint8_t second
Definition: aprs.h:61
int aprs_telemetry_format(char *dest, aprs_telemetry_t *telemetry)
Definition: k_buffer.h:43
Definition: aprs.h:58
int aprs_position_format(char *dest, aprs_position_t *position)
AX.25 module.
uint8_t minute
Definition: aprs.h:60
k_buffer_t * aprs_position_build(aprs_position_t *position)
float latitude
Definition: aprs.h:62