send real decoded type for M10/M20 to sondehub

This commit is contained in:
Hansi, dl9rdz 2021-08-13 00:33:23 +02:00
parent 649711b112
commit eb25f9d530
5 changed files with 23 additions and 12 deletions

View File

@ -646,7 +646,7 @@ struct st_configitems config_list[] = {
/* Hardware dependeing settings */ /* Hardware dependeing settings */
{"", "Hardware configuration (requires reboot)", -5, NULL}, {"", "Hardware configuration (requires reboot)", -5, NULL},
{"disptype", "Display type (0=OLED/SSD1306, 1=ILI9225, 2=OLED/SH1106, 3=ILI9341)", 0, &sonde.config.disptype}, {"disptype", "Display type (0=OLED/SSD1306, 1=ILI9225, 2=OLED/SH1106, 3=ILI9341, 4=ILI9342)", 0, &sonde.config.disptype},
{"norx_timeout", "No-RX-Timeout in seconds (-1=disabled)", 0, &sonde.config.norx_timeout}, {"norx_timeout", "No-RX-Timeout in seconds (-1=disabled)", 0, &sonde.config.norx_timeout},
{"oled_sda", "OLED SDA/TFT SDA", 0, &sonde.config.oled_sda}, {"oled_sda", "OLED SDA/TFT SDA", 0, &sonde.config.oled_sda},
{"oled_scl", "OLED SCL/TFT CLK", 0, &sonde.config.oled_scl}, {"oled_scl", "OLED SCL/TFT CLK", 0, &sonde.config.oled_scl},
@ -1929,6 +1929,7 @@ void setup()
} }
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); axp.setPowerOutPut(AXP192_LDO3, AXP202_ON);
axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON); axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON);
axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON); axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON);
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
@ -3199,6 +3200,10 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
char rs_msg[MSG_SIZE]; char rs_msg[MSG_SIZE];
char *w; char *w;
struct tm ts; 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->subtype==1 ? STYPE_M10 : STYPE_M20; }
// For DFM, s->time is data from subframe DAT8 (gps date/hh/mm), and sec is from DAT1 (gps sec/usec) // For DFM, s->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 // For all others, sec should always be 0 and time the exact time in seconds
time_t t = s->time + s->sec; time_t t = s->time + s->sec;
@ -3228,7 +3233,7 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
if (((int)s->lat == 0) && ((int)s->lon == 0)) return; // Sometimes these values are zeroes. Don't send those to the sondehub if (((int)s->lat == 0) && ((int)s->lon == 0)) return; // Sometimes these values are zeroes. Don't send those to the sondehub
if ((int)s->alt > 50000) return; // If alt is too high don't send to SondeHub if ((int)s->alt > 50000) return; // If alt is too high don't send to SondeHub
// M20 data does not include #sat information // M20 data does not include #sat information
if ( s->type != STYPE_M20 && (int)s->sats < 4) return; // If not enough sats don't send to SondeHub if ( realtype != STYPE_M20 && (int)s->sats < 4) return; // If not enough sats don't send to SondeHub
// If not connected to sondehub, try reconnecting. // If not connected to sondehub, try reconnecting.
// TODO: do this outside of main loop // TODO: do this outside of main loop
@ -3255,7 +3260,7 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
// DFM uses UTC. Most of the other radiosondes use GPS time // DFM uses UTC. Most of the other radiosondes use GPS time
// SondeHub expect datetime to be the same time sytem as the sonde transmits as time stamp // SondeHub expect datetime to be the same time sytem as the sonde transmits as time stamp
if ( s->type == STYPE_RS41 || s->type == STYPE_RS92 || s->type == STYPE_M20 ) { if ( realtype == STYPE_RS41 || realtype == STYPE_RS92 || realtype == STYPE_M20 ) {
t += 18; // convert back to GPS time from UTC time +18s t += 18; // convert back to GPS time from UTC time +18s
} }
@ -3283,25 +3288,25 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
"\"rssi\": %.1f,", "\"rssi\": %.1f,",
version_name, version_id, conf->callsign, version_name, version_id, conf->callsign,
timeinfo.tm_year + 1900, timeinfo.tm_mon + 1, timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec, timeinfo.tm_year + 1900, timeinfo.tm_mon + 1, timeinfo.tm_mday, timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec,
manufacturer_string[s->type], s->ser, manufacturer_string[realtype], s->ser,
ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec + s->sec, ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday, ts.tm_hour, ts.tm_min, ts.tm_sec + s->sec,
(float)s->lat, (float)s->lon, (float)s->alt, (float)s->freq, (float)s->hs, (float)s->vs, (float)s->lat, (float)s->lon, (float)s->alt, (float)s->freq, (float)s->hs, (float)s->vs,
(float)s->dir, -((float)s->rssi / 2) (float)s->dir, -((float)s->rssi / 2)
); );
w += strlen(w); w += strlen(w);
if (s->type != STYPE_M20) { if (realtype != STYPE_M20) {
sprintf(w, "\"sats\": %d,", (int)s->sats); sprintf(w, "\"sats\": %d,", (int)s->sats);
w += strlen(w); w += strlen(w);
} }
if ( TYPE_IS_DFM(s->type) || TYPE_IS_METEO(s->type) || s->type == STYPE_MP3H ) { if ( TYPE_IS_DFM(realtype) || TYPE_IS_METEO(realtype) || realtype == STYPE_MP3H ) {
// send frame as gps timestamp for these sonde, identical to autorx // send frame as gps timestamp for these sonde, identical to autorx
// For M10, this is real GPS time (seconds since Jqn 6 1980, without adjusting for leap seconds) // For M10, this is real GPS time (seconds since Jqn 6 1980, without adjusting for leap seconds)
// DFM and MP3H send real UTC (with leap seconds considered), so for them the frame number actually // DFM and MP3H send real UTC (with leap seconds considered), so for them the frame number actually
// is gps time plus number of leap seconds since the beginning of GPS time. // is gps time plus number of leap seconds since the beginning of GPS time.
int frame = (int)(t - 315964800); int frame = (int)(t - 315964800);
if (s->type == STYPE_M10) { if (realtype == STYPE_M10) {
frame += 18; frame += 18;
}; };
sprintf(w, "\"frame\": %d,", frame); sprintf(w, "\"frame\": %d,", frame);
@ -3310,7 +3315,7 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub *
} }
w += strlen(w); w += strlen(w);
sprintf(w, "\"type\": \"%s\",", sondeTypeStrSH[s->type]); sprintf(w, "\"type\": \"%s\",", sondeTypeStrSH[realtype]);
w += strlen(w); w += strlen(w);
/* if there is a subtype (DFM only) */ /* if there is a subtype (DFM only) */

