From aaa33267d7b88985f8895924069d5376d4e4924d Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Sat, 28 Nov 2020 19:53:09 +0100 Subject: [PATCH] updated dfm serial numbers --- RX_FSK/data/screens.txt | 7 ++++-- RX_FSK/version.h | 2 +- libraries/SondeLib/DFM.cpp | 44 +++++++++++++++++++++------------- libraries/SondeLib/Display.cpp | 35 ++++++++++++++------------- 4 files changed, 52 insertions(+), 36 deletions(-) diff --git a/RX_FSK/data/screens.txt b/RX_FSK/data/screens.txt index b7d3bb4..406bbb1 100644 --- a/RX_FSK/data/screens.txt +++ b/RX_FSK/data/screens.txt @@ -32,7 +32,10 @@ # Hm(suffix) hor. speed m/s (suffix: e.g. "m/s"; no suffix=>m/s as 16x8 bitmap for SSD1306 display only) # Hk(suffix) hor. speed km/h (suffix: e.g. "km/h"; no suffix=>km/h as 16x8 bitmap for SSD1306 display only) # V(suffix) vert. speef (suffix: e.g. "m/s"; no suffix=>m/s as 16x8 bitmap for SSD1306 display only) -# Ix sonde ID (dfm format by x: d=>dxlaprs, a=>autorx, s=>real serial number) +# Ix sonde ID (default/d: dxlaprs; s: short id, n: real serial number) +# RS41,RS92: all identical R1234567 +# DFMx: ID M12345678; short ID and serial 12345678 +# M10: ID ME95231F0; short ID: M95231F0; serial 9062104592 # Q signal quality statistics bar # T type string (RS41/DFM9/DFM6/RS92) # C afC value @@ -223,7 +226,7 @@ key1action=+,0,F,W key2action=>,#,#,# timeaction=#,#,0 color=FFD700 -0,0=Id +0,0=Is color=0000FF 0,11,-5.5=f 1,1,6=c diff --git a/RX_FSK/version.h b/RX_FSK/version.h index 5395224..d7e55d3 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20201128"; +const char *version_id = "devel20201128b"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=4; diff --git a/libraries/SondeLib/DFM.cpp b/libraries/SondeLib/DFM.cpp index f9baa49..3dc6e2d 100644 --- a/libraries/SondeLib/DFM.cpp +++ b/libraries/SondeLib/DFM.cpp @@ -12,6 +12,19 @@ #define DFM_DBG(x) #endif +// single data structure, search restarts after decoder change +static struct st_dfmstat { + int idcnt0; + int idcnt1; + int lastfrid; + int lastfrcnt; + uint8_t start[50]; + uint16_t dat[50*2]; + uint8_t cnt[50*2]; + uint8_t nameregok; + uint8_t nameregtop; +} dfmstate; + int DFM::setup(float frequency, int inv) { inverse = inv; @@ -57,7 +70,8 @@ int DFM::setup(float frequency, int inv) DFM_DBG(Serial.println("Setting SYNC Config FAILED")); return 1; } - if(sx1278.setPreambleDetect(0xA8)!=0) { + //if(sx1278.setPreambleDetect(0xA8)!=0) { + if(sx1278.setPreambleDetect(0xAA)!=0) { DFM_DBG(Serial.println("Setting PreambleDetect FAILED")); return 1; } @@ -73,6 +87,7 @@ int DFM::setup(float frequency, int inv) int retval = sx1278.setFrequency(frequency); sx1278.clearIRQFlags(); + memset((void *)&dfmstate, 0, sizeof(dfmstate)); DFM_DBG(Serial.println("Setting SX1278 config for DFM finished\n"); Serial.println()); return retval; } @@ -163,18 +178,6 @@ void DFM::printRaw(const char *label, int len, int ret, const uint8_t *data) Serial.print(" "); } -// single data structure, search restarts after decoder change -static struct st_dfmstat { - int idcnt0; - int idcnt1; - int lastfrid; - int lastfrcnt; - uint8_t start[50]; - uint16_t dat[50*2]; - uint8_t cnt[50*2]; - uint8_t nameregok; - uint8_t nameregtop; -} dfmstate; #define DFMIDTHRESHOLD 2 @@ -197,7 +200,7 @@ void DFM::finddfname(uint8_t *b) uint32_t v = (st<<20) | (d<<4) | ix; if ( st > (dfmstate.lastfrid>>20) ) { dfmstate.lastfrid = v; - Serial.print("MAXCH: "); Serial.println(st>>20); + Serial.print("MAXCH: "); Serial.println(st); dfmstate.lastfrcnt = 0; } else if ( st == (dfmstate.lastfrid>>20) ) { /* same id found */ @@ -253,9 +256,14 @@ void DFM::finddfname(uint8_t *b) Serial.print("] CNT:"); Serial.print(dfmstate.cnt[2*i]); Serial.print(","); - Serial.println(dfmstate.cnt[2*i+1]); - if(dfmstate.cnt[2*i]>DFMIDTHRESHOLD && dfmstate.cnt[2*i+1]>DFMIDTHRESHOLD) { - if(dfmstate.idcnt0 == 0) { + Serial.print(dfmstate.cnt[2*i+1]); + Serial.print(",st="); + Serial.print(st); + Serial.print(",lastfrid="); + Serial.println(dfmstate.lastfrid>>20); + if( (dfmstate.cnt[2*i]>DFMIDTHRESHOLD && dfmstate.cnt[2*i+1]>DFMIDTHRESHOLD) || + (dfmstate.cnt[2*1]>0 && dfmstate.cnt[2*i+1]>0 && st == (dfmstate.lastfrid>>20) && (st>>4)>6) ) { + if(dfmstate.idcnt0 <= 1) { dfmstate.idcnt0 = dfmstate.cnt[2*i]; dfmstate.idcnt1 = dfmstate.cnt[2*i+1]; dfmstate.nameregok = i; @@ -294,6 +302,8 @@ void DFM::decodeCFG(uint8_t *cfg) #if 1 // new ID finddfname(cfg); + // new aprs ID (dxlaprs, autorx) is now "D" + serial (8 digits) by consensus + memcpy(sonde.si()->ser, sonde.si()->id+1, 9); #else // old ID static int lowid, highid, idgood=0, type=0; diff --git a/libraries/SondeLib/Display.cpp b/libraries/SondeLib/Display.cpp index 7887116..210e566 100644 --- a/libraries/SondeLib/Display.cpp +++ b/libraries/SondeLib/Display.cpp @@ -30,6 +30,9 @@ SPIClass spiDisp(HSPI); const char *sondeTypeStr[NSondeTypes] = { "DFM6", "DFM9", "RS41", "RS92", "M10 " }; +#define TYPE_IS_DFM(t) ( (t)==STYPE_DFM06 || (t)==STYPE_DFM09 ) +#define TYPE_IS_METEO(t) ( (t)==STYPE_M10 ) + byte myIP_tiles[8*11]; static uint8_t ap_tile[8]={0x00,0x04,0x22,0x92, 0x92, 0x22, 0x04, 0x00}; @@ -455,10 +458,10 @@ void ILI9225Display::welcome() { setFont(5); int l=3*22; if(sonde.config.tft_orient&1) { - drawString(0, 1*22, "RS41/92,DFM6/9,M10"); + drawString(0, 1*22, "RS41/92,DFM,M10"); } else { drawString(0, 1*22, "RS41,RS92,"); - drawString(0, 2*22, "DFM6/9,M10"); + drawString(0, 2*22, "DFM,M10"); l+=22; } drawString(0, l, version_id); @@ -1029,24 +1032,24 @@ void Display::drawID(DispEntry *de) { drawString(de, "nnnnnnnn "); return; } - // TODO: handle DFM6 IDs - - if(!de->extra || de->extra[0]=='s') { - // real serial number, as printed on sonde + if(de->extra && de->extra[0]=='n') { + // real serial number, as printed on sonde, can be up to 11 digits long drawString(de, sonde.si()->ser); - } else if (de->extra[0]=='a') { - // autorx sonde number ("DF9" and last 6 digits of real serial number) - if(sonde.si()->type == STYPE_DFM09) { - int n = strlen(sonde.si()->ser) - 6; - if(n<0) n=0; - memcpy(buf, "DF9", 3); - memcpy(buf+3, sonde.si()->ser+n, 6); - drawString(de, buf); + } else if (de->extra && de->extra[0]=='s') { + // short ID, max 8 digits (no initial "D" for DFM, "M" instead of "ME" for M10) + if( TYPE_IS_DFM(sonde.si()->type) ) { + drawString(de, sonde.si()->id+1); + } else if (TYPE_IS_METEO(sonde.si()->type)) { + char sid[9]; + sid[0]='M'; + memcpy(sid+1, sonde.si()->id+2, 8); + sid[8] = 0; + drawString(de, sid); } else { - drawString(de, sonde.si()->ser); + drawString(de, sonde.si()->id); } } else { - // dxlAPRS sonde number (DF6 (why??) and 5 last digits of serial number as hex number + // dxlAPRS sonde number, max 9 digits, as used on aprs.fi and radiosondy.info drawString(de, sonde.si()->id); } }