From 547b08e3d7825605dd2474c91df24f6a425f240a Mon Sep 17 00:00:00 2001 From: Jarmo Date: Mon, 31 May 2021 19:16:41 +0300 Subject: [PATCH] Added mobile location --- RX_FSK/RX_FSK.ino | 27 +++++++++++++++++++++------ RX_FSK/data/config.txt | 1 + RX_FSK/version.h | 2 +- libraries/SondeLib/Sonde.cpp | 2 ++ libraries/SondeLib/Sonde.h | 1 + 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 71bfd9b..f19c328 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -595,6 +595,7 @@ struct st_configitems config_list[] = { /* Sondehub v2 settings */ {"", "Sondehub v2 settings", -5, NULL}, {"sondehub.active", "Sondehub reporting active", 0, &sonde.config.sondehub.active}, + {"sondehub.chase", "Sondehub chase location active", 0, &sonde.config.sondehub.chase}, {"sondehub.host", "Sondehub host", 63, &sonde.config.sondehub.host}, {"sondehub.callsign", "Callsign", 63, &sonde.config.sondehub.callsign}, {"sondehub.lat", "Latitude", 19, &sonde.config.sondehub.lat}, @@ -3052,12 +3053,26 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co ); w += strlen(w); } - sprintf(w, - "\"uploader_position\": [ %s, %s, %s ]," - "\"uploader_antenna\": \"%s\"" - "}]", - conf->lat, conf->lon, conf->alt, conf->antenna - ); + + if (conf->chase == 0) { + sprintf(w, + "\"uploader_position\": [ %s, %s, %s ]," + "\"uploader_antenna\": \"%s\"" + "}]", + conf->lat, conf->lon, conf->alt, conf->antenna + ); + } + else if (gpsPos.valid) { + sprintf(w, + "\"uploader_position\": [ %.6f, %.6f, %d ]," + "\"mobile\": \"true\"" + "}]", + gpsPos.lat, gpsPos.lon, gpsPos.alt + ); + } + else { + sprintf(w, "}]"); + } client->println("PUT /sondes/telemetry HTTP/1.1"); client->print("Host: "); diff --git a/RX_FSK/data/config.txt b/RX_FSK/data/config.txt index a6169d9..c3c518d 100644 --- a/RX_FSK/data/config.txt +++ b/RX_FSK/data/config.txt @@ -123,6 +123,7 @@ mqtt.prefix=rdz_sonde_server/ #-------------------------------# # Sondehub v2 DB settings sondehub.active=0 +sondehub.chase=0 sondehub.host=api.v2.sondehub.org sondehub.callsign=CHANGEME_RDZTTGO sondehub.lat=null diff --git a/RX_FSK/version.h b/RX_FSK/version.h index f7d101c..d8f5b83 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20210524"; +const char *version_id = "devel20210524-1"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=11; diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp index f181096..96da15f 100644 --- a/libraries/SondeLib/Sonde.cpp +++ b/libraries/SondeLib/Sonde.cpp @@ -376,6 +376,8 @@ void Sonde::setConfig(const char *cfg) { strncpy(config.mqtt.prefix, val, 63); } else if(strcmp(cfg, "sondehub.active")==0) { config.sondehub.active = atoi(val); + } else if(strcmp(cfg,"sondehub.chase")==0) { + config.sondehub.chase = atoi(val); } else if(strcmp(cfg, "sondehub.host")==0) { strncpy(config.sondehub.host, val, 63); } else if(strcmp(cfg, "sondehub.callsign")==0) { diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h index e20e4df..1f4970e 100644 --- a/libraries/SondeLib/Sonde.h +++ b/libraries/SondeLib/Sonde.h @@ -183,6 +183,7 @@ struct st_mqtt { struct st_sondehub { int active; + int chase; char host[64]; char callsign[64]; char lat[20];