json reorg, part 3
This commit is contained in:
parent
cad5bd16cd
commit
551744aa29
|
|
@ -2422,6 +2422,20 @@ void loopDecoder() {
|
||||||
float dir = isnan(s->d.dir) ? 0 : s->d.dir;
|
float dir = isnan(s->d.dir) ? 0 : s->d.dir;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
raw[0] = '{';
|
||||||
|
// Use same JSON format as for MQTT and HTML map........
|
||||||
|
sonde2json(raw+1, 1023, s);
|
||||||
|
sprintf(raw+strlen(raw),
|
||||||
|
",\"active\":%d"
|
||||||
|
",\"validId\":%d"
|
||||||
|
",\"validPos\":%d"
|
||||||
|
" %s}\n",
|
||||||
|
(int)s->active,
|
||||||
|
s->d.validID,
|
||||||
|
s->d.validPos,
|
||||||
|
gps);
|
||||||
|
int len = strlen(raw);
|
||||||
|
#if 0
|
||||||
int len = snprintf(raw, 1024, "{"
|
int len = snprintf(raw, 1024, "{"
|
||||||
"\"res\": %d,"
|
"\"res\": %d,"
|
||||||
"\"type\": \"%s\","
|
"\"type\": \"%s\","
|
||||||
|
|
@ -2477,6 +2491,8 @@ void loopDecoder() {
|
||||||
s->d.crefKT,
|
s->d.crefKT,
|
||||||
gps
|
gps
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
//Serial.println("Writing rdzclient...");
|
//Serial.println("Writing rdzclient...");
|
||||||
if (len > 1024) len = 1024;
|
if (len > 1024) len = 1024;
|
||||||
int wlen = rdzclient.write(raw, len);
|
int wlen = rdzclient.write(raw, len);
|
||||||
|
|
|
||||||
|
|
@ -73,14 +73,14 @@ int sonde2json(char *buf, int maxlen, SondeInfo *si)
|
||||||
s->countKT,
|
s->countKT,
|
||||||
s->crefKT,
|
s->crefKT,
|
||||||
si->launchsite,
|
si->launchsite,
|
||||||
si->rxStat[0]
|
(int)si->rxStat[0]
|
||||||
);
|
);
|
||||||
if(n>=maxlen) return -1;
|
if(n>=maxlen) return -1;
|
||||||
buf += n; maxlen -= n;
|
buf += n; maxlen -= n;
|
||||||
|
|
||||||
// add only if available
|
// add only if available
|
||||||
if(s->batteryVoltage > 0) {
|
if(s->batteryVoltage > 0) {
|
||||||
n = snprintf(buf, maxlen, "\"bat\": %.1f,", s->batteryVoltage);
|
n = snprintf(buf, maxlen, ",\"bat\": %.1f", s->batteryVoltage);
|
||||||
if(n>=maxlen) return -1;
|
if(n>=maxlen) return -1;
|
||||||
buf += n; maxlen -= n;
|
buf += n; maxlen -= n;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue