From 8522c659620e82f3831d3ab1075084f8a16f5067 Mon Sep 17 00:00:00 2001 From: dj1an Date: Thu, 24 Jun 2021 14:18:35 +0200 Subject: [PATCH 1/4] added precision option to config added precision option to config --- data/tracker.json | 1 + 1 file changed, 1 insertion(+) diff --git a/data/tracker.json b/data/tracker.json index 43bb129..8114e3d 100644 --- a/data/tracker.json +++ b/data/tracker.json @@ -1,6 +1,7 @@ { "callsign":"NOCALL-7", "debug": false, + "enhance_precision": true, "beacon": { "message":"LoRa Tracker", From c3403ea7c09f8d3bb2e5f6cd573d1dcc3bfb4b09 Mon Sep 17 00:00:00 2001 From: dj1an Date: Thu, 24 Jun 2021 14:30:19 +0200 Subject: [PATCH 2/4] added precision option to config --- src/configuration.cpp | 3 ++- src/configuration.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/configuration.cpp b/src/configuration.cpp index afac9a4..f8c603f 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -43,7 +43,7 @@ Configuration ConfigurationManagement::readConfiguration() if(data.containsKey("callsign")) conf.callsign = data["callsign"].as(); conf.debug = data["debug"] | false; - + conf.enhance_precision = data["enhance_precision"] | false; if(data.containsKey("beacon") && data["beacon"].containsKey("message")) conf.beacon.message = data["beacon"]["message"].as(); conf.beacon.timeout = data["beacon"]["timeout"] | 1; @@ -84,6 +84,7 @@ void ConfigurationManagement::writeConfiguration(Configuration conf) data["callsign"] = conf.callsign; data["debug"] = conf.debug; + data["enhance_precision"] = conf.enhance_precision; data["beacon"]["message"] = conf.beacon.message; data["beacon"]["timeout"] = conf.beacon.timeout; data["beacon"]["symbol"] = conf.beacon.symbol; diff --git a/src/configuration.h b/src/configuration.h index ab2e93d..0e8e225 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -51,6 +51,7 @@ public: String callsign; bool debug; + bool enhance_precision; Beacon beacon; Smart_Beacon smart_beacon; LoRa lora; From 4a4f506c5a62689b5f9ad4de0844f78bb57bedc2 Mon Sep 17 00:00:00 2001 From: dj1an Date: Thu, 24 Jun 2021 14:33:52 +0200 Subject: [PATCH 3/4] added dao precision with Base91 encoding to Beacon Message --- src/LoRa_APRS_Tracker.cpp | 81 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index 6c3a3e9..2b10e60 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -24,6 +24,9 @@ void setup_gps(); String create_lat_aprs(RawDegrees lat); String create_long_aprs(RawDegrees lng); +String create_lat_aprs_dao(RawDegrees lat); +String create_long_aprs_dao(RawDegrees lng); +String create_dao_aprs(RawDegrees lat, RawDegrees lng); String createDateString(time_t t); String createTimeString(time_t t); String getSmartBeaconState(); @@ -182,10 +185,21 @@ void loop() nextBeaconTimeStamp = now() + (Config.smart_beacon.active ? Config.smart_beacon.slow_rate : (Config.beacon.timeout * SECS_PER_MIN)); APRSMessage msg; + String lat; + String lng; + String dao; + msg.setSource(Config.callsign); msg.setDestination("APLT00-1"); - String lat = create_lat_aprs(gps.location.rawLat()); - String lng = create_long_aprs(gps.location.rawLng()); + + if (!Config.enhance_precision){ + lat = create_lat_aprs(gps.location.rawLat()); + lng = create_long_aprs(gps.location.rawLng()); + } else { + lat = create_lat_aprs_dao(gps.location.rawLat()); + lng = create_long_aprs_dao(gps.location.rawLng()); + dao = create_dao_aprs(gps.location.rawLat(), gps.location.rawLng()); + } String alt = ""; int alt_int = max(-99999, min(999999, (int)gps.altitude.feet())); @@ -240,6 +254,11 @@ void loop() { aprsmsg += " - _Bat.: " + batteryVoltage + "V - Cur.: " + batteryChargeCurrent + "mA"; } + + if (Config.enhance_precision){ + aprsmsg += " " + dao; + } + msg.getAPRSBody()->setData(aprsmsg); String data = msg.encode(); logPrintlnD(data); @@ -361,6 +380,21 @@ String create_lat_aprs(RawDegrees lat) return lat_str; } +String create_lat_aprs_dao(RawDegrees lat) +{ + //round to 4 digits and cut the last 2 + char str[20]; + char n_s = 'N'; + if(lat.negative) + { + n_s = 'S'; + } + sprintf(str, "%02d%07.4f%c", lat.deg, lat.billionths / 1000000000.0 * 60.0, n_s); + String lat_str(str); + lat_str.remove(7,2); + return lat_str; +} + String create_long_aprs(RawDegrees lng) { char str[20]; @@ -374,6 +408,49 @@ String create_long_aprs(RawDegrees lng) return lng_str; } +String create_long_aprs_dao(RawDegrees lng) +{ + //round to 4 digits and cut the last 2 + char str[20]; + char e_w = 'E'; + if(lng.negative) + { + e_w = 'W'; + } + sprintf(str, "%03d%07.4f%c", lng.deg, lng.billionths / 1000000000.0 * 60.0, e_w); + String lng_str(str); + lng_str.remove(8,2); + return lng_str; +} + +String create_dao_aprs(RawDegrees lat, RawDegrees lng) +{ + // !DAO! extension, use Base91 format for best precision + // /1.1 : scale from 0-99 to 0-90 for base91, int(... + 0.5): round to nearest integer + // https://metacpan.org/dist/Ham-APRS-FAP/source/FAP.pm + // http://www.aprs.org/aprs12/datum.txt + // + // TODO: optimize ugly float to char to string to int conversion? + + char str[10]; + char lat_str[10]; + char lng_str[10]; + + sprintf(lat_str, "%07.4f", lat.billionths / 1000000000.0 * 60.0); + sprintf(lng_str, "%07.4f", lng.billionths / 1000000000.0 * 60.0); + + String lat_dao(lat_str); + String lng_dao(lng_str); + int lat_int = lat_dao.substring(5,7).toInt(); + int lng_int = lng_dao.substring(5,7).toInt(); + char lat_char = char(int((lat_int/1.1 + 0.5) + 33)); + char lng_char = char(int((lng_int/1.1 + 0.5) + 33)); + + sprintf(str, "!w%c%c!", lat_char, lng_char); + String dao_str(str); + return dao_str; +} + String createDateString(time_t t) { return String(padding(day(t), 2) + "." + padding(month(t), 2) + "." + padding(year(t), 4)); From 2a61bbecc27dfe35a75579e64a0a92221f20f9b2 Mon Sep 17 00:00:00 2001 From: dj1an Date: Thu, 24 Jun 2021 14:49:28 +0200 Subject: [PATCH 4/4] added precision option to config mgmt --- src/configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/configuration.h b/src/configuration.h index 0e8e225..1ad2df3 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -47,7 +47,7 @@ public: int codingRate4; }; - Configuration() : callsign("NOCALL-10"), debug(false) {}; + Configuration() : callsign("NOCALL-10"), debug(false), enhance_precision(true) {}; String callsign; bool debug;