DFM subtypes enhancement for SondeHub

pull/87/head
Hansi, dl9rdz 2021-05-29 12:14:13 +02:00
rodzic 08572f7cbc
commit acc71804ab
5 zmienionych plików z 38 dodań i 33 usunięć

Wyświetl plik

@ -2997,6 +2997,19 @@ enum SHState { SH_DISCONNECTED, SH_CONNECTING, SH_CONN_IDLE, SH_CONN_WAITACK };
SHState shState = SH_DISCONNECTED;
/* Sonde.h: enum SondeType { STYPE_DFM, STYPE_DFM09_OLD, STYPE_RS41, STYPE_RS92, STYPE_M10, STYPE_M20, STYPE_DFM06_OLD, STYPE_MP3H }; */
const char *sondeTypeStrSH[NSondeTypes] = { "DFM", "DFM", "RS41", "RS92", "M10", "M20", "DFM", "MRZ" };
const char *dfmSubtypeStrSH[16] = { NULL, NULL, NULL, NULL, NULL, NULL,
"DFM06", // 0x06
"PS15", // 0x07
NULL, NULL,
"DFM09", // 0x0A
"DFM17", // 0x0B
"DFM09P", // 0x0C
"DFM17", // 0x0D
NULL, NULL
};
void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *conf) {
Serial.println("sondehub_send_data()");
@ -3077,39 +3090,23 @@ void sondehub_send_data(WiFiClient *client, SondeInfo *s, struct st_sondehub *co
);
w += strlen(w);
if ( s->type == STYPE_DFM09_OLD || s->type == STYPE_DFM06_OLD || s->type == STYPE_M10 || s->type == STYPE_M20 ) { //send frame as unix timestamp for these sonde
//send unix timestamp
sprintf(w,
"\"frame\": \"%d\",",
int(t)
);
w += strlen(w);
if ( s->type == STYPE_DFM09_OLD) { //fix subtype
sprintf(w,
"\"type\": \"DFM\","
"\"subtype\": \"DFM09\","
);
w += strlen(w);
} else if ( s->type == STYPE_DFM06_OLD) { //fix subtype
sprintf(w,
"\"type\": \"DFM\","
"\"subtype\": \"DFM06\","
);
w += strlen(w);
} else {
sprintf(w,
"\"type\": \"%s\",",
sondeTypeStr[s->type]
);
w += strlen(w);
}
if ( TYPE_IS_DFM(s->type) || TYPE_IS_METEO(s->type) ) { //send frame as unix timestamp for these sonde
sprintf(w, "\"frame\": %d,", int(t));
} else {
sprintf(w,
"\"frame\": %d,"
"\"type\": \"%s\",",
s->frame, sondeTypeStr[s->type]
);
w += strlen(w);
sprintf(w, "\"frame\": %d,", s->frame);
}
w += strlen(w);
sprintf(w, "\"type\": \"%s\",", sondeTypeStrSH[s->type]);
w += strlen(w);
/* if there is a subtype (DFM only) */
if ( TYPE_IS_DFM(s->type) && s->subtype > 0 && s->subtype < 16 ) {
const char *t = dfmSubtypeStrSH[s->subtype];
// as in https://github.com/projecthorus/radiosonde_auto_rx/blob/e680221f69a568e1fdb24e76db679233f32cb027/auto_rx/autorx/sonde_specific.py#L84
if (t) sprintf(w, "\"subtype\": \"%s\",", t);
else sprintf(w, "\"subtype\": \"DFMx%X\",", s->subtype); // Unknown subtype
w += strlen(w);
}
if (((int)s->temperature != 0) && ((int)s->relativeHumidity != 0)) {

Wyświetl plik

@ -1,4 +1,4 @@
const char *version_name = "rdzTTGOsonde";
const char *version_id = "devel20210526";
const char *version_id = "devel20210529";
const int SPIFFS_MAJOR=2;
const int SPIFFS_MINOR=11;

Wyświetl plik

@ -269,6 +269,7 @@ void DFM::finddfname(uint8_t *b)
if(i==6) {
snprintf(sonde.si()->id, 10, "D%x ", id);
sonde.si()->validID = true;
sonde.si()->subtype = (st>>4)&0x0F;
strncpy(sonde.si()->typestr, typestr[ (st>>4)&0x0F ], 5);
return;
}
@ -319,6 +320,7 @@ void DFM::finddfname(uint8_t *b)
Serial.print("\nNEW AUTOID:");
Serial.println(sonde.si()->id);
sonde.si()->validID = true;
sonde.si()->subtype = (st>>4)&0x0F;
strncpy(sonde.si()->typestr, typestr[ (st>>4)&0x0F ], 5);
}
if(dfmstate.nameregok==i) {

Wyświetl plik

@ -462,6 +462,11 @@ static void posrs41(const byte b[], uint32_t b_len, uint32_t p)
x = (double)getint32(b, b_len, p)*0.01;
y = (double)getint32(b, b_len, p+4UL)*0.01;
z = (double)getint32(b, b_len, p+8UL)*0.01;
if(x==0 && y==0 && z==0) {
// RS41 sometimes sends frame with all 0
if(sonde.si()->validPos) sonde.si()->validPos |= 0x80; // flag as old
return;
}
wgs84r(x, y, z, &lat, &long0, &heig);
Serial.print(" ");
sonde.si()->lat = (float)(X2C_DIVL(lat,1.7453292519943E-2));

Wyświetl plik

@ -67,6 +67,7 @@ typedef struct st_sondeinfo {
// receiver configuration
bool active;
SondeType type;
int8_t subtype; /* 0 for none/unknown, hex type for dfm, maybe add 1/2 for M10/M20 as well?*/
float freq;
// decoded ID
char typestr[5]; // decoded type (use type if *typestr==0)