diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino
index f9669ab..4cf7688 100644
--- a/RX_FSK/RX_FSK.ino
+++ b/RX_FSK/RX_FSK.ino
@@ -460,6 +460,7 @@ void addSondeStatus(char *ptr, int i)
sprintf(ptr + strlen(ptr), "
| GEO-App - ", s->lat, s->lon);
sprintf(ptr + strlen(ptr), "wetterson.de - ", s->id);
sprintf(ptr + strlen(ptr), "radiosondy.info - ", s->id);
+ sprintf(ptr + strlen(ptr), "SondeHub Tracker - ", s->id);
sprintf(ptr + strlen(ptr), "OSM - ", s->lat, s->lon);
sprintf(ptr + strlen(ptr), "Google |
", s->lat, s->lon);
@@ -593,7 +594,7 @@ struct st_configitems config_list[] = {
{"sondehub.lon", "Longitude", 19, &sonde.config.sondehub.lon},
{"sondehub.alt", "Altitude", 19, &sonde.config.sondehub.alt},
{"sondehub.antenna", "Antenna", 63, &sonde.config.sondehub.antenna},
-
+ {"sondehub.email", "Sondehub email", 63, &sonde.config.sondehub.email},
};
const static int N_CONFIG = (sizeof(config_list) / sizeof(struct st_configitems));
@@ -2129,7 +2130,9 @@ void loopDecoder() {
tncclient.write(raw, rawlen);
}
}
- sondehub_send_data(&shclient, s, &sonde.config.sondehub);
+ if (sonde.config.sondehub.active) {
+ sondehub_send_data(&shclient, s, &sonde.config.sondehub);
+ }
}
// send to MQTT if enabled
@@ -2314,6 +2317,9 @@ String translateEncryptionType(wifi_auth_mode_t encryptionType) {
}
}
+enum t_wifi_state { WIFI_DISABLED, WIFI_SCAN, WIFI_CONNECT, WIFI_CONNECTED, WIFI_APMODE };
+
+static t_wifi_state wifi_state = WIFI_DISABLED;
void enableNetwork(bool enable) {
if (enable) {
@@ -2333,8 +2339,10 @@ void enableNetwork(bool enable) {
mqttclient.init(sonde.config.mqtt.host, sonde.config.mqtt.port, sonde.config.mqtt.id, sonde.config.mqtt.username, sonde.config.mqtt.password, sonde.config.mqtt.prefix);
}
- //shclient.setInsecure(); // Skip verification
- sondehub_station_update(&shclient, &sonde.config.sondehub);
+ if (sonde.config.sondehub.active && wifi_state != WIFI_APMODE) {
+ sondehub_station_update(&shclient, &sonde.config.sondehub);
+ }
+
connected = true;
} else {
MDNS.end();
@@ -2342,11 +2350,6 @@ void enableNetwork(bool enable) {
}
}
-
-enum t_wifi_state { WIFI_DISABLED, WIFI_SCAN, WIFI_CONNECT, WIFI_CONNECTED, WIFI_APMODE };
-
-static t_wifi_state wifi_state = WIFI_DISABLED;
-
// Events used only for debug output right now
void WiFiEvent(WiFiEvent_t event)
{
@@ -2907,7 +2910,7 @@ void loop() {
* Update station data to the sondehub v2 DB
*/
void sondehub_station_update(WiFiClient *client, struct st_sondehub *conf) {
- char data[200];
+ char data[300];
Serial.println("sondehub_station_update()");
@@ -2927,9 +2930,10 @@ void sondehub_station_update(WiFiClient *client, struct st_sondehub *conf) {
"\"software_name\": \"%s\","
"\"software_version\": \"%s\","
"\"uploader_callsign\": \"%s\","
+ "\"uploader_contact_email\": \"%s\","
"\"uploader_position\": [%s,%s,%s],"
"\"uploader_antenna\": \"%s\""
- "}", version_name, version_id, conf->callsign, conf->lat, conf->lon, conf->alt, conf->antenna);
+ "}", version_name, version_id, conf->callsign, conf->email, conf->lat, conf->lon, conf->alt, conf->antenna);
client->println(strlen(data));
client->println();
client->println(data);
@@ -2952,6 +2956,8 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
time_t t = s->time;
ts = *gmtime(&t);
+ //TODO convert back to GPS time from UTC time +18s
+ Serial.println(sondeTypeStr[s->type]);
memset(rs_msg, 0, 450);
w=rs_msg;
@@ -2969,19 +2975,12 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
"\"lat\": %02d.%06d,"
"\"lon\": %d.%06d,"
"\"alt\": %d.%02d,"
-// "\"subtype\": \"RS41-SG\","
-// "\"frequency\": 0,"
-// "\"temp\": 0,"
-// "\"humidity\": 0,"
-// "\"vel_h\": 0,"
-// "\"vel_v\": 0,"
-// "\"pressure\": 0,"
-// "\"heading\": 0,"
-// "\"batt\": 0,"
-// "\"sats\": 0,"
-// "\"xdata\": \"string\","
-// "\"snr\": 0,"
-// "\"rssi\": %d"
+ "\"frequency\": %.2f,"
+ "\"vel_h\": %.1f,"
+ "\"vel_v\": %.1f,"
+ "\"heading\": %.1f,"
+ "\"sats\": %d,"
+ "\"rssi\": %.1f,"
"\"uploader_position\": [ %s, %s, %s ],"
"\"uploader_antenna\": \"%s\""
"}]",
@@ -2991,7 +2990,7 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec + s->sec,
(int)s->lat, (int)((s->lat - (int)s->lat)*1000000),
(int)s->lon, (int)((s->lon - (int)s->lon)*1000000), (int)s->alt, (int)((s->alt - (int)s->alt)*100),
- conf->lat, conf->lon, conf->alt, conf->antenna
+ (float)s->freq, (float)s->hs, (float)s->vs, (float)s->dir, (int)s->sats, (float)s->rssi, conf->lat, conf->lon, conf->alt, conf->antenna
);
if (!client->connected()) {
@@ -3015,4 +3014,4 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
//Serial.println(response);
//client->stop();
}
-// End of sondehub v2 related codes
\ No newline at end of file
+// End of sondehub v2 related codes
diff --git a/RX_FSK/data/config.txt b/RX_FSK/data/config.txt
index 3147aa1..c50d637 100644
--- a/RX_FSK/data/config.txt
+++ b/RX_FSK/data/config.txt
@@ -124,11 +124,12 @@ mqtt.prefix=rdz_sonde_server/
# Sondehub v2 DB settings
sondehub.active=1
sondehub.host=api.v2.sondehub.org
-sondehub.callsign=OH3BSG
-sondehub.lat=61.570242
-sondehub.lon=23.518801
-sondehub.alt=160.0
-sondehub.antenna=Discone + LNA
+sondehub.callsign=CHANGEME_BSG_TTGO
+sondehub.lat=null
+sondehub.lon=null
+sondehub.alt=null
+sondehub.antenna=
+sondehub.email=
#-------------------------------#
# EOF
#-------------------------------#
diff --git a/libraries/SondeLib/MP3H.cpp b/libraries/SondeLib/MP3H.cpp
index a516d50..29bdad7 100644
--- a/libraries/SondeLib/MP3H.cpp
+++ b/libraries/SondeLib/MP3H.cpp
@@ -261,7 +261,7 @@ void calcgps(uint8_t *buf) {
if(dir<0.0) dir+=360.0;
si->dir = dir;
si->vs = clb;
- si->hs = sqrt((float)(vn*vn + ve*ve));
+ si->hs = sqrt(vn*vn + ve*ve);
Serial.printf("Pos: %f %f alt %f dir %f vs %f hs %f\n", si->lat, si->lon, si->alt, si->dir, si->vs, si->hs);
si->validPos = 0x3f; // maybe do some checks first...
diff --git a/libraries/SondeLib/RS41.cpp b/libraries/SondeLib/RS41.cpp
index 68f1c94..4f5894c 100644
--- a/libraries/SondeLib/RS41.cpp
+++ b/libraries/SondeLib/RS41.cpp
@@ -173,15 +173,14 @@ double atang2(double x, double y)
{
double w;
if (fabs(x)>fabs(y)) {
- w = (double)atan((float)(X2C_DIVL(y,x)));
+ w = (double)atan(X2C_DIVL(y,x));
if (x<0.0) {
if (y>0.0) w = 3.1415926535898+w;
else w = w-3.1415926535898;
}
}
else if (y!=0.0) {
- w = (double)(1.5707963267949f-atan((float)(X2C_DIVL(x,
- y))));
+ w = (double)(1.5707963267949f-atan(X2C_DIVL(x, y)));
if (y<0.0) w = w-3.1415926535898;
}
else w = 0.0;
@@ -422,20 +421,18 @@ void wgs84r(double x, double y, double z,
double h;
h = x*x+y*y;
if (h>0.0) {
- rh = (double)sqrt((float)h);
+ rh = sqrt(h);
xh = x+rh;
*long0 = atang2(xh, y)*2.0;
if (*long0>3.1415926535898) *long0 = *long0-6.2831853071796;
- t = (double)atan((float)(X2C_DIVL(z*1.003364089821,
- rh)));
- st = (double)sin((float)t);
- ct = (double)cos((float)t);
- *lat = (double)atan((float)
- (X2C_DIVL(z+4.2841311513312E+4*st*st*st,
+ t = atan(X2C_DIVL(z*1.003364089821, rh));
+ st = sin(t);
+ ct = cos(t);
+ *lat = atan((X2C_DIVL(z+4.2841311513312E+4*st*st*st,
rh-4.269767270718E+4*ct*ct*ct)));
- sl = (double)sin((float)*lat);
- *heig = X2C_DIVL(rh,(double)cos((float)*lat))-(double)(X2C_DIVR(6.378137E+6f,
- sqrt((float)(1.0-6.6943799901413E-3*sl*sl))));
+ sl = sin(*lat);
+ *heig = X2C_DIVL(rh,cos(*lat))-(X2C_DIVR(6.378137E+6f,
+ sqrt((1.0-6.6943799901413E-3*sl*sl))));
}
else {
*lat = 0.0;
@@ -481,21 +478,14 @@ static void posrs41(const byte b[], uint32_t b_len, uint32_t p)
vx = (double)getint16(b, b_len, p+12UL)*0.01;
vy = (double)getint16(b, b_len, p+14UL)*0.01;
vz = (double)getint16(b, b_len, p+16UL)*0.01;
- vn = (-(vx*(double)sin((float)lat)*(double)
- cos((float)long0))-vy*(double)
- sin((float)lat)*(double)sin((float)
- long0))+vz*(double)cos((float)lat);
- ve = -(vx*(double)sin((float)long0))+vy*(double)
- cos((float)long0);
- vu = vx*(double)cos((float)lat)*(double)
- cos((float)long0)+vy*(double)
- cos((float)lat)*(double)sin((float)
- long0)+vz*(double)sin((float)lat);
+ vn = (-(vx*sin(lat)*cos(long0))-vy*sin(lat)*sin(long0))+vz*cos(lat);
+ ve = -(vx*sin(long0))+vy*cos(long0);
+ vu = vx*cos(lat)*cos(long0)+vy*cos(lat)*sin(long0)+vz*sin(lat);
dir = X2C_DIVL(atang2(vn, ve),1.7453292519943E-2);
if (dir<0.0) dir = 360.0+dir;
sonde.si()->dir = dir;
Serial.print(" ");
- sonde.si()->hs = sqrt((float)(vn*vn+ve*ve));
+ sonde.si()->hs = sqrt(vn*vn+ve*ve);
Serial.print(sonde.si()->hs*3.6);
Serial.print("km/h ");
Serial.print(dir);
diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp
index 05bcde7..aba6785 100644
--- a/libraries/SondeLib/Sonde.cpp
+++ b/libraries/SondeLib/Sonde.cpp
@@ -388,6 +388,8 @@ void Sonde::setConfig(const char *cfg) {
strncpy(config.sondehub.alt, val, 19);
} else if(strcmp(cfg, "sondehub.antenna")==0) {
strncpy(config.sondehub.antenna, val, 63);
+ } else if(strcmp(cfg, "sondehub.email")==0) {
+ strncpy(config.sondehub.email, val, 63);
} else {
Serial.printf("Invalid config option '%s'=%s \n", cfg, val);
}
diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h
index 93bd0b2..e20e4df 100644
--- a/libraries/SondeLib/Sonde.h
+++ b/libraries/SondeLib/Sonde.h
@@ -189,6 +189,7 @@ struct st_sondehub {
char lon[20];
char alt[20];
char antenna[64];
+ char email[64];
};
typedef struct st_rdzconfig {