kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
Merge branch 'dl9rdz:devel' into devel
commit
9e347a48e6
|
@ -153,8 +153,14 @@ String processor(const String& var) {
|
|||
Serial.println(var);
|
||||
if (var == "MAPCENTER") {
|
||||
double lat, lon;
|
||||
if(gpsPos.valid) { lat=gpsPos.lat; lon=gpsPos.lon; }
|
||||
else { lat = sonde.config.rxlat; lon = sonde.config.rxlon; }
|
||||
if (gpsPos.valid) {
|
||||
lat = gpsPos.lat;
|
||||
lon = gpsPos.lon;
|
||||
}
|
||||
else {
|
||||
lat = sonde.config.rxlat;
|
||||
lon = sonde.config.rxlon;
|
||||
}
|
||||
if ( !isnan(lat) && !isnan(lon) ) {
|
||||
char p[40];
|
||||
snprintf(p, 40, "%g,%g", lat, lon);
|
||||
|
@ -555,8 +561,8 @@ const char *createLiveJson() {
|
|||
/*bool b = */nmea.getAltitude(alt);
|
||||
bool valid = nmea.isValid();
|
||||
uint8_t hdop = nmea.getHDOP();
|
||||
if (valid) {
|
||||
strcat(ptr, ",");
|
||||
//if (valid) {
|
||||
// strcat(ptr, ",");
|
||||
#endif
|
||||
sprintf(ptr + strlen(ptr), ", \"gps\": {\"lat\": %g, \"lon\": %g, \"alt\": %d, \"sat\": %d, \"speed\": %g, \"dir\": %d, \"hdop\": %d }", gpsPos.lat, gpsPos.lon, gpsPos.alt, gpsPos.sat, gpsPos.speed, gpsPos.course, gpsPos.hdop);
|
||||
//}
|
||||
|
@ -3527,15 +3533,31 @@ void sondehub_reply_handler(WiFiClient *client) {
|
|||
else {
|
||||
// any reply here belongs to normal telemetry upload, lets just print it.
|
||||
// and wait for a valid HTTP response
|
||||
int cnt = 0;
|
||||
while (client->available() > 0) {
|
||||
// data is available from remote server, process it...
|
||||
int cnt = client->readBytesUntil('\n', rs_msg, MSG_SIZE - 1);
|
||||
// readBytesUntil may wait for up to 1 second if enough data is not available...
|
||||
// int cnt = client->readBytesUntil('\n', rs_msg, MSG_SIZE - 1);
|
||||
int c = client->read();
|
||||
if (c < 0) break; // should never happen in available() returned >0 right before....
|
||||
rs_msg[cnt++] = c;
|
||||
if (c == '\n') {
|
||||
rs_msg[cnt] = 0;
|
||||
Serial.println(rs_msg);
|
||||
// If something that looks like a valid HTTP response is received, we are ready to send the next data item
|
||||
if (shState == SH_CONN_WAITACK && cnt > 11 && strncmp(rs_msg, "HTTP/1", 6) == 0) {
|
||||
shState = SH_CONN_IDLE;
|
||||
}
|
||||
cnt = 0;
|
||||
}
|
||||
if (cnt >= MSG_SIZE - 1) {
|
||||
cnt = 0;
|
||||
Serial.println("(overlong line from network, ignoring)");
|
||||
}
|
||||
}
|
||||
if (cnt > 0) {
|
||||
rs_msg[cnt + 1] = 0;
|
||||
Serial.println(rs_msg);
|
||||
}
|
||||
}
|
||||
// send import requests if needed
|
||||
|
@ -3717,14 +3739,14 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
|
|||
}
|
||||
|
||||
// Only send temp if provided
|
||||
if ((int)s->d.temperature != 0) {
|
||||
sprintf(w, "\"temp\": %.1f,", float(s->d.temperature));
|
||||
if (!isnan(s->d.temperature)) {
|
||||
sprintf(w, "\"temp\": %.1f,", s->d.temperature);
|
||||
w += strlen(w);
|
||||
}
|
||||
|
||||
// Only send humidity if provided
|
||||
if ((int)s->d.relativeHumidity != 0) {
|
||||
sprintf(w, "\"humidity\": %.1f,", float(s->d.relativeHumidity));
|
||||
if (!isnan(s->d.relativeHumidity)) {
|
||||
sprintf(w, "\"humidity\": %.1f,", s->d.relativeHumidity);
|
||||
w += strlen(w);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ int Chasemapper::send(WiFiUDP &udp, SondeInfo *si) {
|
|||
"\"heading\": %d,"
|
||||
"\"time\": \"%02d:%02d:%02d\","
|
||||
"\"model\": \"%s\","
|
||||
"\"freq\": \"%.3f MHz\","
|
||||
"\"temp\": %g }",
|
||||
"\"freq\": \"%.3f MHz\"",
|
||||
si->d.ser,
|
||||
si->d.lat,
|
||||
si->d.lon,
|
||||
|
@ -30,8 +29,11 @@ int Chasemapper::send(WiFiUDP &udp, SondeInfo *si) {
|
|||
(int)si->d.dir,
|
||||
tim.tm_hour, tim.tm_min, tim.tm_sec,
|
||||
sondeTypeStrSH[realtype],
|
||||
si->freq,
|
||||
si->d.temperature);
|
||||
si->freq);
|
||||
if( !isnan(si->d.temperature) ) {
|
||||
sprintf(buf + strlen(buf), ", \"temp\": %g", si->d.temperature);
|
||||
}
|
||||
strcat(buf, "}");
|
||||
Serial.printf("Sending chasemapper json: %s\n", buf);
|
||||
udp.beginPacket(sonde.config.cm.host, sonde.config.cm.port);
|
||||
udp.write((const uint8_t *)buf, strlen(buf));
|
||||
|
|
|
@ -79,10 +79,12 @@ void Sonde::defaultConfig() {
|
|||
Serial.printf("Board fingerprint is %d\n", fingerprint);
|
||||
|
||||
sondeList = (SondeInfo *)malloc((MAXSONDE+1)*sizeof(SondeInfo));
|
||||
// addSonde should initialize everything anyway, so this should not strictly be necessary, but does no harm either
|
||||
memset(sondeList, 0, (MAXSONDE+1)*sizeof(SondeInfo));
|
||||
for(int i=0; i<(MAXSONDE+1); i++) {
|
||||
sondeList[i].freq=400;
|
||||
sondeList[i].type=STYPE_RS41;
|
||||
clearAllData(&sondeList[i]);
|
||||
}
|
||||
config.touch_thresh = 70;
|
||||
config.led_pout = -1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const char *version_name = "rdzTTGOsonde";
|
||||
const char *version_id = "devel20210921";
|
||||
const char *version_id = "devel20210922";
|
||||
const int SPIFFS_MAJOR=2;
|
||||
const int SPIFFS_MINOR=16;
|
||||
|
|
Ładowanie…
Reference in New Issue