use correct M10/M20 type everywhere

pull/191/head
Hansi, dl9rdz 2021-09-24 12:09:32 +02:00
rodzic a7f6d6bb7b
commit 8bc4eda63c
5 zmienionych plików z 48 dodań i 25 usunięć

Wyświetl plik

@ -503,7 +503,7 @@ void addSondeStatus(char *ptr, int i)
struct tm ts;
SondeInfo *s = &sonde.sondeList[i];
strcat(ptr, "<table>");
sprintf(ptr + strlen(ptr), "<tr><td id=\"sfreq\">%3.3f MHz, Type: %s</td><tr><td>ID: %s", s->freq, sondeTypeLongStr[s->type],
sprintf(ptr + strlen(ptr), "<tr><td id=\"sfreq\">%3.3f MHz, Type: %s</td><tr><td>ID: %s", s->freq, sondeTypeLongStr[sonde.realType(s)],
s->d.validID ? s->d.id : "<?""?>");
if (s->d.validID && (TYPE_IS_DFM(s->type) || TYPE_IS_METEO(s->type) || s->type == STYPE_MP3H) ) {
sprintf(ptr + strlen(ptr), " (ser: %s)", s->d.ser);
@ -548,7 +548,7 @@ const char *createLiveJson() {
SondeInfo *s = &sonde.sondeList[sonde.currentSonde];
sprintf(ptr + strlen(ptr), "\"sonde\": {\"rssi\": %d, \"vframe\": %d, \"time\": %d,\"id\": \"%s\", \"freq\": %3.3f, \"type\": \"%s\"",
s->rssi, s->d.vframe, s->d.time, s->d.id, s->freq, sondeTypeStr[s->type]);
s->rssi, s->d.vframe, s->d.time, s->d.id, s->freq, sondeTypeStr[sonde.realType(s)]);
if ( !isnan(s->d.lat) && !isnan(s->d.lon) )
sprintf(ptr + strlen(ptr), ", \"lat\": %.6f, \"lon\": %.6f", s->d.lat, s->d.lon);
@ -1309,7 +1309,7 @@ void addSondeStatusKML(char *ptr, int i)
sprintf(ptr + strlen(ptr), "<Placemark id=\"%s\"><name>%s</name><Point><altitudeMode>absolute</altitudeMode><coordinates>%.6f,%.6f,%.0f</coordinates></Point><description>%3.3f MHz, Type: %s, h=%.0fm</description></Placemark>",
s->d.id, s->d.id,
s->d.lon, s->d.lat, s->d.alt,
s->freq, sondeTypeStr[s->type], s->d.alt);
s->freq, sondeTypeStr[sonde.realType(s)], s->d.alt);
}
const char *createKMLDynamic() {
@ -2528,20 +2528,20 @@ void loopDecoder() {
Serial.print("sending: "); Serial.println(raw);
tncclient.write(raw, rawlen);
}
if(sonde.config.tcpfeed.active) {
static unsigned long lasttcp = 0;
if( tcpclient.disconnected()) {
tcpclient.connect(sonde.config.tcpfeed.host, sonde.config.tcpfeed.port);
}
else if( tcpclient.connected() ) {
unsigned long now = millis();
if( (now-lasttcp) > sonde.config.tcpfeed.highrate*1000L ) {
strcat(str,"\r\n");
Serial.print(str);
tcpclient.write(str, strlen(str));
lasttcp = now;
}
}
if (sonde.config.tcpfeed.active) {
static unsigned long lasttcp = 0;
if ( tcpclient.disconnected()) {
tcpclient.connect(sonde.config.tcpfeed.host, sonde.config.tcpfeed.port);
}
else if ( tcpclient.connected() ) {
unsigned long now = millis();
if ( (now - lasttcp) > sonde.config.tcpfeed.highrate * 1000L ) {
strcat(str, "\r\n");
Serial.print(str);
tcpclient.write(str, strlen(str));
lasttcp = now;
}
}
}
#if FEATURE_CHASEMAPPER
if (sonde.config.cm.active) {
@ -2573,7 +2573,7 @@ void loopDecoder() {
char raw[1024];
char gps[128];
const char *typestr = s->d.typestr;
if (*typestr == 0) typestr = sondeTypeStr[s->type];
if (*typestr == 0) typestr = sondeTypeStr[sonde.realType(s)];
// TODO: only if GPS is valid...
if (gpsPos.valid) {
snprintf(gps, 128, ", \"gpslat\": %f,"
@ -2775,13 +2775,13 @@ void enableNetwork(bool enable) {
MDNS.end();
connected = false;
}
tcpclient.onConnect([](void *arg, AsyncClient *s) {
tcpclient.onConnect([](void *arg, AsyncClient * s) {
Serial.write("APRS: TCP connected\n");
char buf[128];
snprintf(buf, 128, "user %s pass %d vers %s %s\r\n", sonde.config.call, sonde.config.passcode, version_name, version_id);
s->write(buf, strlen(buf));
});
tcpclient.onData([](void *arg, AsyncClient *c, void *data, size_t len) {
tcpclient.onData([](void *arg, AsyncClient * c, void *data, size_t len) {
Serial.write((const uint8_t *)data, len);
});
Serial.println("enableNetwork done");
@ -3646,11 +3646,8 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
char rs_msg[MSG_SIZE];
char *w;
struct tm ts;
uint8_t realtype = s->type;
// config setting M10 and M20 will both decode both types, so use the real type that was decoded
if (TYPE_IS_METEO(realtype)) {
realtype = s->d.subtype == 1 ? STYPE_M10 : STYPE_M20;
}
uint8_t realtype = sonde.realType(s);
// For DFM, s->d.time is data from subframe DAT8 (gps date/hh/mm), and sec is from DAT1 (gps sec/usec)
// For all others, sec should always be 0 and time the exact time in seconds

Wyświetl plik

@ -328,6 +328,25 @@ int M10M20::decodeframeM10(uint8_t *data) {
if(dir<0) dir+=360;
si->dir = dir;
si->validPos = 0x3f;
// m10 temp
const float p0 = 1.07303516e-03, p1 = 2.41296733e-04, p2 = 2.26744154e-06, p3 = 6.52855181e-08;
const float Rs[3] = { 12.1e3 , 36.5e3 , 475.0e3 };
const float Rp[3] = { 1e20 , 330.0e3 , 2000.0e3 };
uint8_t sct = data[62];
float rt = getint16(data+63) & (0xFFF);
float T = NAN;
if(rt!=0 && sct<3) {
rt = (4095-rt)/rt - (Rs[sct]/Rp[sct]);
if(rt>0) {
rt = Rs[sct] / rt;
if(rt>0) {
rt = log(rt);
rt = 1/( p0 + p1*rt + p2*rt*rt + p3*rt*rt*rt ) - 273.15;
if(rt>-99 && rt<50) { T = rt; }
}
}
}
si->temperature = T;
uint32_t gpstime = getint32(data+10);
uint16_t gpsweek = getint16(data+32);

Wyświetl plik

@ -716,4 +716,9 @@ void Sonde::clearDisplay() {
disp.rdis->clear();
}
SondeType Sonde::realType(SondeInfo *si) {
if(TYPE_IS_METEO(si->type)) { return si->d.subtype==1 ? STYPE_M10:STYPE_M20; }
else return si->type;
}
Sonde sonde = Sonde();

Wyświetl plik

@ -319,6 +319,8 @@ public:
// moved to heap, saving space in .bss
//SondeInfo sondeList[MAXSONDE+1];
SondeInfo *sondeList;
// helper function for type string
static SondeType realType(SondeInfo *si);
Sonde();
void defaultConfig();

Wyświetl plik

@ -310,7 +310,7 @@ char *aprs_senddata(SondeInfo *si, const char *usercall, const char *sym) {
if( !isnan(s->relativeHumidity) ) {
sprintf(b+strlen(b), "h=%.1f%% ", s->relativeHumidity);
}
sprintf(b+strlen(b), "%.3fMHz Type=%s ", si->freq, sondeTypeStr[si->type]);
sprintf(b+strlen(b), "%.3fMHz Type=%s ", si->freq, sondeTypeStr[sonde.realType(si)]);
if( s->countKT != 0xffff && s->vframe - s->crefKT < 51 ) {
sprintf(b+strlen(b), "TxOff=%dh%dm ", s->countKT/3600, (s->countKT-s->countKT/3600*3600)/60);
}