From 61b733cf92fdeb4e786fa73be6acd445729308e4 Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Wed, 10 Jan 2024 23:00:07 +0100 Subject: [PATCH] GPS for Livemap tentative bugfix (not tested) --- RX_FSK/RX_FSK.ino | 29 +++++++++++++++++++++++------ RX_FSK/data/cfg.js | 2 +- RX_FSK/src/posinfo.cpp | 10 ++++++++-- RX_FSK/version.h | 2 +- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index dbd5021..3b86e18 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -398,6 +398,21 @@ void setupWifiList() { } } +// copy string, replacing '"' with '"' +// max string length is 31 characters +const String quoteString(const char *s) { + char buf[6*32]; + uint16_t i = 0, o = 0; + int len = strlen(s); + if(len>31) len=31; + while(iNrSSIDPassword"); for (int i = 0; i < MAX_WIFI; i++) { + String pw = i < nNetworks ? quoteString( networks[i].pw.c_str() ) : ""; sprintf(tmp, "%d", i); sprintf(ptr + strlen(ptr), "%s" "", i == 0 ? "AP" : tmp, i + 1, i < nNetworks ? networks[i].id.c_str() : "", - i + 1, i < nNetworks ? networks[i].pw.c_str() : ""); + i + 1, pw.c_str() ); } strcat(ptr, ""); //
"); @@ -1737,7 +1753,7 @@ void setup() // Make sure the whole thing powers up!?!?!?!?!? U8X8 *u8x8 = new U8X8_SSD1306_128X64_NONAME_HW_I2C(0, 22, 21); u8x8->initDisplay(); - delay(500); + delay(100); scanI2Cdevice(); @@ -1755,7 +1771,7 @@ void setup() } int ndevices = scanI2Cdevice(); if (sonde.fingerprint != 17 || ndevices > 0) break; // only retry for fingerprint 17 (startup problems of new t-beam with oled) - delay(500); + delay(100); } } } @@ -1875,7 +1891,6 @@ void setup() int i = 0; while (++i < 3) { - delay(500); // == check the radio chip by setting default frequency =========== // sx1278.ON(); if (sx1278.setFrequency(402700000) == 0) { @@ -1887,6 +1902,8 @@ void setup() Serial.print("Frequency set to "); Serial.println(f); // == check the radio chip by setting default frequency =========== // + if( f>402700000-1000 && f<402700000+1000 ) break; + delay(500); } #endif @@ -2485,7 +2502,7 @@ void loopWifiBackground() { WiFi.disconnect(true); } } else if (wifi_state == WIFI_CONNECTED) { - Serial.printf("status: %d\n", ((WiFiSTAClass)WiFi).status()); + //Serial.printf("status: %d\n", ((WiFiSTAClass)WiFi).status()); if (!WiFi.isConnected()) { sonde.setIP("", false); sonde.updateDisplayIP(); @@ -2493,7 +2510,7 @@ void loopWifiBackground() { wifi_state = WIFI_DISABLED; // restart scan enableNetwork(false); WiFi.disconnect(true); - } else Serial.println("WiFi still connected"); + } //else Serial.println("WiFi still connected"); } } diff --git a/RX_FSK/data/cfg.js b/RX_FSK/data/cfg.js index 3d9c9d1..a0df69e 100644 --- a/RX_FSK/data/cfg.js +++ b/RX_FSK/data/cfg.js @@ -1,6 +1,6 @@ var cfgs = [ [ "", "General configuration", "https://github.com/dl9rdz/rdz_ttgo_sonde/wiki/General-configuration" ], -[ "wifi", "Wifi mode (0=off, 1=client, 2=AP, 3=client or AP autoselect on startup)" ], +[ "wifi", "Wifi mode (0=off, 1=client, 2=AP, 3=client or AP, 4=client-noscan)" ], [ "mdnsname", "Network mDNS name"], [ "ephftp", "FTP server for ephemeris data (RS92 decoder)"], [ "debug", "Debug mode (0/1)" ], diff --git a/RX_FSK/src/posinfo.cpp b/RX_FSK/src/posinfo.cpp index bcc10a0..3884e8c 100644 --- a/RX_FSK/src/posinfo.cpp +++ b/RX_FSK/src/posinfo.cpp @@ -124,12 +124,18 @@ void gpsTask(void *parameter) { if(gpsPos.valid) { float d = fabs(gpsPos.lon - sonde.config.rxlon); d += fabs(gpsPos.lat - sonde.config.rxlat); - if(!posInfo.chase && d > AUTO_CHASE_THRESHOLD) { + // Activate GPS position tracking as soon as it is a bit away from home position + if(/*!posInfo.chase &&*/ d > AUTO_CHASE_THRESHOLD) { posInfo = gpsPos; posInfo.chase = 1; } else if ( posInfo.chase && d < AUTO_CHASE_THRESHOLD/2 ) { + // Stop GPS position tracking / chase mode as soon as it is very close to home (fixeedToPosInfo sets chase to 0) fixedToPosInfo(); - } + } else { + // Otherwise, continue tracking the GPS position + posInfo = gpsPos; + posInfo.chase = 1; + } } gpsPos.hdop = nmea.getHDOP(); diff --git a/RX_FSK/version.h b/RX_FSK/version.h index 2b7fa4f..63a55f6 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20240107"; +const char *version_id = "devel20240110"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=17;