From eb25f9d5302323edf681df1d5dfa6842bd51fb67 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Fri, 13 Aug 2021 00:33:23 +0200 Subject: [PATCH] send real decoded type for M10/M20 to sondehub --- RX_FSK/RX_FSK.ino | 21 +++++++++++++-------- RX_FSK/version.h | 2 +- libraries/SondeLib/Display.cpp | 8 ++++++-- libraries/SondeLib/M10M20.cpp | 2 ++ libraries/SondeLib/Sonde.h | 2 +- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index cf0eb32..45ba170 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -646,7 +646,7 @@ struct st_configitems config_list[] = { /* Hardware dependeing settings */ {"", "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}, {"oled_sda", "OLED SDA/TFT SDA", 0, &sonde.config.oled_sda}, {"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_LDO3, AXP202_ON); + axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON); axp.setPowerOutPut(AXP192_EXTEN, 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 *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->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 all others, sec should always be 0 and time the exact time in seconds 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->alt > 50000) return; // If alt is too high don't send to SondeHub // 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. // 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 // 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 } @@ -3283,25 +3288,25 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub * "\"rssi\": %.1f,", 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, - 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, (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) ); w += strlen(w); - if (s->type != STYPE_M20) { + if (realtype != STYPE_M20) { sprintf(w, "\"sats\": %d,", (int)s->sats); 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 // 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 // is gps time plus number of leap seconds since the beginning of GPS time. int frame = (int)(t - 315964800); - if (s->type == STYPE_M10) { + if (realtype == STYPE_M10) { frame += 18; }; sprintf(w, "\"frame\": %d,", frame); @@ -3310,7 +3315,7 @@ void sondehub_send_data(WiFiClient * client, SondeInfo * s, struct st_sondehub * } w += strlen(w); - sprintf(w, "\"type\": \"%s\",", sondeTypeStrSH[s->type]); + sprintf(w, "\"type\": \"%s\",", sondeTypeStrSH[realtype]); w += strlen(w); /* if there is a subtype (DFM only) */ diff --git a/RX_FSK/version.h b/RX_FSK/version.h index 3633eff..eaf4c51 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20210811"; +const char *version_id = "devel20210812"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=14; diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index deaabc9..7d9e0a4 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -345,6 +345,8 @@ void ILI9225Display::begin() { sonde.config.oled_scl, sonde.config.oled_sda, -1, HSPI); if(_type == 3) tft = new Arduino_ILI9341(bus, sonde.config.oled_rst); + else if(_type == 4) + tft = new Arduino_ILI9342(bus, sonde.config.oled_rst); else tft = new Arduino_ILI9225(bus, sonde.config.oled_rst); Serial.println("ILI9225/ILI9341 init: done"); @@ -665,7 +667,7 @@ RawDisplay *Display::rdis = NULL; //TODO: maybe merge with initFromFile later? void Display::init() { 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); } else { 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) break; case 3: // ILI9341 + case 4: // ILI9342 index = 4; // landscape mode (orient=1/3) if( (sonde.config.tft_orient&0x01)==0 ) index++; // portrait mode (0/2) break; @@ -1035,7 +1038,7 @@ void Display::initFromFile(int index) { char text[61]; n=sscanf(s, "%f,%f,%f", &y, &x, &w); 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].y = y; newlayouts[idx].de[what].width = n>2 ? w : WIDTH_AUTO; @@ -1193,6 +1196,7 @@ void Display::drawID(DispEntry *de) { } void Display::drawRSSI(DispEntry *de) { rdis->setFont(de->fmt); + // TODO.... 3/4!!!!! if(sonde.config.disptype!=1) { snprintf(buf, 16, "-%d ", sonde.si()->rssi/2); int len=strlen(buf)-3; diff --git a/libraries/SondeLib/M10M20.cpp b/libraries/SondeLib/M10M20.cpp index 01d60b2..c10117d 100644 --- a/libraries/SondeLib/M10M20.cpp +++ b/libraries/SondeLib/M10M20.cpp @@ -393,12 +393,14 @@ void M10M20::processM10data(uint8_t dt) if(rxp==2 && dataptr[0]==0x45 && dataptr[1]==0x20) { isM20 = true; } if(isM20) { memcpy(sonde.si()->typestr, "M20 ", 5); + sonde.si()->subtype = 2; if(rxp>=M20_FRAMELEN) { rxsearching = true; haveNewFrame = decodeframeM20(dataptr); } } else { memcpy(sonde.si()->typestr, "M10 ", 5); + sonde.si()->subtype = 1; if(rxp>=M10_FRAMELEN) { rxsearching = true; haveNewFrame = decodeframeM10(dataptr); diff --git a/libraries/SondeLib/Sonde.h b/libraries/SondeLib/Sonde.h index 89f13a9..4e04e4e 100644 --- a/libraries/SondeLib/Sonde.h +++ b/libraries/SondeLib/Sonde.h @@ -67,7 +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?*/ + int8_t subtype; /* 0 for none/unknown, hex type for dfm, 1/2 for M10/M20 */ float freq; // decoded ID char typestr[5]; // decoded type (use type if *typestr==0)