kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
Merge pull request #4 from dl9rdz/devel
always send json data after each frame for rdzwx-gopull/71/head
commit
8d66dde162
|
@ -1858,12 +1858,20 @@ void loopDecoder() {
|
||||||
}
|
}
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
if (!rdzclient.connected()) {
|
if (!rdzclient.connected()) {
|
||||||
rdzclient = rdzserver.available();
|
rdzclient = rdzserver.available();
|
||||||
if(rdzclient.connected()) {
|
if(rdzclient.connected()) {
|
||||||
Serial.println("RDZ JSON socket: new connection");
|
Serial.println("RDZ JSON socket: new connection");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (rdzserver.hasClient()) {
|
||||||
|
Serial.println("TCP JSON socket: new connection");
|
||||||
|
if(rdzclient) rdzclient.stop();
|
||||||
|
rdzclient = rdzserver.available();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if(rdzclient.available()) {
|
if(rdzclient.available()) {
|
||||||
Serial.print("RDZ JSON socket: received ");
|
Serial.print("RDZ JSON socket: received ");
|
||||||
while(rdzclient.available()) {
|
while(rdzclient.available()) {
|
||||||
|
@ -1882,10 +1890,10 @@ void loopDecoder() {
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
}
|
}
|
||||||
// wifi (axudp) or bluetooth (bttnc) active => send packet
|
// wifi (axudp) or bluetooth (bttnc) active => send packet
|
||||||
if ((res & 0xff) == 0 && (connected || tncclient.connected() || rdzclient.connected() )) {
|
SondeInfo *s = &sonde.sondeList[rxtask.receiveSonde];
|
||||||
|
if ((res & 0xff) == 0 && (connected || tncclient.connected() )) {
|
||||||
//Send a packet with position information
|
//Send a packet with position information
|
||||||
// first check if ID and position lat+lonis ok
|
// first check if ID and position lat+lonis ok
|
||||||
SondeInfo *s = &sonde.sondeList[rxtask.receiveSonde];
|
|
||||||
|
|
||||||
if (s->validID && ((s->validPos & 0x03) == 0x03)) {
|
if (s->validID && ((s->validPos & 0x03) == 0x03)) {
|
||||||
const char *str = aprs_senddata(s, sonde.config.call, sonde.config.udpfeed.symbol);
|
const char *str = aprs_senddata(s, sonde.config.call, sonde.config.udpfeed.symbol);
|
||||||
|
@ -1905,10 +1913,27 @@ void loopDecoder() {
|
||||||
Serial.print("sending: "); Serial.println(raw);
|
Serial.print("sending: "); Serial.println(raw);
|
||||||
tncclient.write(raw, rawlen);
|
tncclient.write(raw, rawlen);
|
||||||
}
|
}
|
||||||
if (rdzclient.connected()) {
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// send to MQTT if enabled
|
||||||
|
if (connected && mqttEnabled) {
|
||||||
|
Serial.println("Sending sonde info via MQTT");
|
||||||
|
mqttclient.publishPacket(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
// also send to web socket
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
// always send data, even if not valid....
|
||||||
|
if (rdzclient.connected()) {
|
||||||
Serial.println("Sending position via TCP as rdzJSON");
|
Serial.println("Sending position via TCP as rdzJSON");
|
||||||
char raw[1024];
|
char raw[1024];
|
||||||
|
const char *typestr = s->typestr;
|
||||||
|
if(*typestr==0) typestr = sondeTypeStr[s->type];
|
||||||
int len = snprintf(raw, 1024, "{"
|
int len = snprintf(raw, 1024, "{"
|
||||||
|
"\"res\": %d,"
|
||||||
|
"\"type\": \"%s\","
|
||||||
"\"active\": %d,"
|
"\"active\": %d,"
|
||||||
"\"freq\": %.2f,"
|
"\"freq\": %.2f,"
|
||||||
"\"id\": \"%s\","
|
"\"id\": \"%s\","
|
||||||
|
@ -1929,12 +1954,13 @@ void loopDecoder() {
|
||||||
"\"validTime\": %d,"
|
"\"validTime\": %d,"
|
||||||
"\"rssi\": %d,"
|
"\"rssi\": %d,"
|
||||||
"\"afc\": %d,"
|
"\"afc\": %d,"
|
||||||
"\"rxStat\": \"%s\","
|
|
||||||
"\"launchKT\": %d,"
|
"\"launchKT\": %d,"
|
||||||
"\"burstKT\": %d,"
|
"\"burstKT\": %d,"
|
||||||
"\"countKT\": %d,"
|
"\"countKT\": %d,"
|
||||||
"\"crefKT\": %d"
|
"\"crefKT\": %d"
|
||||||
"}\n",
|
"}\n",
|
||||||
|
res&0xff,
|
||||||
|
typestr,
|
||||||
(int)s->active,
|
(int)s->active,
|
||||||
s->freq,
|
s->freq,
|
||||||
s->id,
|
s->id,
|
||||||
|
@ -1955,7 +1981,6 @@ void loopDecoder() {
|
||||||
(int)s->validTime,
|
(int)s->validTime,
|
||||||
s->rssi,
|
s->rssi,
|
||||||
s->afc,
|
s->afc,
|
||||||
s->rxStat,
|
|
||||||
s->launchKT,
|
s->launchKT,
|
||||||
s->burstKT,
|
s->burstKT,
|
||||||
s->countKT,
|
s->countKT,
|
||||||
|
@ -1963,17 +1988,6 @@ void loopDecoder() {
|
||||||
);
|
);
|
||||||
|
|
||||||
rdzclient.write(raw, len>1024?1024:len);
|
rdzclient.write(raw, len>1024?1024:len);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// send to MQTT if enabled
|
|
||||||
if (connected && mqttEnabled) {
|
|
||||||
Serial.println("Sending sonde info via MQTT");
|
|
||||||
mqttclient.publishPacket(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
// also send to web socket
|
|
||||||
//TODO
|
|
||||||
}
|
}
|
||||||
Serial.print("updateDisplay started... ");
|
Serial.print("updateDisplay started... ");
|
||||||
if (forceReloadScreenConfig) {
|
if (forceReloadScreenConfig) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const char *version_name = "rdzTTGOsonde";
|
const char *version_name = "rdzTTGOsonde";
|
||||||
const char *version_id = "devel20210124";
|
const char *version_id = "devel20210126";
|
||||||
const int SPIFFS_MAJOR=2;
|
const int SPIFFS_MAJOR=2;
|
||||||
const int SPIFFS_MINOR=8;
|
const int SPIFFS_MINOR=8;
|
||||||
|
|
Ładowanie…
Reference in New Issue