-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlora-aprs.ino
78 lines (67 loc) · 2.25 KB
/
lora-aprs.ino
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
/************************************************************************************
* Experimental functions to decode LoRa-APRS
************************************************************************************/
void parseAPRSPacket(byte *buf)
{
String gps_Lat;
String gps_Long;
String gps_Alt;
String message((char *) buf);
packetCounter++;
Telemetry.raw = "LoRa-APRS packet";
Serial.println(message);
// Get the source of the APRS packet
int pos_Src = message.indexOf('>');
if (pos_Src >= 0)
{
Telemetry.payload_callsign = message.substring(3, pos_Src);
Serial.print(F("APRS source:\t")); Serial.println(Telemetry.payload_callsign);
}
// Get the location of the APRS payload
int pos_Loc = message.indexOf(':');
if (pos_Loc > 0)
{
// Get the latitude
gps_Lat = message.substring(pos_Loc+2,pos_Loc+10);
// Convert the latitude to decimal
Telemetry.lat = gps_Lat.substring(0,2).toFloat()+(gps_Lat.substring(2,7).toFloat() / 60);
if (gps_Lat[7]== 'S')
{
Telemetry.lat = Telemetry.lat*-1;
}
Serial.print("APRS latitude:\t"); Serial.println(Telemetry.lat,5);
// Get the longitude
gps_Long = message.substring(pos_Loc+11,pos_Loc+20);
Telemetry.lon = gps_Long.substring(0,3).toFloat()+(gps_Long.substring(3,8).toFloat() / 60);
Serial.print("APRS longitude:\t"); Serial.println(Telemetry.lon,5);
if (gps_Long[8] == 'W')
{
Telemetry.lon = Telemetry.lon*-1;
}
}
// Get the altitude of the APRS payload
int pos_Alt = message.indexOf("/A=");
if (pos_Alt > 0)
{
// altitude is in feet
gps_Alt = message.substring(pos_Alt+3,pos_Alt+9);
// Convert to meters
Telemetry.alt = gps_Alt.toFloat() / 3.2808;
Serial.print(F("APRS altitude:\t")); Serial.print(Telemetry.alt,0); Serial.println(F(" meter"));
}
else
{
Telemetry.alt=0;
}
// Determine your location
setUploaderPosition();
// Determine the distance and bearing of the payload
setDistanceAndBearing();
// Create a visual end-of-packet on the Serial console
closePacket();
// Update the SSD1306 display
#if defined(USE_SSD1306)
// displayUpdate();
oledUpdateNeeded = true;
#endif
}