better DFM name change handling

This commit is contained in:
Hansi, dl9rdz 2022-05-29 10:28:33 +00:00
parent 8b59a0d1c9
commit 293e8a7313
3 changed files with 15 additions and 15 deletions

View File

@ -2332,23 +2332,21 @@ void loopDecoder() {
sondehub_reply_handler(&shclient);
#endif
// wifi (axudp) or bluetooth (bttnc) active => send packet
// wifi active and good packet received => send packet
SondeInfo *s = &sonde.sondeList[rxtask.receiveSonde];
if ((res & 0xff) == 0 && (connected || tncclient.connected() )) {
if ((res & 0xff) == 0 && connected) {
//Send a packet with position information
// first check if ID and position lat+lonis ok
if (s->d.validID && ((s->d.validPos & 0x03) == 0x03)) {
char *str = aprs_senddata(s, sonde.config.call, sonde.config.objcall, sonde.config.udpfeed.symbol);
if (connected) {
char raw[201];
int rawlen = aprsstr_mon2raw(str, raw, APRS_MAXLEN);
Serial.println("Sending AXUDP");
//Serial.println(raw);
udp.beginPacket(sonde.config.udpfeed.host, sonde.config.udpfeed.port);
udp.write((const uint8_t *)raw, rawlen);
udp.endPacket();
}
char raw[201];
int rawlen = aprsstr_mon2raw(str, raw, APRS_MAXLEN);
Serial.println("Sending AXUDP");
//Serial.println(raw);
udp.beginPacket(sonde.config.udpfeed.host, sonde.config.udpfeed.port);
udp.write((const uint8_t *)raw, rawlen);
udp.endPacket();
if (tncclient.connected()) {
Serial.println("Sending position via TCP");
char raw[201];
@ -3567,7 +3565,7 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
}
// Check if current sonde data is valid. If not, don't do anything....
if (*s->d.ser == 0) return; // Don't send anything without serial number
if (*s->d.ser == 0 || s->d.validID==0 ) return; // Don't send anything without serial number
if (((int)s->d.lat == 0) && ((int)s->d.lon == 0)) return; // Sometimes these values are zeroes. Don't send those to the sondehub
if ((int)s->d.alt > 50000) return; // If alt is too high don't send to SondeHub
// M20 data does not include #sat information

View File

@ -221,6 +221,8 @@ const char* typestr[16]={
void DFM::killid() {
SondeData *sd = &(sonde.si()->d);
sd->validID = false;
*(sd->id) = 0;
*(sd->ser) = 0;
memset((void *)&dfmstate, 0, sizeof(dfmstate));
}
@ -268,6 +270,7 @@ void DFM::finddfname(uint8_t *b)
}
if(i==6) {
snprintf(sd->id, 10, "D%x ", id);
memcpy(sd->ser, sd->id+1, 9);
sd->validID = true;
sd->subtype = (st>>4)&0x0F;
strncpy(sd->typestr, typestr[ (st>>4)&0x0F ], 5);
@ -319,6 +322,7 @@ void DFM::finddfname(uint8_t *b)
snprintf(sd->id, 10, "D%d", ((dfmstate.dat[2*i]<<16)|dfmstate.dat[2*i+1])%100000000);
Serial.print("\nNEW AUTOID:");
Serial.println(sd->id);
memcpy(sd->ser, sd->id+1, 9);
sd->validID = true;
sd->subtype = (st>>4)&0x0F;
strncpy(sd->typestr, typestr[ (st>>4)&0x0F ], 5);
@ -402,8 +406,6 @@ void DFM::decodeCFG(uint8_t *cfg)
Serial.printf("battery: %f\n", si->batteryVoltage);
}
}
// new aprs ID (dxlaprs, autorx) is now "D" + serial (8 digits) by consensus
memcpy(sonde.si()->d.ser, sonde.si()->d.id+1, 9);
}
#if 0

View File

@ -1,4 +1,4 @@
const char *version_name = "rdzTTGOsonde";
const char *version_id = "devel20220422";
const char *version_id = "devel20220426";
const int SPIFFS_MAJOR=2;
const int SPIFFS_MINOR=16;