forked from Qyon/STM32_RTTY
-
Notifications
You must be signed in to change notification settings - Fork 15
/
aprs.cpp
83 lines (70 loc) · 2.05 KB
/
aprs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// Created by Admin on 2017-01-09.
//
#include "aprs.h"
#include "QAPRSBase.h"
#include "stdio.h"
#include "ublox.h"
#include "config.h"
#if !defined(__OPTIMIZE__)
#error "APRS Works only when optimization enabled at level at least -O2"
#endif
QAPRSBase qaprs;
void aprs_init(){
qaprs.init(0, 0, (char *) APRS_CALLSIGN, (const uint8_t) APRS_SSID, (char *) "APZQAP", '0', (char *) "WIDE1-1,WIDE2-1");
}
void aprs_timer_handler() {
qaprs.timerInterruptHandler();
}
uint8_t aprs_is_active() {
return qaprs.enabled;
}
void calcDMH(long x, int8_t* degrees, uint8_t* minutes, uint8_t* h_minutes) {
uint8_t sign = (uint8_t) (x > 0 ? 1 : 0);
if (!sign) {
x = -(x);
}
*degrees = (int8_t) (x / 1000000);
x = x - (*degrees * 1000000);
x = (x) * 60 / 10000;
*minutes = (uint8_t) (x / 100);
*h_minutes = (uint8_t) (x - (*minutes * 100));
if (!sign) {
*degrees = -*degrees;
}
}
void aprs_test(){
char packet_buffer[128];
sprintf(packet_buffer,
(":TEST1234567890")
);
qaprs.sendData(packet_buffer);
}
void aprs_send_position(GPSEntry gpsData, int8_t temperature, uint16_t voltage) {
char packet_buffer[128];
int8_t la_degrees, lo_degrees;
uint8_t la_minutes, la_h_minutes, lo_minutes, lo_h_minutes;
calcDMH(gpsData.lat_raw/10, &la_degrees, &la_minutes, &la_h_minutes);
calcDMH(gpsData.lon_raw/10, &lo_degrees, &lo_minutes, &lo_h_minutes);
static uint16_t aprs_packet_counter = 0;
aprs_packet_counter ++;
sprintf(packet_buffer,
("!%02d%02d.%02u%c%c%03d%02u.%02u%c%c/A=%06ld/P%dS%dT%dV%d%s"),
abs(la_degrees), la_minutes, la_h_minutes,
la_degrees > 0 ? 'N' : 'S',
APRS_DISPLAY_TABLE,
abs(lo_degrees), lo_minutes, lo_h_minutes,
lo_degrees > 0 ? 'E' : 'W',
APRS_DISPLAY_SYMBOL,
(gpsData.alt_raw/1000) * 3280 / 1000,
aprs_packet_counter,
gpsData.sats_raw,
temperature,
voltage,
APRS_COMMENT
);
qaprs.sendData(packet_buffer);
}
void aprs_change_tone_time(uint16_t x) {
qaprs._toneSendTime = x;
}