Skip to content

Commit

Permalink
APRS: a JSON setting to change Path value [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Nov 4, 2023
1 parent c574973 commit b21e57f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
7 changes: 7 additions & 0 deletions software/firmware/source/SoftRF/src/platform/ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2732,6 +2732,13 @@ static void ESP32_EEPROM_extension(int cmd)
strncpy(APRS_ToCall, tocall_s, sizeof(APRS_ToCall));
}
}
JsonVariant path = root["path"];
if (path.success()) {
const char * path_s = path.as<char*>();
if (strlen(path_s) < sizeof(APRS_Path)) {
strncpy(APRS_Path, path_s, sizeof(APRS_Path));
}
}
#endif /* USE_SA8X8 || ENABLE_PROL */
#if defined(USE_SA8X8)
JsonVariant sa868 = root["sa868"];
Expand Down
7 changes: 7 additions & 0 deletions software/firmware/source/SoftRF/src/platform/nRF52.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,13 @@ static void nRF52_EEPROM_extension(int cmd)
strncpy(APRS_ToCall, tocall_s, sizeof(APRS_ToCall));
}
}
JsonVariant path = root["path"];
if (path.success()) {
const char * path_s = path.as<char*>();
if (strlen(path_s) < sizeof(APRS_Path)) {
strncpy(APRS_Path, path_s, sizeof(APRS_Path));
}
}
#endif /* ENABLE_PROL */
#if defined(ENABLE_REMOTE_ID)
JsonVariant opid = root["uas_opid"];
Expand Down
12 changes: 8 additions & 4 deletions software/firmware/source/SoftRF/src/protocol/radio/APRS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ ParseAPRS aprsParse;

char APRS_FromCall[10] = "";
char APRS_ToCall [10] = "OGFLR"; // TODO: make use of assigned APSRFx value
char APRS_Path [10] = ""; // "WIDE1-1"

int packet2Raw(String &tnc2, AX25Msg &Packet) {
if (Packet.len < 5) return 0;
Expand Down Expand Up @@ -278,8 +279,7 @@ size_t aprs_encode(void *pkt, ufo_t *this_aircraft) {
}

snprintf(buf, sizeof(buf),
"%s>%s:"
"/"
"%s>%s" "%s%s" ":" "/"
"%02d%02d%02dh"
"%02d%05.2f%c"
"%c"
Expand All @@ -290,8 +290,8 @@ size_t aprs_encode(void *pkt, ufo_t *this_aircraft) {
"id%08X "
"%c%sfpm "
"+0.0rot" /* " 7.8dB -1.6kHz gps8x3" */,
strlen(APRS_FromCall) == 0 ? id_s : APRS_FromCall,
APRS_ToCall,
strlen(APRS_FromCall) == 0 ? id_s : APRS_FromCall, APRS_ToCall,
strlen(APRS_Path) > 0 ? "," : "", APRS_Path,
gnss.time.hour(), gnss.time.minute(), gnss.time.second(),
abs(lat_int), fabsf(lat_dec * 60), lat < 0 ? 'S' : 'N',
AprsIcon[acft_type][0],
Expand All @@ -305,6 +305,10 @@ size_t aprs_encode(void *pkt, ufo_t *this_aircraft) {
id | (XX << 24),
this_aircraft->vs < 0 ? '-' : '+', fpm_s);

#if 0 // ndef RASPBERRY_PI
Serial.print(strlen(buf)); Serial.print(" , "); Serial.println(buf);
#endif

strcpy((char *) pkt, buf);
return strlen(buf) + 1;
}
3 changes: 2 additions & 1 deletion software/firmware/source/SoftRF/src/protocol/radio/APRS.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#define APRS_SYNCWORD { 0x00 } /* TBD */
#define APRS_SYNCWORD_SIZE 1
#define APRS_PAYLOAD_SIZE 120 /* TBD */
#define APRS_PAYLOAD_SIZE 120 /* TBD ; 04.11.2023 actual size is 106 bytes */
#define APRS_CRC_TYPE RF_CHECKSUM_TYPE_CCITT_FFFF
#define APRS_CRC_SIZE 2

Expand Down Expand Up @@ -63,5 +63,6 @@ extern const rf_proto_desc_t prol_proto_desc;

extern char APRS_FromCall[10];
extern char APRS_ToCall [10];
extern char APRS_Path [10];

#endif /* PROTOCOL_APRS_H */

0 comments on commit b21e57f

Please sign in to comment.