(fixed previous commit)
This commit is contained in:
parent
473d35b312
commit
77181d9dad
|
|
@ -2232,6 +2232,8 @@ void loopDecoder() {
|
|||
mqttclient.publishPacket(s);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
sondehub_finish_data(&shclient, s, &sonde.config.sondehub);
|
||||
}
|
||||
// always send data, even if not valid....
|
||||
if (rdzclient.connected()) {
|
||||
|
|
@ -2739,6 +2741,7 @@ void loopWifiScan() {
|
|||
while (WiFi.status() != WL_CONNECTED && cnt < MAXWIFIDELAY) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
#if 0
|
||||
if (cnt == 5) {
|
||||
// my FritzBox needs this for reconnecting
|
||||
WiFi.disconnect(true);
|
||||
|
|
@ -2748,6 +2751,7 @@ void loopWifiScan() {
|
|||
Serial.print(" with password "); Serial.println(fetchWifiPw(index));
|
||||
delay(500);
|
||||
}
|
||||
#endif
|
||||
disp.rdis->drawString(15 * dispxs, lastl + dispys, _scan[cnt & 1]);
|
||||
cnt++;
|
||||
}
|
||||
|
|
@ -3065,7 +3069,7 @@ void sondehub_station_update(WiFiClient *client, struct st_sondehub *conf) {
|
|||
sprintf(w,
|
||||
"\"uploader_position\": [%.6f,%.6f,%d],"
|
||||
"\"uploader_antenna\": \"%s\","
|
||||
"\"mobile\": true"
|
||||
"\"mobile\": \"true\""
|
||||
"}",
|
||||
gpsPos.lat, gpsPos.lon, gpsPos.alt, conf->antenna);
|
||||
}
|
||||
|
|
@ -3116,6 +3120,7 @@ const char *dfmSubtypeStrSH[16] = { NULL, NULL, NULL, NULL, NULL, NULL,
|
|||
#define SONDEHUB_TIME_THRESHOLD (3)
|
||||
void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *conf) {
|
||||
Serial.println("sondehub_send_data()");
|
||||
Serial.printf("shState = %d\n", shState);
|
||||
|
||||
// max age of data in JSON request (in seconds)
|
||||
#define SONDEHUB_MAXAGE 15
|
||||
|
|
@ -3148,13 +3153,6 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
|
|||
return;
|
||||
}
|
||||
|
||||
// If there is an "old" pending collection of JSON data sets, send it even if no now data is received
|
||||
if(shSate == SH_CONN_APPENDING && (now - shStart > SONDEHUB_MAXAGE+3) ) { // after MAXAGE seconds
|
||||
sondehub_send_last(client, s, conf);
|
||||
shState = SH_CONN_WAITACK;
|
||||
shStart = 0;
|
||||
}
|
||||
|
||||
// Check if current sonde data is valid. If not, don't do anything....
|
||||
if (*s->ser == 0) 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
|
||||
|
|
@ -3207,11 +3205,11 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
|
|||
"\"datetime\": \"%04d-%02d-%02dT%02d:%02d:%02d.000Z\","
|
||||
"\"lat\": %.6f,"
|
||||
"\"lon\": %.6f,"
|
||||
"\"alt\": %.3f,"
|
||||
"\"alt\": %.2f,"
|
||||
"\"frequency\": %.3f,"
|
||||
"\"vel_h\": %.3f,"
|
||||
"\"vel_v\": %.3f,"
|
||||
"\"heading\": %.3f,"
|
||||
"\"vel_h\": %.1f,"
|
||||
"\"vel_v\": %.1f,"
|
||||
"\"heading\": %.1f,"
|
||||
"\"sats\": %d,"
|
||||
"\"rssi\": %.1f,",
|
||||
version_name, version_id, conf->callsign,
|
||||
|
|
@ -3252,8 +3250,8 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
|
|||
|
||||
if (((int)s->temperature != 0) && ((int)s->relativeHumidity != 0)) {
|
||||
sprintf(w,
|
||||
"\"temp\": %.1f,"
|
||||
"\"humidity\": %.1f,",
|
||||
"\"temp\": %.2f,"
|
||||
"\"humidity\": %.2f,",
|
||||
float(s->temperature), float(s->relativeHumidity)
|
||||
);
|
||||
w += strlen(w);
|
||||
|
|
@ -3291,7 +3289,7 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
|
|||
conf->antenna
|
||||
);
|
||||
}
|
||||
if(shState == SH_CONN_IDLE) {
|
||||
if (shState != SH_CONN_APPENDING) {
|
||||
sondehub_send_header(client, s, conf);
|
||||
sondehub_send_next(client, s, conf, rs_msg, strlen(rs_msg), 1);
|
||||
shState = SH_CONN_APPENDING;
|
||||
|
|
@ -3310,6 +3308,19 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
|
|||
//Serial.println(response);
|
||||
}
|
||||
|
||||
void sondehub_finish_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *conf) {
|
||||
// If there is an "old" pending collection of JSON data sets, send it even if no now data is received
|
||||
if (shState == SH_CONN_APPENDING) {
|
||||
time_t now;
|
||||
time(&now);
|
||||
if (now - shStart > SONDEHUB_MAXAGE + 3) { // after MAXAGE seconds
|
||||
sondehub_send_last(client, s, conf);
|
||||
shState = SH_CONN_WAITACK;
|
||||
shStart = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sondehub_send_header(WiFiClient *client, SondeInfo *s, struct st_sondehub *conf) {
|
||||
Serial.print("PUT /sondes/telemetry HTTP/1.1\r\n"
|
||||
"Host: ");
|
||||
|
|
|
|||
Loading…
Reference in New Issue