sdcard and about tab refinements

This commit is contained in:
Hansi, dl9rdz 2024-08-14 09:58:47 +00:00
parent 82b0779c73
commit f1a8bff160
7 changed files with 83 additions and 24 deletions

View File

@ -63,6 +63,9 @@ Conn *connectors[] = { &connSystem,
#if FEATURE_SONDEHUB
&connSondehub,
#endif
#if FEATURE_CHASEMAPPER
&connChasemapper,
#endif
#if FEATURE_SDCARD
&connSDCard,
#endif
@ -2167,11 +2170,8 @@ void loopDecoder() {
#if FEATURE_APRS
connAPRS.updateSonde(s);
#endif
#if FEATURE_CHASEMAPPER
if (sonde.config.cm.active) {
connChasemapper.updateSonde( s );
}
connChasemapper.updateSonde( s );
#endif
}
#if FEATURE_SONDEHUB
@ -2184,7 +2184,9 @@ void loopDecoder() {
#if FEATURE_MQTT
connMQTT.updateSonde( s ); // send to MQTT if enabled
#endif
#if FEATURE_SDCARD
connSDCard.updateSonde(s);
#endif
} else {
#if FEATURE_SONDEHUB
connSondehub.updateSonde( NULL );
@ -2198,6 +2200,9 @@ void loopDecoder() {
#endif
#if FEATURE_APRS
connAPRS.updateStation( NULL );
#endif
#if FEATURE_SDCARD
connSDCard.updateStation( NULL );
#endif
// always send data, even if not valid....
if (rdzclient.connected()) {
@ -2315,7 +2320,7 @@ void startSpectrumDisplay() {
enterMode(ST_SPECTRUM);
}
String translateEncryptionType(wifi_auth_mode_t encryptionType) {
const char *translateEncryptionType(wifi_auth_mode_t encryptionType) {
switch (encryptionType) {
case (WIFI_AUTH_OPEN):
return "Open";
@ -2685,8 +2690,8 @@ void loopWifiScan() {
disp.rdis->drawString(0, dispys * (1 + line), ssid.c_str());
line = (line + 1) % (disph / dispys);
String mac = WiFi.BSSIDstr(i);
String encryptionTypeDescription = translateEncryptionType(WiFi.encryptionType(i));
Serial.printf("Network %s: RSSI %d, MAC %s, enc: %s\n", ssid.c_str(), WiFi.RSSI(i), mac.c_str(), encryptionTypeDescription.c_str());
const char *encryptionTypeDescription = translateEncryptionType(WiFi.encryptionType(i));
Serial.printf("Network %s: RSSI %d, MAC %s, enc: %s\n", ssid.c_str(), WiFi.RSSI(i), mac.c_str(), encryptionTypeDescription);
int curidx = fetchWifiIndex(ssid.c_str());
if (curidx >= 0 && index == -1) {
index = curidx;

View File

@ -72,10 +72,9 @@
<tbody id="status-body">
</tbody>
</table>
<p>RS92 RINEX eph state: %EPHSTATE%</p>
</div>
</div>
<div class="footer"><span></span><span class="ttgoinfo">rdzTTGOserver %VERSION_ID%</span></div>
</div>
</div>
<script>

View File

@ -28,7 +28,10 @@ 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";
// tiny library printf does not support $ parameters, so remove....
// for now, only urls with the right order of parameters are supported, this maybe will change in the future again.
//const char *DEFEPH="gssc.esa.int/gnss/data/daily/%1$04d/brdc/brdc%2$03d0.%3$02dn.gz";
const char *DEFEPH="gssc.esa.int/gnss/data/daily/%04d/brdc/brdc%03d0.%02dn.gz";
int fingerprintValue[]={ 17, 31, 64, 4, 55, 48, 23, 128+23, 119, 128+119, -1 };
const char *fingerprintText[]={
@ -295,6 +298,8 @@ void Sonde::checkConfig() {
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);
// $ not supported for now...
if(strchr(sonde.config.ephftp,'$')) strcpy(sonde.config.ephftp,DEFEPH);
switch(strlen(config.beaconsym)) {
case 0: case 1:
strcpy(config.beaconsym,"/`/("); // default: dish antenne, mobile sat station

View File

@ -318,12 +318,12 @@ error:
const char *aprsstate2str(int state) {
switch(state) {
case TCS_DISCONNECTED: return "Disconnected";
case TCS_DISCONNECTED: return "disconnected";
case TCS_DNSLOOKUP: return "DNS lookup";
case TCS_DNSRESOLVED: return "DNS resolved";
case TCS_CONNECTING: return "Connecting";
case TCS_LOGIN: return "Login";
case TCS_CONNECTED: return "Connected";
case TCS_CONNECTING: return "connecting";
case TCS_LOGIN: return "login";
case TCS_CONNECTED: return "connected";
default: return "??";
}
}
@ -338,7 +338,7 @@ String ConnAPRS::getStatus() {
else strlcat(buf, "KISS TNC: server active, idle<br>", 1024 );
// APRS client
if(sonde.config.tcpfeed.active==0) strlcat(buf, "APRS: disabled", 1024);
else snprintf( buf+strlen(buf), 1024-strlen(buf), "APRS: %s: %s", sonde.config.tcpfeed.host, aprsstate2str(tcpclient_state));
else snprintf( buf+strlen(buf), 1024-strlen(buf), "APRS: %s [%s]", aprsstate2str(tcpclient_state), sonde.config.tcpfeed.host);
return String(buf);
}

View File

@ -17,6 +17,9 @@ void ConnChasemapper::netsetup() {
void ConnChasemapper::updateSonde(SondeInfo *si) {
char buf[1024];
struct tm tim;
if(!sonde.config.cm.active) return;
time_t t = si->d.time;
gmtime_r(&t, &tim);
uint8_t realtype = si->type;
@ -65,7 +68,10 @@ void ConnChasemapper::updateStation(PosInfo *pi) {
}
String ConnChasemapper::getStatus() {
return String("");
if(!sonde.config.cm.active) return String("disabled");
char info[100];
snprintf(info, 100, "active [%s:%d]", sonde.config.cm.host, sonde.config.cm.port);
return String(info);
}
String ConnChasemapper::getName() {

View File

@ -3,12 +3,14 @@
#if FEATURE_SDCARD
#include "conn-sdcard.h"
#include "posinfo.h"
#include <dirent.h>
#include <time.h>
static SPIClass sdspi(HSPI);
char *cardTypeStr(uint8_t cardtype) {
const char *cardTypeStr(uint8_t cardtype) {
switch(cardtype) {
case CARD_NONE: return "No SD card attached";
case CARD_MMC: return "MMC";
@ -75,23 +77,38 @@ void ConnSDCard::netsetup() {
}
// Rotation by time or by id.
// only by id for now.
static char logName[20], logOldName[20] = {0};
static void is_to_logname(char *name, int maxlen, SondeData *sd) {
if(sd->validID) snprintf(name, maxlen, "/%s.csv", sd->ser);
else strncpy(name, "/noid.csv", maxlen);
}
void ConnSDCard::updateSonde( SondeInfo *si ) {
if (!initok) return;
if (!file) {
file = SD.open("/data.csv", FILE_APPEND);
SondeData *sd = &si->d;
is_to_logname(logName, 20, sd);
if(strcmp(logName, logOldName) || !file) {
if(file) file.close();
file = SD.open(logName, FILE_APPEND);
strcpy(logOldName, logName);
Serial.printf("Logging to file %s\n", logName);
}
if (!file) {
Serial.println("Error opening file");
return;
}
SondeData *sd = &si->d;
file.printf("%d,%s,%s,%d,"
"%f,%f,%f,%f,%f,%f,%d,%d,"
"%d,%d,%d,%d\n",
sd->validID, sd->ser, sd->typestr, sd->subtype,
sd->lat, sd->lon, sd->alt, sd->vs, sd->hs, sd->dir, sd->sats, sd->validPos,
sd->time, sd->frame, sd->vframe, sd->validTime);
// TODO: Make this time based, not invocation based (well, should be the same, this is called
// 1x per second)
wcount++;
if (wcount >= sonde.config.sd.sync) {
file.flush();
@ -99,8 +116,29 @@ void ConnSDCard::updateSonde( SondeInfo *si ) {
}
}
static StationPos lastPI={0};
// TODO: This needs some cleanup.
// Code uses global varuable posInfo, not this PosInfo paramter (also in aprs, sondehub)
void ConnSDCard::updateStation( PosInfo *pi ) {
if (!initok) return;
if( lastPI.lat == posInfo.lat && lastPI.lon == posInfo.lon) return;
File posfile = SD.open("/mypos.csv", FILE_APPEND);
if(!posfile) {
Serial.println("Error opening /mypos.csv");
return;
}
char ftim[50];
struct tm timeinfo;
time_t now;
time(&now);
gmtime_r(&now, &timeinfo);
strftime(ftim, 50, "%Y-%m-%dT%H:%M:%SZ", &timeinfo);
posfile.printf("%s,%.6f,%.6f\n", ftim, posInfo.lat, posInfo.lon);
posfile.close();
lastPI = posInfo;
}
String ConnSDCard::getStatus() {

View File

@ -1,7 +1,8 @@
#include "../features.h"
#include "conn-system.h"
#include <WiFi.h>
#include "geteph.h"
extern uint32_t netup_time;
@ -45,9 +46,14 @@ String ConnSystem::getStatus() {
uint16_t nup_s = nuptime - 60 * nup_m;
char buf[1024];
snprintf(buf, 1024, "Uptime: %0dd %02d:%02d:%02d, WiFi uptime: %0dd %02d:%02d:%02d <br> rdzwxGO app: %sconnected",
#if FEATURE_RS92
const char *rs92 = ephtxt[ephstate];
#else
const char *rs92 = "not supported in this version";
#endif
snprintf(buf, 1024, "Uptime: %0dd %02d:%02d:%02d, WiFi uptime: %0dd %02d:%02d:%02d <br> rdzwxGO app: %sconnected<br>RS92 RINEX eph state: %s",
up_d, up_h, up_m, up_s,
nup_d, nup_h, nup_m, nup_s, rdzclient.connected()?"":"not ");
nup_d, nup_h, nup_m, nup_s, rdzclient.connected()?"":"not ", rs92);
return String(buf);
}