Merge pull request #6 from LukePrior/sondehub

Only add time for select sonde, prepare temp
pull/80/head
oh3bsg 2021-05-22 09:35:22 +03:00 zatwierdzone przez GitHub
commit f58e265b75
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 81 dodań i 39 usunięć

Wyświetl plik

@ -2959,47 +2959,89 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
struct tm ts;
time_t t = s->time;
if (s->ser == "") return; // Don't send anything without serial number
if (String(s->ser) == "") return; // Don't send anything without serial number
if (((int)s->lat == 0) && ((int)s->lon == 0)) return; // Sometimes these values are zeroes. Don't send those to the sondehub
if ((int)s->alt > 50000) return; // If alt is too high don't send to SondeHub
if ((int)s->sats < 4) return; // If not enough sats don't send to SondeHub
if (((int)s->lat == 0) && ((int)s->lon == 0) && ((int)s->alt == 0)) return; // Sometimes all of these values are zeroes. Don't send those to the sondehub
t += 18; // convert back to GPS time from UTC time +18s
if (String(sondeTypeStr[s->type]) == "RS41" || String(sondeTypeStr[s->type]) == "RS92" || String(sondeTypeStr[s->type]) == "M10" || String(sondeTypeStr[s->type]) == "M20") {
t += 18; // convert back to GPS time from UTC time +18s
}
ts = *gmtime(&t);
memset(rs_msg, 0, MSG_SIZE);
memset(rs_msg, 0, MSG_SIZE);
w=rs_msg;
sprintf(w,
"[ {"
"\"software_name\": \"%s\","
"\"software_version\": \"%s\","
"\"uploader_callsign\": \"%s\","
"\"time_received\": \"%04d-%02d-%02dT%02d:%02d:%02d.000Z\","
"\"manufacturer\": \"%s\","
"\"type\": \"%s\","
"\"serial\": \"%s\","
"\"frame\": %d,"
"\"datetime\": \"%04d-%02d-%02dT%02d:%02d:%02d.000Z\","
"\"lat\": %02d.%06d,"
"\"lon\": %d.%06d,"
"\"alt\": %d.%02d,"
"\"frequency\": %.3f,"
"\"vel_h\": %.1f,"
"\"vel_v\": %.1f,"
"\"heading\": %.1f,"
"\"sats\": %d,"
"\"rssi\": %.1f,"
"\"uploader_position\": [ %s, %s, %s ],"
"\"uploader_antenna\": \"%s\""
"}]",
version_name, version_id, conf->callsign,
ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec + s->sec,
manufacturer_string[s->type], sondeTypeStr[s->type], s->ser, s->frame,
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),
(float)s->freq, (float)s->hs, (float)s->vs, (float)s->dir, (int)s->sats, -((float)s->rssi/2), conf->lat, conf->lon, conf->alt, conf->antenna
);
if (((int)s->temperature != 0) && ((int)s->relativeHumidity != 0)) {
sprintf(w,
"[ {"
"\"software_name\": \"%s\","
"\"software_version\": \"%s\","
"\"uploader_callsign\": \"%s\","
"\"time_received\": \"%04d-%02d-%02dT%02d:%02d:%02d.000Z\","
"\"manufacturer\": \"%s\","
"\"type\": \"%s\","
"\"serial\": \"%s\","
"\"frame\": %d,"
"\"datetime\": \"%04d-%02d-%02dT%02d:%02d:%02d.000Z\","
"\"lat\": %.6f,"
"\"lon\": %.6f,"
"\"alt\": %.2f,"
"\"frequency\": %.3f,"
"\"vel_h\": %.1f,"
"\"vel_v\": %.1f,"
"\"heading\": %.1f,"
"\"sats\": %d,"
"\"rssi\": %.1f,"
"\"temp\": %.2f,"
"\"humidity\": %.2f,"
"\"uploader_position\": [ %s, %s, %s ],"
"\"uploader_antenna\": \"%s\""
"}]",
version_name, version_id, conf->callsign,
ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec + s->sec,
manufacturer_string[s->type], sondeTypeStr[s->type], s->ser, s->frame,
ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec + s->sec,
(float)s->lat, (float)s->lon, (float)s->alt, (float)s->freq, (float)s->hs, (float)s->vs,
(float)s->dir, (int)s->sats, -((float)s->rssi/2), float(s->temperature), float(s->relativeHumidity), conf->lat, conf->lon, conf->alt, conf->antenna
);
}
else {
sprintf(w,
"[ {"
"\"software_name\": \"%s\","
"\"software_version\": \"%s\","
"\"uploader_callsign\": \"%s\","
"\"time_received\": \"%04d-%02d-%02dT%02d:%02d:%02d.000Z\","
"\"manufacturer\": \"%s\","
"\"type\": \"%s\","
"\"serial\": \"%s\","
"\"frame\": %d,"
"\"datetime\": \"%04d-%02d-%02dT%02d:%02d:%02d.000Z\","
"\"lat\": %.6f,"
"\"lon\": %.6f,"
"\"alt\": %.2f,"
"\"frequency\": %.3f,"
"\"vel_h\": %.1f,"
"\"vel_v\": %.1f,"
"\"heading\": %.1f,"
"\"sats\": %d,"
"\"rssi\": %.1f,"
"\"uploader_position\": [ %s, %s, %s ],"
"\"uploader_antenna\": \"%s\""
"}]",
version_name, version_id, conf->callsign,
ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec + s->sec,
manufacturer_string[s->type], sondeTypeStr[s->type], s->ser, s->frame,
ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec + s->sec,
(float)s->lat, (float)s->lon, (float)s->alt, (float)s->freq, (float)s->hs, (float)s->vs,
(float)s->dir, (int)s->sats, -((float)s->rssi/2), conf->lat, conf->lon, conf->alt, conf->antenna
);
}
if (!client->connected()) {
Serial.println("NO CONNECTION");
@ -3019,7 +3061,7 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
client->println();
client->println(w);
Serial.println(w);
//String response = client->readString();
//Serial.println(response);
String response = client->readString();
Serial.println(response);
}
// End of sondehub v2 related codes

Wyświetl plik

@ -1,4 +1,4 @@
const char *version_name = "BSG TTGO Sonde";
const char *version_id = "v0.3.1";
const char *version_id = "v0.3.2";
const int SPIFFS_MAJOR=2;
const int SPIFFS_MINOR=11;