From 2ca3cdf837ddf522522667402d94aa2796e5e4f2 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 20 Nov 2024 07:52:39 -0600 Subject: [PATCH 01/15] Fix RTC time injection and consolidate position logic (#5396) * Fix RTC time injection and consolidate position logic * Comment out unused var warning * Backerds --- src/mesh/NodeDB.cpp | 2 +- src/modules/PositionModule.cpp | 38 ++++++++++++++++++++-------------- src/modules/PositionModule.h | 1 + 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 55b8c0b4d..841a50d65 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -114,7 +114,7 @@ NodeDB::NodeDB() uint32_t channelFileCRC = crc32Buffer(&channelFile, sizeof(channelFile)); int saveWhat = 0; - bool hasUniqueId = false; + // bool hasUniqueId = false; // Get device unique id #if defined(ARCH_ESP32) && defined(ESP_EFUSE_OPTIONAL_UNIQUE_ID) uint32_t unique_id[4]; diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index fc15aabb6..d977cfdec 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -146,11 +146,20 @@ bool PositionModule::hasQualityTimesource() #if MESHTASTIC_EXCLUDE_GPS bool hasGpsOrRtc = (rtc_found.address != ScanI2C::ADDRESS_NONE.address); #else - bool hasGpsOrRtc = (gps && gps->isConnected()) || (rtc_found.address != ScanI2C::ADDRESS_NONE.address); + bool hasGpsOrRtc = hasGPS() || (rtc_found.address != ScanI2C::ADDRESS_NONE.address); #endif return hasGpsOrRtc || setFromPhoneOrNtpToday; } +bool PositionModule::hasGPS() +{ +#if MESHTASTIC_EXCLUDE_GPS + return false; +#else + return gps && gps->isConnected(); +#endif +} + meshtastic_MeshPacket *PositionModule::allocReply() { if (precision == 0) { @@ -194,10 +203,21 @@ meshtastic_MeshPacket *PositionModule::allocReply() p.precision_bits = precision; p.has_latitude_i = true; p.has_longitude_i = true; - p.time = getValidTime(RTCQualityNTP) > 0 ? getValidTime(RTCQualityNTP) : localPosition.time; + // Always use NTP / GPS time if available + if (getValidTime(RTCQualityNTP) > 0) { + p.time = getValidTime(RTCQualityNTP); + } else if (rtc_found.address != ScanI2C::ADDRESS_NONE.address) { + LOG_INFO("Use RTC time for position"); + p.time = getValidTime(RTCQualityDevice); + } else if (getRTCQuality() < RTCQualityNTP) { + LOG_INFO("Strip low RTCQuality (%d) time from position", getRTCQuality()); + p.time = 0; + } if (config.position.fixed_position) { p.location_source = meshtastic_Position_LocSource_LOC_MANUAL; + } else { + p.location_source = localPosition.location_source; } if (pos_flags & meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE) { @@ -242,20 +262,6 @@ meshtastic_MeshPacket *PositionModule::allocReply() p.has_ground_speed = true; } - // Strip out any time information before sending packets to other nodes - to keep the wire size small (and because other - // nodes shouldn't trust it anyways) Note: we allow a device with a local GPS or NTP to include the time, so that devices - // without can get time. - if (getRTCQuality() < RTCQualityNTP) { - LOG_INFO("Strip time %u from position", p.time); - p.time = 0; - } else if (rtc_found.address != ScanI2C::ADDRESS_NONE.address) { - LOG_INFO("Use RTC time %u for position", p.time); - p.time = getValidTime(RTCQualityDevice); - } else { - p.time = getValidTime(RTCQualityNTP); - LOG_INFO("Provide time to mesh %u", p.time); - } - LOG_INFO("Position reply: time=%i lat=%i lon=%i", p.time, p.latitude_i, p.longitude_i); // TAK Tracker devices should send their position in a TAK packet over the ATAK port diff --git a/src/modules/PositionModule.h b/src/modules/PositionModule.h index 41b86b795..1e4aa5d29 100644 --- a/src/modules/PositionModule.h +++ b/src/modules/PositionModule.h @@ -61,6 +61,7 @@ class PositionModule : public ProtobufModule, private concu uint32_t precision; void sendLostAndFoundText(); bool hasQualityTimesource(); + bool hasGPS(); const uint32_t minimumTimeThreshold = Default::getConfiguredOrDefaultMs(config.position.broadcast_smart_minimum_interval_secs, 30); From 154864dfbff306d93337435d74503f1ad59967e3 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:18:27 +0100 Subject: [PATCH 02/15] Update arduino-pico core to fix sporadic hangs (#5406) --- arch/rp2xx0/rp2040.ini | 4 ++-- arch/rp2xx0/rp2350.ini | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/rp2xx0/rp2040.ini b/arch/rp2xx0/rp2040.ini index 57e5d7bc2..031a4848f 100644 --- a/arch/rp2xx0/rp2040.ini +++ b/arch/rp2xx0/rp2040.ini @@ -2,7 +2,7 @@ [rp2040_base] platform = https://github.com/maxgerhardt/platform-raspberrypi.git#a606be683748c73e9a0d46baf70163478d298f0f ; For arduino-pico 4.2.0 extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#4.2.1 +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#996c3bfab9758f12c07aa20cc6d352e630c16987 ; 4.2.1 with fix for sporadic hangs board_build.core = earlephilhower board_build.filesystem_size = 0.5m @@ -23,4 +23,4 @@ lib_deps = ${arduino_base.lib_deps} ${environmental_base.lib_deps} ${radiolib_base.lib_deps} - rweather/Crypto + rweather/Crypto \ No newline at end of file diff --git a/arch/rp2xx0/rp2350.ini b/arch/rp2xx0/rp2350.ini index 58c5e5554..0ae184d00 100644 --- a/arch/rp2xx0/rp2350.ini +++ b/arch/rp2xx0/rp2350.ini @@ -2,7 +2,7 @@ [rp2350_base] platform = https://github.com/maxgerhardt/platform-raspberrypi.git#a606be683748c73e9a0d46baf70163478d298f0f ; For arduino-pico 4.2.0 extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#4.2.1 +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#96c3bfab9758f12c07aa20cc6d352e630c16987 ; 4.2.1 with fix for sporadic hangs board_build.core = earlephilhower board_build.filesystem_size = 0.5m @@ -22,4 +22,4 @@ lib_deps = ${arduino_base.lib_deps} ${environmental_base.lib_deps} ${radiolib_base.lib_deps} - rweather/Crypto + rweather/Crypto \ No newline at end of file From 364dead3aa4a1679dc9c80d599454aa739975557 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 20 Nov 2024 21:53:36 +0100 Subject: [PATCH 03/15] Update platform-raspberrypi also (#5407) * Update arduino-pico core to fix sporadic hangs * Update platform-raspberrypi also --- arch/rp2xx0/rp2040.ini | 2 +- arch/rp2xx0/rp2350.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/rp2xx0/rp2040.ini b/arch/rp2xx0/rp2040.ini index 031a4848f..85efa583c 100644 --- a/arch/rp2xx0/rp2040.ini +++ b/arch/rp2xx0/rp2040.ini @@ -1,6 +1,6 @@ ; Common settings for rp2040 Processor based targets [rp2040_base] -platform = https://github.com/maxgerhardt/platform-raspberrypi.git#a606be683748c73e9a0d46baf70163478d298f0f ; For arduino-pico 4.2.0 +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#19e30129fb1428b823be585c787dcb4ac0d9014c ; For arduino-pico 4.2.1 extends = arduino_base platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#996c3bfab9758f12c07aa20cc6d352e630c16987 ; 4.2.1 with fix for sporadic hangs diff --git a/arch/rp2xx0/rp2350.ini b/arch/rp2xx0/rp2350.ini index 0ae184d00..6daf59bdf 100644 --- a/arch/rp2xx0/rp2350.ini +++ b/arch/rp2xx0/rp2350.ini @@ -1,6 +1,6 @@ ; Common settings for rp2040 Processor based targets [rp2350_base] -platform = https://github.com/maxgerhardt/platform-raspberrypi.git#a606be683748c73e9a0d46baf70163478d298f0f ; For arduino-pico 4.2.0 +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#19e30129fb1428b823be585c787dcb4ac0d9014c ; For arduino-pico 4.2.1 extends = arduino_base platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#96c3bfab9758f12c07aa20cc6d352e630c16987 ; 4.2.1 with fix for sporadic hangs From 1752caaf19ca9ab65b0df8a192af4c50c344a4c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gjels=C3=B8?= <36234524+gjelsoe@users.noreply.github.com> Date: Thu, 21 Nov 2024 00:21:06 +0100 Subject: [PATCH 04/15] --web added to device-install(.sh/.bat) (#5405) * Add --web * Update device-install.bat Forgot a "-" a few places. --------- Co-authored-by: Ben Meadors --- bin/device-install.bat | 15 ++++++++++++--- bin/device-install.sh | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/bin/device-install.bat b/bin/device-install.bat index f8ca9e408..5e0f1c847 100755 --- a/bin/device-install.bat +++ b/bin/device-install.bat @@ -1,6 +1,7 @@ @ECHO OFF set PYTHON=python +set WEB_APP=0 :: Determine the correct esptool command to use where esptool >nul 2>&1 @@ -12,13 +13,14 @@ if %ERRORLEVEL% EQU 0 ( goto GETOPTS :HELP -echo Usage: %~nx0 [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME^|FILENAME] +echo Usage: %~nx0 [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME^|FILENAME] [--web] echo Flash image file to device, but first erasing and writing system information echo. echo -h Display this help and exit echo -p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerrous). echo -P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: %PYTHON%) echo -f FILENAME The .bin file to flash. Custom to your device type and region. +echo --web Flash WEB APP. goto EOF :GETOPTS @@ -27,6 +29,7 @@ if /I "%1"=="--help" goto HELP if /I "%1"=="-F" set "FILENAME=%2" & SHIFT if /I "%1"=="-p" set ESPTOOL_PORT=%2 & SHIFT if /I "%1"=="-P" set PYTHON=%2 & SHIFT +if /I "%1"=="--web" set WEB_APP=1 & SHIFT SHIFT IF NOT "__%1__"=="____" goto GETOPTS @@ -49,8 +52,14 @@ IF EXIST %FILENAME% IF x%FILENAME:update=%==x%FILENAME% ( ) else ( %ESPTOOL_CMD% --baud 115200 write_flash 0x260000 bleota-s3.bin ) - for %%f in (littlefs-*.bin) do ( - %ESPTOOL_CMD% --baud 115200 write_flash 0x300000 %%f + IF %WEB_APP%==1 ( + for %%f in (littlefsweb-*.bin) do ( + %ESPTOOL_CMD% --baud 115200 write_flash 0x300000 %%f + ) + ) else ( + for %%f in (littlefs-*.bin) do ( + %ESPTOOL_CMD% --baud 115200 write_flash 0x300000 %%f + ) ) ) else ( echo "Invalid file: %FILENAME%" diff --git a/bin/device-install.sh b/bin/device-install.sh index b2a5684ee..9cdf635d7 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -1,6 +1,7 @@ #!/bin/sh PYTHON=${PYTHON:-$(which python3 python | head -n 1)} +WEB_APP=false # Determine the correct esptool command to use if "$PYTHON" -m esptool version >/dev/null 2>&1; then @@ -19,16 +20,26 @@ set -e # Usage info show_help() { cat < Date: Thu, 21 Nov 2024 19:14:35 +0800 Subject: [PATCH 05/15] add GPS in indicator board (#5411) --- variants/seeed-sensecap-indicator/variant.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/variants/seeed-sensecap-indicator/variant.h b/variants/seeed-sensecap-indicator/variant.h index d7ed329eb..ab305422f 100644 --- a/variants/seeed-sensecap-indicator/variant.h +++ b/variants/seeed-sensecap-indicator/variant.h @@ -36,12 +36,13 @@ #define TOUCH_I2C_PORT 0 #define TOUCH_SLAVE_ADDRESS 0x48 -// Buzzer -#define PIN_BUZZER 19 +// in future, we may want to add a buzzer and add all sensors to the indicator via a data protocol for now only GPS is supported +// // Buzzer +// #define PIN_BUZZER 19 -#define HAS_GPS 0 -#undef GPS_RX_PIN -#undef GPS_TX_PIN +#define GPS_RX_PIN 20 +#define GPS_TX_PIN 19 +#define HAS_GPS 1 #define USE_SX1262 #define USE_SX1268 From fd98e9f55310a93160464cd350c0637b9fee1df6 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 21 Nov 2024 06:13:30 -0600 Subject: [PATCH 06/15] Fixed NMEA sentence issue in CalTopo as well as bug with no printing all of the nodes (#5412) --- src/gps/NMEAWPL.cpp | 2 +- src/modules/SerialModule.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gps/NMEAWPL.cpp b/src/gps/NMEAWPL.cpp index f528c4607..f4249ca62 100644 --- a/src/gps/NMEAWPL.cpp +++ b/src/gps/NMEAWPL.cpp @@ -23,7 +23,7 @@ uint32_t printWPL(char *buf, size_t bufsz, const meshtastic_PositionLite &pos, c { GeoCoord geoCoord(pos.latitude_i, pos.longitude_i, pos.altitude); char type = isCaltopoMode ? 'P' : 'N'; - uint32_t len = snprintf(buf, bufsz, "$G%cWPL,%02d%07.4f,%c,%03d%07.4f,%c,%s", type, geoCoord.getDMSLatDeg(), + uint32_t len = snprintf(buf, bufsz, "\r\n$G%cWPL,%02d%07.4f,%c,%03d%07.4f,%c,%s", type, geoCoord.getDMSLatDeg(), (abs(geoCoord.getLatitude()) - geoCoord.getDMSLatDeg() * 1e+7) * 6e-6, geoCoord.getDMSLatCP(), geoCoord.getDMSLonDeg(), (abs(geoCoord.getLongitude()) - geoCoord.getDMSLonDeg() * 1e+7) * 6e-6, geoCoord.getDMSLonCP(), name); diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index 32f9d9bc6..531be274e 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -204,9 +204,11 @@ int32_t SerialModule::runOnce() lastNmeaTime = millis(); uint32_t readIndex = 0; const meshtastic_NodeInfoLite *tempNodeInfo = nodeDB->readNextMeshNode(readIndex); - while (tempNodeInfo != NULL && tempNodeInfo->has_user && hasValidPosition(tempNodeInfo)) { - printWPL(outbuf, sizeof(outbuf), tempNodeInfo->position, tempNodeInfo->user.long_name, true); - serialPrint->printf("%s", outbuf); + while (tempNodeInfo != NULL) { + if (tempNodeInfo->has_user && hasValidPosition(tempNodeInfo)) { + printWPL(outbuf, sizeof(outbuf), tempNodeInfo->position, tempNodeInfo->user.long_name, true); + serialPrint->printf("%s", outbuf); + } tempNodeInfo = nodeDB->readNextMeshNode(readIndex); } } From 1089469f82f1f4ea39590c54f2b978844b938586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gjels=C3=B8?= <36234524+gjelsoe@users.noreply.github.com> Date: Thu, 21 Nov 2024 20:27:26 +0100 Subject: [PATCH 07/15] --web littlefswebui-* typo fix (#5416) * Add --web * Update device-install.bat Forgot a "-" a few places. * Typo fix. * Typo fix --------- Co-authored-by: Ben Meadors Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> --- bin/device-install.bat | 2 +- bin/device-install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/device-install.bat b/bin/device-install.bat index 5e0f1c847..c18be89a8 100755 --- a/bin/device-install.bat +++ b/bin/device-install.bat @@ -53,7 +53,7 @@ IF EXIST %FILENAME% IF x%FILENAME:update=%==x%FILENAME% ( %ESPTOOL_CMD% --baud 115200 write_flash 0x260000 bleota-s3.bin ) IF %WEB_APP%==1 ( - for %%f in (littlefsweb-*.bin) do ( + for %%f in (littlefswebui-*.bin) do ( %ESPTOOL_CMD% --baud 115200 write_flash 0x300000 %%f ) ) else ( diff --git a/bin/device-install.sh b/bin/device-install.sh index 9cdf635d7..e09c61ba6 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -85,7 +85,7 @@ if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then $ESPTOOL_CMD write_flash 0x260000 bleota-s3.bin fi if [ "$WEB_APP" = true ]; then - $ESPTOOL_CMD write_flash 0x300000 littlefsweb-*.bin + $ESPTOOL_CMD write_flash 0x300000 littlefswebui-*.bin else $ESPTOOL_CMD write_flash 0x300000 littlefs-*.bin fi From dbc5ec27f77cae59d465c60100506ffd092a3060 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:11:50 +0100 Subject: [PATCH 08/15] Temporarily disable MDNS when MQTT is enabled (#5418) Leads to a panic --- src/mesh/wifi/WiFiAPClient.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index 911a47093..779576d64 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -62,7 +62,11 @@ static void onNetworkConnected() LOG_INFO("Start WiFi network services"); // start mdns - if (!MDNS.begin("Meshtastic")) { + if ( +#ifdef ARCH_RP2040 + !moduleConfig.mqtt.enabled && // MDNS is not supported when MQTT is enabled on ARCH_RP2040 +#endif + !MDNS.begin("Meshtastic")) { LOG_ERROR("Error setting up MDNS responder!"); } else { LOG_INFO("mDNS Host: Meshtastic.local"); From f5058a9cbb76ad1a784f571666e6302d95565775 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 21 Nov 2024 14:52:54 -0600 Subject: [PATCH 09/15] Check for OkToMqtt flag presence before uplinking to MQTT (#5413) * Check for oktomqtt flag presence before uplinking to MQTT * Move to mqtt->onSend --- src/mqtt/MQTT.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 0e2710940..3d5948976 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -545,9 +545,11 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_Me // mp_decoded will not be decoded when it's PKI encrypted and not directed to us if (mp_decoded.which_payload_variant == meshtastic_MeshPacket_decoded_tag) { + // For uplinking other's packets, check if it's not OK to MQTT or if it's an older packet without the bitfield + bool dontUplink = !mp_decoded.decoded.has_bitfield || + (mp_decoded.decoded.has_bitfield && !(mp_decoded.decoded.bitfield & BITFIELD_OK_TO_MQTT_MASK)); // check for the lowest bit of the data bitfield set false, and the use of one of the default keys. - if (!isFromUs(&mp_decoded) && !isMqttServerAddressPrivate && mp_decoded.decoded.has_bitfield && - !(mp_decoded.decoded.bitfield & BITFIELD_OK_TO_MQTT_MASK) && + if (!isFromUs(&mp_decoded) && !isMqttServerAddressPrivate && dontUplink && (ch.settings.psk.size < 2 || (ch.settings.psk.size == 16 && memcmp(ch.settings.psk.bytes, defaultpsk, 16)) || (ch.settings.psk.size == 32 && memcmp(ch.settings.psk.bytes, eventpsk, 32)))) { LOG_INFO("MQTT onSend - Not forwarding packet due to DontMqttMeBro flag"); From d5bb32ff93d319d7add76e4b9f44c70bdbb88c39 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 21 Nov 2024 15:11:19 -0600 Subject: [PATCH 10/15] Temetry can respond to want-response for LocalStats variant (#5414) --- src/modules/Telemetry/DeviceTelemetry.cpp | 16 +++++++++++----- src/modules/Telemetry/DeviceTelemetry.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/modules/Telemetry/DeviceTelemetry.cpp b/src/modules/Telemetry/DeviceTelemetry.cpp index 1f479d6f1..4989b88e2 100644 --- a/src/modules/Telemetry/DeviceTelemetry.cpp +++ b/src/modules/Telemetry/DeviceTelemetry.cpp @@ -77,9 +77,10 @@ meshtastic_MeshPacket *DeviceTelemetryModule::allocReply() // Check for a request for device metrics if (decoded->which_variant == meshtastic_Telemetry_device_metrics_tag) { LOG_INFO("Device telemetry reply to request"); - - meshtastic_Telemetry telemetry = getDeviceTelemetry(); - return allocDataProtobuf(telemetry); + return allocDataProtobuf(getDeviceTelemetry()); + } else if (decoded->which_variant == meshtastic_Telemetry_local_stats_tag) { + LOG_INFO("Device telemetry reply w/ LocalStats to request"); + return allocDataProtobuf(getLocalStatsTelemetry()); } } return NULL; @@ -112,7 +113,7 @@ meshtastic_Telemetry DeviceTelemetryModule::getDeviceTelemetry() return t; } -void DeviceTelemetryModule::sendLocalStatsToPhone() +meshtastic_Telemetry DeviceTelemetryModule::getLocalStatsTelemetry() { meshtastic_Telemetry telemetry = meshtastic_Telemetry_init_zero; telemetry.which_variant = meshtastic_Telemetry_local_stats_tag; @@ -142,7 +143,12 @@ void DeviceTelemetryModule::sendLocalStatsToPhone() LOG_INFO("num_packets_tx=%i, num_packets_rx=%i, num_packets_rx_bad=%i", telemetry.variant.local_stats.num_packets_tx, telemetry.variant.local_stats.num_packets_rx, telemetry.variant.local_stats.num_packets_rx_bad); - meshtastic_MeshPacket *p = allocDataProtobuf(telemetry); + return telemetry; +} + +void DeviceTelemetryModule::sendLocalStatsToPhone() +{ + meshtastic_MeshPacket *p = allocDataProtobuf(getLocalStatsTelemetry()); p->to = NODENUM_BROADCAST; p->decoded.want_response = false; p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; diff --git a/src/modules/Telemetry/DeviceTelemetry.h b/src/modules/Telemetry/DeviceTelemetry.h index 29818d4eb..19b7d5b01 100644 --- a/src/modules/Telemetry/DeviceTelemetry.h +++ b/src/modules/Telemetry/DeviceTelemetry.h @@ -42,6 +42,8 @@ class DeviceTelemetryModule : private concurrency::OSThread, public ProtobufModu private: meshtastic_Telemetry getDeviceTelemetry(); + meshtastic_Telemetry getLocalStatsTelemetry(); + void sendLocalStatsToPhone(); uint32_t sendToPhoneIntervalMs = SECONDS_IN_MINUTE * 1000; // Send to phone every minute uint32_t sendStatsToPhoneIntervalMs = 15 * SECONDS_IN_MINUTE * 1000; // Send stats to phone every 15 minutes From e6fb6b115aebb12b31fb93ed9d1508a6109b2f03 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 22 Nov 2024 05:32:35 -0600 Subject: [PATCH 11/15] Seems like the last DIY board that's not "extra" (#5420) --- variants/diy/platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/variants/diy/platformio.ini b/variants/diy/platformio.ini index 00ff88da2..83e2175c8 100644 --- a/variants/diy/platformio.ini +++ b/variants/diy/platformio.ini @@ -2,6 +2,7 @@ [env:meshtastic-diy-v1] extends = esp32_base board = esp32doit-devkit-v1 +board_level = extra board_check = true build_flags = ${esp32_base.build_flags} From fdec95f9c1aae9c14b575580cec460a3942f6387 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 22 Nov 2024 14:25:09 -0600 Subject: [PATCH 12/15] Cherry pick tdeck fixes (#5422) * Try-fix (workaround) T-Deck audio crash * set T-Deck audio to unused 48 (mem mclk) * swap mclk to gpio 21 * dreamcatcher: assign GPIO44 to audio mclk --------- Co-authored-by: mverch67 --- src/AudioThread.h | 2 +- variants/dreamcatcher/platformio.ini | 2 +- variants/dreamcatcher/variant.h | 1 + variants/t-deck/platformio.ini | 2 +- variants/t-deck/variant.h | 1 + variants/t-watch-s3/platformio.ini | 2 +- variants/t-watch-s3/variant.h | 1 + 7 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/AudioThread.h b/src/AudioThread.h index bb23e8598..6d560ec55 100644 --- a/src/AudioThread.h +++ b/src/AudioThread.h @@ -64,7 +64,7 @@ class AudioThread : public concurrency::OSThread void initOutput() { audioOut = new AudioOutputI2S(1, AudioOutputI2S::EXTERNAL_I2S); - audioOut->SetPinout(DAC_I2S_BCK, DAC_I2S_WS, DAC_I2S_DOUT); + audioOut->SetPinout(DAC_I2S_BCK, DAC_I2S_WS, DAC_I2S_DOUT, DAC_I2S_MCLK); audioOut->SetGain(0.2); }; diff --git a/variants/dreamcatcher/platformio.ini b/variants/dreamcatcher/platformio.ini index 46f9b9871..c57849d96 100644 --- a/variants/dreamcatcher/platformio.ini +++ b/variants/dreamcatcher/platformio.ini @@ -11,7 +11,7 @@ build_flags = -DARDUINO_USB_CDC_ON_BOOT=1 lib_deps = ${esp32s3_base.lib_deps} - earlephilhower/ESP8266Audio@^1.9.7 + earlephilhower/ESP8266Audio@^1.9.9 earlephilhower/ESP8266SAM@^1.0.1 [env:dreamcatcher-2206] diff --git a/variants/dreamcatcher/variant.h b/variants/dreamcatcher/variant.h index eb95a95dd..7835979e1 100644 --- a/variants/dreamcatcher/variant.h +++ b/variants/dreamcatcher/variant.h @@ -60,6 +60,7 @@ #define DAC_I2S_BCK 21 #define DAC_I2S_WS 9 #define DAC_I2S_DOUT 48 +#define DAC_I2S_MCLK 44 #define BIAS_T_ENABLE 7 // needs to be low #define BIAS_T_VALUE 0 diff --git a/variants/t-deck/platformio.ini b/variants/t-deck/platformio.ini index a63ff57a7..16769e2f2 100644 --- a/variants/t-deck/platformio.ini +++ b/variants/t-deck/platformio.ini @@ -15,5 +15,5 @@ build_flags = ${esp32_base.build_flags} lib_deps = ${esp32s3_base.lib_deps} lovyan03/LovyanGFX@^1.1.9 - earlephilhower/ESP8266Audio@^1.9.7 + earlephilhower/ESP8266Audio@^1.9.9 earlephilhower/ESP8266SAM@^1.0.1 \ No newline at end of file diff --git a/variants/t-deck/variant.h b/variants/t-deck/variant.h index 9860d608f..6d398391e 100644 --- a/variants/t-deck/variant.h +++ b/variants/t-deck/variant.h @@ -73,6 +73,7 @@ #define DAC_I2S_BCK 7 #define DAC_I2S_WS 5 #define DAC_I2S_DOUT 6 +#define DAC_I2S_MCLK 21 // GPIO lrck mic // LoRa #define USE_SX1262 diff --git a/variants/t-watch-s3/platformio.ini b/variants/t-watch-s3/platformio.ini index 1f5fc278b..26d1b8fb3 100644 --- a/variants/t-watch-s3/platformio.ini +++ b/variants/t-watch-s3/platformio.ini @@ -14,5 +14,5 @@ lib_deps = ${esp32s3_base.lib_deps} lovyan03/LovyanGFX@^1.1.9 lewisxhe/PCF8563_Library@1.0.1 adafruit/Adafruit DRV2605 Library@^1.2.2 - earlephilhower/ESP8266Audio@^1.9.7 + earlephilhower/ESP8266Audio@^1.9.9 earlephilhower/ESP8266SAM@^1.0.1 \ No newline at end of file diff --git a/variants/t-watch-s3/variant.h b/variants/t-watch-s3/variant.h index 9f939d859..45bd5f23c 100644 --- a/variants/t-watch-s3/variant.h +++ b/variants/t-watch-s3/variant.h @@ -34,6 +34,7 @@ #define DAC_I2S_BCK 48 #define DAC_I2S_WS 15 #define DAC_I2S_DOUT 46 +#define DAC_I2S_MCLK 0 #define HAS_AXP2101 From c51a7b98bd2ffeaa5b18db52bb18d4f1838749ec Mon Sep 17 00:00:00 2001 From: dylanli Date: Sat, 23 Nov 2024 08:54:06 +0800 Subject: [PATCH 13/15] add canned message and keyboard in indicator board (#5410) * add canned message and keyboard in indicator board * Added virtual keyboard macro and enabled for Indicator * Cleanup macros by applying USE_VIRTUAL_KEYBOARD and DISPLAY_CLOCK_FRAME --------- Co-authored-by: Ben Meadors --- src/graphics/Screen.cpp | 6 ++--- src/graphics/Screen.h | 2 +- src/graphics/images.h | 2 +- src/mesh/NodeDB.cpp | 4 +-- src/modules/CannedMessageModule.cpp | 28 ++++++++++----------- src/modules/CannedMessageModule.h | 4 +-- variants/rak_wismeshtap/variant.h | 2 +- variants/seeed-sensecap-indicator/variant.h | 3 +++ variants/t-watch-s3/variant.h | 3 +++ 9 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index f18baf276..a875c11d6 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -396,7 +396,7 @@ static void drawBattery(OLEDDisplay *display, int16_t x, int16_t y, uint8_t *img display->drawFastImage(x, y, 16, 8, imgBuffer); } -#ifdef T_WATCH_S3 +#if defined(DISPLAY_CLOCK_FRAME) void Screen::drawWatchFaceToggleButton(OLEDDisplay *display, int16_t x, int16_t y, bool digitalMode, float scale) { @@ -2068,7 +2068,7 @@ void Screen::setFrames(FrameFocus focus) focus = FOCUS_FAULT; // Change our "focus" parameter, to ensure we show the fault frame } -#ifdef T_WATCH_S3 +#if defined(DISPLAY_CLOCK_FRAME) normalFrames[numframes++] = screen->digitalWatchFace ? &Screen::drawDigitalClockFrame : &Screen::drawAnalogClockFrame; #endif @@ -2699,7 +2699,7 @@ int Screen::handleUIFrameEvent(const UIFrameEvent *event) int Screen::handleInputEvent(const InputEvent *event) { -#ifdef T_WATCH_S3 +#if defined(DISPLAY_CLOCK_FRAME) // For the T-Watch, intercept touches to the 'toggle digital/analog watch face' button uint8_t watchFaceFrame = error_code ? 1 : 0; diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index ee8de69f0..2a77ca575 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -554,7 +554,7 @@ class Screen : public concurrency::OSThread static void drawDebugInfoWiFiTrampoline(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y); -#ifdef T_WATCH_S3 +#if defined(DISPLAY_CLOCK_FRAME) static void drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y); static void drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y); diff --git a/src/graphics/images.h b/src/graphics/images.h index fb6b176fc..b757dcf30 100644 --- a/src/graphics/images.h +++ b/src/graphics/images.h @@ -14,7 +14,7 @@ const uint8_t imgUser[] PROGMEM = {0x3C, 0x42, 0x99, 0xA5, 0xA5, 0x99, 0x42, 0x3 const uint8_t imgPositionEmpty[] PROGMEM = {0x20, 0x30, 0x28, 0x24, 0x42, 0xFF}; const uint8_t imgPositionSolid[] PROGMEM = {0x20, 0x30, 0x38, 0x3C, 0x7E, 0xFF}; -#ifdef T_WATCH_S3 +#if defined(DISPLAY_CLOCK_FRAME) const uint8_t bluetoothConnectedIcon[36] PROGMEM = {0xfe, 0x01, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0xe3, 0x1f, 0xf3, 0x3f, 0x33, 0x30, 0x33, 0x33, 0x33, 0x33, 0x03, 0x33, 0xff, 0x33, 0xfe, 0x31, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xf0, 0x3f, 0xe0, 0x1f}; diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 841a50d65..bd89261a3 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -503,7 +503,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false) #ifdef RAK4630 config.display.wake_on_tap_or_motion = true; #endif -#ifdef T_WATCH_S3 +#if defined(T_WATCH_S3) || defined(SENSECAP_INDICATOR) config.display.screen_on_secs = 30; config.display.wake_on_tap_or_motion = true; #endif @@ -527,7 +527,7 @@ void NodeDB::initConfigIntervals() config.display.screen_on_secs = default_screen_on_secs; -#if defined(T_WATCH_S3) || defined(T_DECK) || defined(RAK14014) +#if defined(T_WATCH_S3) || defined(T_DECK) || defined(RAK14014) || defined(SENSECAP_INDICATOR) config.power.is_power_saving = true; config.display.screen_on_secs = 30; config.power.wait_bluetooth_secs = 30; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 6d1bfdc5c..a96fcc080 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -55,7 +55,7 @@ CannedMessageModule::CannedMessageModule() LOG_INFO("CannedMessageModule is enabled"); // T-Watch interface currently has no way to select destination type, so default to 'node' -#if defined(T_WATCH_S3) || defined(RAK14014) +#if defined(USE_VIRTUAL_KEYBOARD) this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NODE; #endif @@ -81,7 +81,7 @@ int CannedMessageModule::splitConfiguredMessages() String canned_messages = cannedMessageModuleConfig.messages; -#if defined(T_WATCH_S3) || defined(RAK14014) +#if defined(USE_VIRTUAL_KEYBOARD) String separator = canned_messages.length() ? "|" : ""; canned_messages = "[---- Free Text ----]" + separator + canned_messages; @@ -150,7 +150,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) } if (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_SELECT)) { -#if defined(T_WATCH_S3) || defined(RAK14014) +#if defined(USE_VIRTUAL_KEYBOARD) if (this->currentMessageIndex == 0) { this->runState = CANNED_MESSAGE_RUN_STATE_FREETEXT; @@ -177,7 +177,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) e.action = UIFrameEvent::Action::REGENERATE_FRAMESET; // We want to change the list of frames shown on-screen this->currentMessageIndex = -1; -#if !defined(T_WATCH_S3) && !defined(RAK14014) +#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD) this->freetext = ""; // clear freetext this->cursor = 0; this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; @@ -190,7 +190,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) || (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT))) { -#if defined(T_WATCH_S3) || defined(RAK14014) +#if defined(USE_VIRTUAL_KEYBOARD) if (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_LEFT)) { this->payload = INPUT_BROKER_MSG_LEFT; } else if (event->inputEvent == static_cast(meshtastic_ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT)) { @@ -312,7 +312,7 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event) } } -#if defined(T_WATCH_S3) || defined(RAK14014) +#if defined(USE_VIRTUAL_KEYBOARD) if (this->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { String keyTapped = keyForCoordinates(event->touchX, event->touchY); @@ -446,7 +446,7 @@ int32_t CannedMessageModule::runOnce() this->freetext = ""; // clear freetext this->cursor = 0; -#if !defined(T_WATCH_S3) && !defined(RAK14014) +#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(SENSECAP_INDICATOR) this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; #endif @@ -459,7 +459,7 @@ int32_t CannedMessageModule::runOnce() this->freetext = ""; // clear freetext this->cursor = 0; -#if !defined(T_WATCH_S3) && !defined(RAK14014) +#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD) this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; #endif @@ -479,7 +479,7 @@ int32_t CannedMessageModule::runOnce() powerFSM.trigger(EVENT_PRESS); return INT32_MAX; } else { -#if defined(T_WATCH_S3) || defined(RAK14014) +#if defined(USE_VIRTUAL_KEYBOARD) sendText(this->dest, indexChannels[this->channel], this->messages[this->currentMessageIndex], true); #else sendText(NODENUM_BROADCAST, channels.getPrimaryIndex(), this->messages[this->currentMessageIndex], true); @@ -496,7 +496,7 @@ int32_t CannedMessageModule::runOnce() this->freetext = ""; // clear freetext this->cursor = 0; -#if !defined(T_WATCH_S3) && !defined(RAK14014) +#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD) this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; #endif @@ -513,7 +513,7 @@ int32_t CannedMessageModule::runOnce() this->freetext = ""; // clear freetext this->cursor = 0; -#if !defined(T_WATCH_S3) && !defined(RAK14014) +#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD) this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; #endif @@ -526,7 +526,7 @@ int32_t CannedMessageModule::runOnce() this->freetext = ""; // clear freetext this->cursor = 0; -#if !defined(T_WATCH_S3) && !defined(RAK14014) +#if !defined(T_WATCH_S3) && !defined(RAK14014) && !defined(USE_VIRTUAL_KEYBOARD) this->destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; #endif @@ -769,7 +769,7 @@ void CannedMessageModule::showTemporaryMessage(const String &message) setIntervalFromNow(2000); } -#if defined(T_WATCH_S3) || defined(RAK14014) +#if defined(USE_VIRTUAL_KEYBOARD) String CannedMessageModule::keyForCoordinates(uint x, uint y) { @@ -1055,7 +1055,7 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st display->drawString(10 + x, 0 + y + FONT_HEIGHT_SMALL, "Canned Message\nModule disabled."); } else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { requestFocus(); // Tell Screen::setFrames to move to our module's frame -#if defined(T_WATCH_S3) || defined(RAK14014) +#if defined(USE_VIRTUAL_KEYBOARD) drawKeyboard(display, state, 0, 0); #else diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index 4427be144..fd9ffc9b6 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -102,7 +102,7 @@ class CannedMessageModule : public SinglePortModule, public Observable Date: Sat, 23 Nov 2024 02:06:31 -0800 Subject: [PATCH 14/15] Update build-native.sh (#5415) * Update build-native.sh Device-install.sh and device-update.sh are not used on native platform, skip copying to release directory after build and copy native-install.sh and native-run.sh instead. * Update build-native.sh Skip native-run.sh copy --- bin/build-native.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/build-native.sh b/bin/build-native.sh index e8ed61bcf..cda77b064 100755 --- a/bin/build-native.sh +++ b/bin/build-native.sh @@ -27,5 +27,4 @@ rm -r $OUTDIR/* || true platformio pkg update --environment native || platformioFailed pio run --environment native || platformioFailed cp .pio/build/native/program "$OUTDIR/meshtasticd_linux_$(uname -m)" -cp bin/device-install.* $OUTDIR -cp bin/device-update.* $OUTDIR +cp bin/native-install.* $OUTDIR From fadcbd597fb8d8c2981fdc148e785d717c13c39c Mon Sep 17 00:00:00 2001 From: Christopher Hoover Date: Sat, 23 Nov 2024 04:10:09 -0800 Subject: [PATCH 15/15] Cleans up visibility in GPS.h (#5426) Signed-off-by: Christopher Hoover --- release/latest/.gitignore | 1 - src/gps/GPS.h | 196 +++++++++++++++++--------------------- 2 files changed, 90 insertions(+), 107 deletions(-) delete mode 100644 release/latest/.gitignore diff --git a/release/latest/.gitignore b/release/latest/.gitignore deleted file mode 100644 index fff416667..000000000 --- a/release/latest/.gitignore +++ /dev/null @@ -1 +0,0 @@ -curfirmwareversion.xml diff --git a/src/gps/GPS.h b/src/gps/GPS.h index cd61c5444..cb970f7db 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -64,6 +64,95 @@ const char *getDOPString(uint32_t dop); */ class GPS : private concurrency::OSThread { + public: + meshtastic_Position p = meshtastic_Position_init_default; + + /** This is normally bound to config.position.gps_en_gpio but some rare boards (like heltec tracker) need more advanced + * implementations. Those boards will set this public variable to a custom implementation. + * + * Normally set by GPS::createGPS() + */ + GpioVirtPin *enablePin = NULL; + + virtual ~GPS(); + + /** We will notify this observable anytime GPS state has changed meaningfully */ + Observable newStatus; + + /** + * Returns true if we succeeded + */ + virtual bool setup(); + + // re-enable the thread + void enable(); + + // Disable the thread + int32_t disable() override; + + // toggle between enabled/disabled + void toggleGpsMode(); + + // Change the power state of the GPS - for power saving / shutdown + void setPowerState(GPSPowerState newState, uint32_t sleepMs = 0); + + /// Returns true if we have acquired GPS lock. + virtual bool hasLock(); + + /// Returns true if there's valid data flow with the chip. + virtual bool hasFlow(); + + /// Return true if we are connected to a GPS + bool isConnected() const { return hasGPS; } + + bool isPowerSaving() const { return config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED; } + + // Empty the input buffer as quickly as possible + void clearBuffer(); + + virtual bool factoryReset(); + + // Creates an instance of the GPS class. + // Returns the new instance or null if the GPS is not present. + static GPS *createGps(); + + // Wake the GPS hardware - ready for an update + void up(); + + // Let the GPS hardware save power between updates + void down(); + + protected: + /// Record that we have a GPS + void setConnected(); + + /** Subclasses should look for serial rx characters here and feed it to their GPS parser + * + * Return true if we received a valid message from the GPS + */ + virtual bool whileActive(); + + /** + * Perform any processing that should be done only while the GPS is awake and looking for a fix. + * Override this method to check for new locations + * + * @return true if we've acquired a time + */ + virtual bool lookForTime(); + + /** + * Perform any processing that should be done only while the GPS is awake and looking for a fix. + * Override this method to check for new locations + * + * @return true if we've acquired a new location + */ + virtual bool lookForLocation(); + + GnssModel_t gnssModel = GNSS_MODEL_UNKNOWN; + + private: + GPS() : concurrency::OSThread("GPS") {} + TinyGPSPlus reader; uint8_t fixQual = 0; // fix quality from GPGGA uint32_t lastChecksumFailCount = 0; @@ -75,7 +164,6 @@ class GPS : private concurrency::OSThread TinyGPSCustom gsapdop; // custom extract PDOP from GPGSA uint8_t fixType = 0; // fix type from GPGSA #endif - private: #if GPS_BAUDRATE_FIXED // if GPS_BAUDRATE is specified in variant, only try that. const int serialSpeeds[1] = {GPS_BAUDRATE}; @@ -113,7 +201,6 @@ class GPS : private concurrency::OSThread CallbackObserver notifyDeepSleepObserver = CallbackObserver(this, &GPS::prepareDeepSleep); - public: /** If !NULL we will use this serial port to construct our GPS */ #if defined(ARCH_RP2040) static SerialUART *_serial_gps; @@ -167,53 +254,6 @@ class GPS : private concurrency::OSThread const char *ACK_SUCCESS_MESSAGE = "Get ack success!"; - meshtastic_Position p = meshtastic_Position_init_default; - - /** This is normally bound to config.position.gps_en_gpio but some rare boards (like heltec tracker) need more advanced - * implementations. Those boards will set this public variable to a custom implementation. - * - * Normally set by GPS::createGPS() - */ - GpioVirtPin *enablePin = NULL; - - GPS() : concurrency::OSThread("GPS") {} - - virtual ~GPS(); - - /** We will notify this observable anytime GPS state has changed meaningfully */ - Observable newStatus; - - /** - * Returns true if we succeeded - */ - virtual bool setup(); - - // re-enable the thread - void enable(); - - // Disable the thread - int32_t disable() override; - - // toggle between enabled/disabled - void toggleGpsMode(); - - // Change the power state of the GPS - for power saving / shutdown - void setPowerState(GPSPowerState newState, uint32_t sleepMs = 0); - - /// Returns true if we have acquired GPS lock. - virtual bool hasLock(); - - /// Returns true if there's valid data flow with the chip. - virtual bool hasFlow(); - - /// Return true if we are connected to a GPS - bool isConnected() const { return hasGPS; } - - bool isPowerSaving() const { return config.position.gps_mode != meshtastic_Config_PositionConfig_GpsMode_ENABLED; } - - // Empty the input buffer as quickly as possible - void clearBuffer(); - // Create a ublox packet for editing in memory uint8_t makeUBXPacket(uint8_t class_id, uint8_t msg_id, uint8_t payload_size, const uint8_t *msg); uint8_t makeCASPacket(uint8_t class_id, uint8_t msg_id, uint8_t payload_size, const uint8_t *msg); @@ -229,59 +269,6 @@ class GPS : private concurrency::OSThread GPS_RESPONSE getACKCas(uint8_t class_id, uint8_t msg_id, uint32_t waitMillis); - virtual bool factoryReset(); - - // Creates an instance of the GPS class. - // Returns the new instance or null if the GPS is not present. - static GPS *createGps(); - - // Wake the GPS hardware - ready for an update - void up(); - - // Let the GPS hardware save power between updates - void down(); - - protected: - /** - * Perform any processing that should be done only while the GPS is awake and looking for a fix. - * Override this method to check for new locations - * - * @return true if we've acquired a time - */ - - /** - * Perform any processing that should be done only while the GPS is awake and looking for a fix. - * Override this method to check for new locations - * - * @return true if we've acquired a new location - */ - - /// Record that we have a GPS - void setConnected(); - - /** Subclasses should look for serial rx characters here and feed it to their GPS parser - * - * Return true if we received a valid message from the GPS - */ - virtual bool whileActive(); - - /** - * Perform any processing that should be done only while the GPS is awake and looking for a fix. - * Override this method to check for new locations - * - * @return true if we've acquired a time - */ - virtual bool lookForTime(); - - /** - * Perform any processing that should be done only while the GPS is awake and looking for a fix. - * Override this method to check for new locations - * - * @return true if we've acquired a new location - */ - virtual bool lookForLocation(); - - private: /// Prepare the GPS for the cpu entering deep sleep, expect to be gone for at least 100s of msecs /// always returns 0 to indicate okay to sleep int prepareDeepSleep(void *unused); @@ -320,10 +307,7 @@ class GPS : private concurrency::OSThread uint8_t fixeddelayCtr = 0; const char *powerStateToString(); - - protected: - GnssModel_t gnssModel = GNSS_MODEL_UNKNOWN; }; extern GPS *gps; -#endif // Exclude GPS \ No newline at end of file +#endif // Exclude GPS