From 35156948cb772f27daed96e7a1621bd514dfc904 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Mon, 28 Aug 2023 10:07:09 +0000 Subject: [PATCH] yet another fix for ftp eph --- RX_FSK/RX_FSK.ino | 1 + RX_FSK/src/Sonde.cpp | 5 ++++- RX_FSK/src/Sonde.h | 2 +- RX_FSK/src/geteph.cpp | 21 ++++++++++++--------- RX_FSK/version.h | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index d723e34..2ec0fa0 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -1692,6 +1692,7 @@ void setup() int v = gpio_get_level((gpio_num_t)i); Serial.printf("%d:%d ", i, v); } + Serial.printf("Test%1$s%1$s\n", "hello"); //NimBLEDevice::init("NimBLE-Arduino"); //NimBLEServer* pServer = NimBLEDevice::createServer();; diff --git a/RX_FSK/src/Sonde.cpp b/RX_FSK/src/Sonde.cpp index be54dd7..d3afe3b 100644 --- a/RX_FSK/src/Sonde.cpp +++ b/RX_FSK/src/Sonde.cpp @@ -28,6 +28,7 @@ const char *sondeTypeStr[NSondeTypes] = { "DFM ", "RS41", "RS92", "Mxx ", "M10 " const char *sondeTypeLongStr[NSondeTypes] = { "DFM (all)", "RS41", "RS92", "M10/M20", "M10 ", "M20 ", "MP3-H1" }; const char sondeTypeChar[NSondeTypes] = { 'D', '4', 'R', 'M', 'M', '2', '3' }; const char *manufacturer_string[]={"Graw", "Vaisala", "Vaisala", "Meteomodem", "Meteomodem", "Meteomodem", "Meteo-Radiy"}; +const char *DEFEPH="gssc.esa.int/gnss/data/daily/%1$04d/brdc/brdc%2$03d0.%3$02dn.gz"; int fingerprintValue[]={ 17, 31, 64, 4, 55, 48, 23, 128+23, 119, 128+119, -1 }; const char *fingerprintText[]={ @@ -258,7 +259,7 @@ void Sonde::defaultConfig() { config.tcpfeed.port = 12345; config.tcpfeed.highrate = 10; config.kisstnc.active = 0; - strcpy(config.ephftp,"igs.bkg.bund.de/IGS/BRDC/"); + strcpy(config.ephftp,DEFEPH); config.mqtt.active = 0; strcpy(config.mqtt.id, "rdz_sonde_server"); @@ -278,6 +279,8 @@ void Sonde::checkConfig() { if(config.sondehub.fimaxage>48) config.sondehub.fimaxage = 48; if(config.sondehub.fimaxdist==0) config.sondehub.fimaxdist = 150; if(config.sondehub.fimaxage==0) config.sondehub.fimaxage = 2; + // auto upgrade config to new version with format arguments in string + if(!strchr(sonde.config.ephftp,'%')) strcpy(sonde.config.ephftp,DEFEPH); } void Sonde::setConfig(const char *cfg) { while(*cfg==' '||*cfg=='\t') cfg++; diff --git a/RX_FSK/src/Sonde.h b/RX_FSK/src/Sonde.h index fa72f39..422d584 100644 --- a/RX_FSK/src/Sonde.h +++ b/RX_FSK/src/Sonde.h @@ -282,7 +282,7 @@ typedef struct st_rdzconfig { struct st_dfmconfig dfm; struct st_m10m20config m10m20; struct st_mp3hconfig mp3h; - char ephftp[40]; + char ephftp[80]; // data feed configuration // for now, one feed for each type is enough, but might get extended to more? char call[10]; // APRS callsign diff --git a/RX_FSK/src/geteph.cpp b/RX_FSK/src/geteph.cpp index 15fd2ca..6b55cf2 100644 --- a/RX_FSK/src/geteph.cpp +++ b/RX_FSK/src/geteph.cpp @@ -86,22 +86,25 @@ void geteph() { Serial.println("cannot open file\n"); return; } - char host[252]; - strcpy(host, sonde.config.ephftp); - char *buf = strchr(host, '/'); - if(!buf) { Serial.println("Invalid FTP host config"); return; } - *buf = 0; - buf++; + char host[100]; + char buf[200]; + char *ptr = strchr(sonde.config.ephftp, '/'); + if(!ptr) { Serial.println("Invalid FTP host config"); return; } + int hlen = ptr - sonde.config.ephftp; + strncpy(host, sonde.config.ephftp, hlen); + host[hlen] = 0; + snprintf(buf, 200, ptr+1, year, day, year-2000); uint8_t dispw, disph, dispxs, dispys; disp.rdis->getDispSize(&disph, &dispw, &dispxs, &dispys); disp.rdis->clear(); disp.rdis->setFont(FONT_SMALL); disp.rdis->drawString(0, 0, host); // fetch rinex from server - char *ptr = buf + strlen(buf); - snprintf(ptr, 128, "%04d/%03d/brdc%03d0.%02dn.gz", year, day, day, year-2000); + // char *ptr = buf + strlen(buf); + // snprintf(ptr, 128, "%04d/%03d/brdc%03d0.%02dn.gz", year, day, day, year-2000); + // snprintf(ptr, 128, "%04d/brdc/brdc%03d0.%02dn.gz", year, /*day,*/ day, year-2000); Serial.println("running geteph\n"); - disp.rdis->drawString(0, 1*dispys, ptr+9); + disp.rdis->drawString(0, 1*dispys, buf+9); if(!client.connect(host, 21)) { Serial.printf("FTP connection to %s failed\n", host); diff --git a/RX_FSK/version.h b/RX_FSK/version.h index 3c47cb2..75f3e19 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20230822"; +const char *version_id = "devel20230828"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=17;