View File

@ -1,4 +1,4 @@
const char *version_name = "rdzTTGOsonde"; const char *version_name = "rdzTTGOsonde";
const char *version_id = "devel20210811"; const char *version_id = "devel20210812";
const int SPIFFS_MAJOR=2; const int SPIFFS_MAJOR=2;
const int SPIFFS_MINOR=14; const int SPIFFS_MINOR=14;

View File

@ -345,6 +345,8 @@ void ILI9225Display::begin() {
sonde.config.oled_scl, sonde.config.oled_sda, -1, HSPI); sonde.config.oled_scl, sonde.config.oled_sda, -1, HSPI);
if(_type == 3) if(_type == 3)
tft = new Arduino_ILI9341(bus, sonde.config.oled_rst); tft = new Arduino_ILI9341(bus, sonde.config.oled_rst);
else if(_type == 4)
tft = new Arduino_ILI9342(bus, sonde.config.oled_rst);
else else
tft = new Arduino_ILI9225(bus, sonde.config.oled_rst); tft = new Arduino_ILI9225(bus, sonde.config.oled_rst);
Serial.println("ILI9225/ILI9341 init: done"); Serial.println("ILI9225/ILI9341 init: done");
@ -665,7 +667,7 @@ RawDisplay *Display::rdis = NULL;
//TODO: maybe merge with initFromFile later? //TODO: maybe merge with initFromFile later?
void Display::init() { void Display::init() {
Serial.printf("disptype is %d\n",sonde.config.disptype); Serial.printf("disptype is %d\n",sonde.config.disptype);
if(sonde.config.disptype==1 || sonde.config.disptype==3) { if(sonde.config.disptype==1 || sonde.config.disptype==3 || sonde.config.disptype==4 ) {
rdis = new ILI9225Display(sonde.config.disptype); rdis = new ILI9225Display(sonde.config.disptype);
} else { } else {
rdis = new U8x8Display(sonde.config.disptype); rdis = new U8x8Display(sonde.config.disptype);
@ -914,6 +916,7 @@ int Display::getScreenIndex(int index) {
if( (sonde.config.tft_orient&0x01)==0 ) index++; // portrait mode (0/2) if( (sonde.config.tft_orient&0x01)==0 ) index++; // portrait mode (0/2)
break; break;
case 3: // ILI9341 case 3: // ILI9341
case 4: // ILI9342
index = 4; // landscape mode (orient=1/3) index = 4; // landscape mode (orient=1/3)
if( (sonde.config.tft_orient&0x01)==0 ) index++; // portrait mode (0/2) if( (sonde.config.tft_orient&0x01)==0 ) index++; // portrait mode (0/2)
break; break;
@ -1035,7 +1038,7 @@ void Display::initFromFile(int index) {
char text[61]; char text[61];
n=sscanf(s, "%f,%f,%f", &y, &x, &w); n=sscanf(s, "%f,%f,%f", &y, &x, &w);
sscanf(ptr+1, "%60[^\r\n]", text); sscanf(ptr+1, "%60[^\r\n]", text);
if(sonde.config.disptype==1 || sonde.config.disptype==3) { x*=xscale; y*=yscale; w*=xscale; } if(sonde.config.disptype==1 || sonde.config.disptype==3 || sonde.config.disptype==4 ) { x*=xscale; y*=yscale; w*=xscale; }
newlayouts[idx].de[what].x = x; newlayouts[idx].de[what].x = x;
newlayouts[idx].de[what].y = y; newlayouts[idx].de[what].y = y;
newlayouts[idx].de[what].width = n>2 ? w : WIDTH_AUTO; newlayouts[idx].de[what].width = n>2 ? w : WIDTH_AUTO;
@ -1193,6 +1196,7 @@ void Display::drawID(DispEntry *de) {
} }
void Display::drawRSSI(DispEntry *de) { void Display::drawRSSI(DispEntry *de) {
rdis->setFont(de->fmt); rdis->setFont(de->fmt);
// TODO.... 3/4!!!!!
if(sonde.config.disptype!=1) { if(sonde.config.disptype!=1) {
snprintf(buf, 16, "-%d ", sonde.si()->rssi/2); snprintf(buf, 16, "-%d ", sonde.si()->rssi/2);
int len=strlen(buf)-3; int len=strlen(buf)-3;

View File

@ -393,12 +393,14 @@ void M10M20::processM10data(uint8_t dt)
if(rxp==2 && dataptr[0]==0x45 && dataptr[1]==0x20) { isM20 = true; } if(rxp==2 && dataptr[0]==0x45 && dataptr[1]==0x20) { isM20 = true; }
if(isM20) { if(isM20) {
memcpy(sonde.si()->typestr, "M20 ", 5); memcpy(sonde.si()->typestr, "M20 ", 5);
sonde.si()->subtype = 2;
if(rxp>=M20_FRAMELEN) { if(rxp>=M20_FRAMELEN) {
rxsearching = true; rxsearching = true;
haveNewFrame = decodeframeM20(dataptr); haveNewFrame = decodeframeM20(dataptr);
} }
} else { } else {
memcpy(sonde.si()->typestr, "M10 ", 5); memcpy(sonde.si()->typestr, "M10 ", 5);
sonde.si()->subtype = 1;
if(rxp>=M10_FRAMELEN) { if(rxp>=M10_FRAMELEN) {
rxsearching = true; rxsearching = true;
haveNewFrame = decodeframeM10(dataptr); haveNewFrame = decodeframeM10(dataptr);

View File

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