kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
+time check for SondeHub
rodzic
faa9fc1630
commit
e368dd50dc
|
@ -3015,6 +3015,8 @@ const char *dfmSubtypeStrSH[16] = { NULL, NULL, NULL, NULL, NULL, NULL,
|
|||
NULL, NULL
|
||||
};
|
||||
|
||||
// in hours.... max allowed diff UTC <-> sonde time
|
||||
#define SONDEHUB_TIME_THRESHOLD (3)
|
||||
void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *conf) {
|
||||
Serial.println("sondehub_send_data()");
|
||||
|
||||
|
@ -3060,16 +3062,23 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
|
|||
}
|
||||
|
||||
struct tm timeinfo;
|
||||
if(!getLocalTime(&timeinfo, 0)){
|
||||
time_t now;
|
||||
time(&now);
|
||||
gmtime_r(&now, &timeinfo);
|
||||
if(timeinfo.tm_year <= (2016-1900)) {
|
||||
Serial.println("Failed to obtain time");
|
||||
return;
|
||||
}
|
||||
if( abs(now - s->time) > (3600*SONDEHUB_TIME_THRESHOLD) ) {
|
||||
Serial.println("Sonde time too far from current UTC time");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( s->type == STYPE_RS41 || s->type == STYPE_RS92 || s->type == STYPE_M10 || s->type == STYPE_M20 ) {
|
||||
t += 18; // convert back to GPS time from UTC time +18s
|
||||
}
|
||||
|
||||
ts = *gmtime(&t);
|
||||
gmtime_r(&t, &ts);
|
||||
|
||||
memset(rs_msg, 0, MSG_SIZE);
|
||||
w = rs_msg;
|
||||
|
|
Ładowanie…
Reference in New Issue