From 209fb585b0acb32f5785f29f84ef3a920ef590f8 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 30 Nov 2023 20:49:00 -0600 Subject: [PATCH 01/31] Default to what G2 comes with --- src/mesh/NodeDB.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 2e6c8131e..262a19263 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -248,6 +248,12 @@ void NodeDB::installDefaultModuleConfig() #ifdef T_WATCH_S3 // Don't worry about the other settings, we'll use the DRV2056 behavior for notifications moduleConfig.external_notification.enabled = true; +#endif +#ifdef NANO_G2_ULTRA + moduleConfig.external_notification.enabled = true; + moduleConfig.external_notification.alert_message = true; + moduleConfig.external_notification.output_ms = 100; + moduleConfig.external_notification.active true; #endif moduleConfig.has_canned_message = true; From a05bab35ad3b163871880c9d3c00dd53b7be8567 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 1 Dec 2023 07:17:38 -0600 Subject: [PATCH 02/31] = --- src/mesh/NodeDB.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index f2505bb0d..cb5c27b49 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -253,7 +253,7 @@ void NodeDB::installDefaultModuleConfig() moduleConfig.external_notification.enabled = true; moduleConfig.external_notification.alert_message = true; moduleConfig.external_notification.output_ms = 100; - moduleConfig.external_notification.active true; + moduleConfig.external_notification.active = true; #endif moduleConfig.has_canned_message = true; From 4c69d06ac05cd196d939d99d5d2b5444bef435eb Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Sat, 2 Dec 2023 12:30:00 +0000 Subject: [PATCH 03/31] Update Power.cpp (#2979) --- src/Power.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 0a56a1ba2..0fa97b7f0 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -435,7 +435,7 @@ void Power::shutdown() ledOff(PIN_LED2); #endif #ifdef PIN_LED3 - ledOff(PIN_LED2); + ledOff(PIN_LED3); #endif doDeepSleep(DELAY_FOREVER, false); #endif @@ -897,4 +897,4 @@ bool Power::axpChipInit() #else return false; #endif -} \ No newline at end of file +} From 1b6c11c5f1701f8a7cf04daadbfe82b2c386d7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 2 Dec 2023 14:00:20 +0100 Subject: [PATCH 04/31] tryfix crash (#2964) * tryfix crash * only use this when wifi is not enabled. (poking around) --------- Co-authored-by: Ben Meadors --- src/mesh/MeshService.cpp | 4 +++- src/nimble/NimbleBluetooth.cpp | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 44094f1bb..4fd9523c0 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -320,7 +320,9 @@ meshtastic_NodeInfoLite *MeshService::refreshLocalMeshNode() position.time = getValidTime(RTCQualityFromNet); - updateBatteryLevel(powerStatus->getBatteryChargePercent()); + if (powerStatus->getHasBattery() == 1) { + updateBatteryLevel(powerStatus->getBatteryChargePercent()); + } return node; } diff --git a/src/nimble/NimbleBluetooth.cpp b/src/nimble/NimbleBluetooth.cpp index 3175e0f09..0b2a806c9 100644 --- a/src/nimble/NimbleBluetooth.cpp +++ b/src/nimble/NimbleBluetooth.cpp @@ -186,7 +186,7 @@ void NimbleBluetooth::setupService() // Setup the battery service NimBLEService *batteryService = bleServer->createService(NimBLEUUID((uint16_t)0x180f)); // 0x180F is the Battery Service BatteryCharacteristic = batteryService->createCharacteristic( // 0x2A19 is the Battery Level characteristic) - (uint16_t)0x2a19, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY); + (uint16_t)0x2a19, NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY, 1); NimBLE2904 *batteryLevelDescriptor = (NimBLE2904 *)BatteryCharacteristic->createDescriptor((uint16_t)0x2904); batteryLevelDescriptor->setFormat(NimBLE2904::FORMAT_UINT8); @@ -208,8 +208,10 @@ void NimbleBluetooth::startAdvertising() /// Given a level between 0-100, update the BLE attribute void updateBatteryLevel(uint8_t level) { - BatteryCharacteristic->setValue(&level, 1); - BatteryCharacteristic->notify(); + if ((config.bluetooth.enabled == true) && bleServer && nimbleBluetooth->isConnected()) { + BatteryCharacteristic->setValue(&level, 1); + BatteryCharacteristic->notify(); + } } void NimbleBluetooth::clearBonds() From 2544733ad40769b8dec528309ae7d3c2459f8c2a Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Sat, 2 Dec 2023 13:40:31 +0000 Subject: [PATCH 05/31] Standardise order for setting GPIO pin default values (#2942) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update SX126xInterface.cpp * Update GPS.cpp * Update TFTDisplay.cpp * Update SX128xInterface.cpp * Update EInkDisplay2.cpp * trunk fmt --------- Co-authored-by: Ben Meadors Co-authored-by: Thomas Göttgens --- src/gps/GPS.cpp | 12 ++++++------ src/graphics/EInkDisplay2.cpp | 6 +++--- src/graphics/TFTDisplay.cpp | 8 ++++---- src/mesh/SX126xInterface.cpp | 2 +- src/mesh/SX128xInterface.cpp | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 7ea36c860..f51fb0588 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -495,14 +495,14 @@ void GPS::setGPSPower(bool on, bool standbyOnly, uint32_t sleepTime) #ifdef PIN_GPS_STANDBY // Specifically the standby pin for L76K and clones if (on) { LOG_INFO("Waking GPS"); - digitalWrite(PIN_GPS_STANDBY, 1); pinMode(PIN_GPS_STANDBY, OUTPUT); + digitalWrite(PIN_GPS_STANDBY, 1); return; } else { LOG_INFO("GPS entering sleep"); // notifyGPSSleep.notifyObservers(NULL); - digitalWrite(PIN_GPS_STANDBY, 0); pinMode(PIN_GPS_STANDBY, OUTPUT); + digitalWrite(PIN_GPS_STANDBY, 0); return; } #endif @@ -920,8 +920,8 @@ GPS *GPS::createGps() if (_en_gpio != 0) { LOG_DEBUG("Setting %d to output.\n", _en_gpio); - digitalWrite(_en_gpio, !GPS_EN_ACTIVE); pinMode(_en_gpio, OUTPUT); + digitalWrite(_en_gpio, !GPS_EN_ACTIVE); } #ifdef PIN_GPS_PPS @@ -941,8 +941,8 @@ GPS *GPS::createGps() new_gps->setGPSPower(true, false, 0); #ifdef PIN_GPS_RESET - digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE); // assert for 10ms pinMode(PIN_GPS_RESET, OUTPUT); + digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE); // assert for 10ms delay(10); digitalWrite(PIN_GPS_RESET, !GPS_RESET_MODE); #endif @@ -987,8 +987,8 @@ bool GPS::factoryReset() { #ifdef PIN_GPS_REINIT // The L76K GNSS on the T-Echo requires the RESET pin to be pulled LOW - digitalWrite(PIN_GPS_REINIT, 0); pinMode(PIN_GPS_REINIT, OUTPUT); + digitalWrite(PIN_GPS_REINIT, 0); delay(150); // The L76K datasheet calls for at least 100MS delay digitalWrite(PIN_GPS_REINIT, 1); #endif @@ -1268,4 +1268,4 @@ int32_t GPS::disable() setAwake(false); return INT32_MAX; -} \ No newline at end of file +} diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 61d0eea5a..3b97dd723 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -46,7 +46,7 @@ #define TECHO_DISPLAY_MODEL GxEPD2_154_M09 #elif defined(HELTEC_WIRELESS_PAPER) -//#define TECHO_DISPLAY_MODEL GxEPD2_213_T5D +// #define TECHO_DISPLAY_MODEL GxEPD2_213_T5D #define TECHO_DISPLAY_MODEL GxEPD2_213_BN #endif @@ -193,14 +193,14 @@ bool EInkDisplay::connect() LOG_INFO("Doing EInk init\n"); #ifdef PIN_EINK_PWR_ON - digitalWrite(PIN_EINK_PWR_ON, HIGH); // If we need to assert a pin to power external peripherals pinMode(PIN_EINK_PWR_ON, OUTPUT); + digitalWrite(PIN_EINK_PWR_ON, HIGH); // If we need to assert a pin to power external peripherals #endif #ifdef PIN_EINK_EN // backlight power, HIGH is backlight on, LOW is off - digitalWrite(PIN_EINK_EN, LOW); pinMode(PIN_EINK_EN, OUTPUT); + digitalWrite(PIN_EINK_EN, LOW); #endif #if defined(TTGO_T_ECHO) diff --git a/src/graphics/TFTDisplay.cpp b/src/graphics/TFTDisplay.cpp index 63db8120a..618880a5c 100644 --- a/src/graphics/TFTDisplay.cpp +++ b/src/graphics/TFTDisplay.cpp @@ -478,8 +478,8 @@ bool TFTDisplay::connect() LOG_INFO("Doing TFT init\n"); #ifdef TFT_BL - digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); pinMode(TFT_BL, OUTPUT); + digitalWrite(TFT_BL, TFT_BACKLIGHT_ON); // pinMode(PIN_3V3_EN, OUTPUT); // digitalWrite(PIN_3V3_EN, HIGH); LOG_INFO("Power to TFT Backlight\n"); @@ -487,11 +487,11 @@ bool TFTDisplay::connect() #ifdef ST7735_BACKLIGHT_EN_V03 if (heltec_version == 3) { - digitalWrite(ST7735_BACKLIGHT_EN_V03, TFT_BACKLIGHT_ON); pinMode(ST7735_BACKLIGHT_EN_V03, OUTPUT); + digitalWrite(ST7735_BACKLIGHT_EN_V03, TFT_BACKLIGHT_ON); } else { - digitalWrite(ST7735_BACKLIGHT_EN_V05, TFT_BACKLIGHT_ON); pinMode(ST7735_BACKLIGHT_EN_V05, OUTPUT); + digitalWrite(ST7735_BACKLIGHT_EN_V05, TFT_BACKLIGHT_ON); } #endif @@ -515,4 +515,4 @@ bool TFTDisplay::connect() return true; } -#endif \ No newline at end of file +#endif diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index 30951cd16..0692d1ef1 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -26,8 +26,8 @@ SX126xInterface::SX126xInterface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs template bool SX126xInterface::init() { #ifdef SX126X_POWER_EN - digitalWrite(SX126X_POWER_EN, HIGH); pinMode(SX126X_POWER_EN, OUTPUT); + digitalWrite(SX126X_POWER_EN, HIGH); #endif // FIXME: correct logic to default to not using TCXO if no voltage is specified for SX126X_DIO3_TCXO_VOLTAGE diff --git a/src/mesh/SX128xInterface.cpp b/src/mesh/SX128xInterface.cpp index 1916c8042..0c5c4dcfa 100644 --- a/src/mesh/SX128xInterface.cpp +++ b/src/mesh/SX128xInterface.cpp @@ -22,8 +22,8 @@ SX128xInterface::SX128xInterface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs template bool SX128xInterface::init() { #ifdef SX128X_POWER_EN - digitalWrite(SX128X_POWER_EN, HIGH); pinMode(SX128X_POWER_EN, OUTPUT); + digitalWrite(SX128X_POWER_EN, HIGH); #endif #ifdef RF95_FAN_EN @@ -32,12 +32,12 @@ template bool SX128xInterface::init() #endif #if defined(SX128X_RXEN) && (SX128X_RXEN != RADIOLIB_NC) // set not rx or tx mode - digitalWrite(SX128X_RXEN, LOW); // Set low before becoming an output pinMode(SX128X_RXEN, OUTPUT); + digitalWrite(SX128X_RXEN, LOW); // Set low before becoming an output #endif #if defined(SX128X_TXEN) && (SX128X_TXEN != RADIOLIB_NC) - digitalWrite(SX128X_TXEN, LOW); pinMode(SX128X_TXEN, OUTPUT); + digitalWrite(SX128X_TXEN, LOW); #endif RadioLibInterface::init(); From 9e90b4af027daa618ada9c7fa25043ac04d139e8 Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Sat, 2 Dec 2023 13:46:25 +0000 Subject: [PATCH 06/31] Update variant.h (#2930) Co-authored-by: Ben Meadors --- variants/diy/hydra/variant.h | 1 + 1 file changed, 1 insertion(+) diff --git a/variants/diy/hydra/variant.h b/variants/diy/hydra/variant.h index a51b21653..60bb60beb 100644 --- a/variants/diy/hydra/variant.h +++ b/variants/diy/hydra/variant.h @@ -18,6 +18,7 @@ // Radio #define USE_SX1262 // E22-900M30S uses SX1262 +#define USE_SX1268 // E22-400M30S uses SX1268 #define SX126X_MAX_POWER \ 22 // Outputting 22dBm from SX1262 results in ~30dBm E22-900M30S output (module only uses last stage of the YP2233W PA) #define SX126X_DIO3_TCXO_VOLTAGE 1.8 // E22 series TCXO reference voltage is 1.8V From 6ff61b3e04ec583f679db658772fe6ed37315e69 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sat, 2 Dec 2023 21:47:52 +0100 Subject: [PATCH 07/31] Pico W: Initial Wi-Fi support (#2980) * Pico W: Initial WiFi support: connects, but freezes after a while * Update arduino-pico core to fix hang with Wi-Fi * Add `picow` to workflow since it's different from `pico` now --- .github/workflows/main_matrix.yml | 1 + arch/nrf52/nrf52.ini | 2 +- arch/portduino/portduino.ini | 1 + arch/rp2040/rp2040.ini | 6 +- arch/stm32/stm32wl5e.ini | 2 +- src/graphics/Screen.cpp | 11 +- src/main.cpp | 11 +- src/mesh/NodeDB.cpp | 2 +- src/mesh/api/WiFiServerAPI.h | 2 +- src/mesh/http/ContentHandler.cpp | 2 +- src/mesh/http/ContentHandler.h | 3 +- src/mesh/http/ContentHelper.cpp | 4 +- src/mesh/http/WebServer.cpp | 4 +- src/mesh/{http => wifi}/WiFiAPClient.cpp | 194 +++++++++++++---------- src/mesh/{http => wifi}/WiFiAPClient.h | 4 +- src/modules/AdminModule.h | 6 +- src/mqtt/MQTT.cpp | 2 +- src/platform/esp32/main-esp32.cpp | 2 +- src/sleep.cpp | 2 +- variants/rpipicow/platformio.ini | 6 +- variants/rpipicow/variant.h | 6 +- 21 files changed, 154 insertions(+), 119 deletions(-) rename src/mesh/{http => wifi}/WiFiAPClient.cpp (94%) rename src/mesh/{http => wifi}/WiFiAPClient.h (79%) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 6b6ff1ad7..e53c35bd2 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -123,6 +123,7 @@ jobs: matrix: include: - board: pico + - board: picow - board: rak11310 uses: ./.github/workflows/build_rpi2040.yml with: diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 1a3631420..5da571cce 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -11,7 +11,7 @@ build_flags = -Isrc/platform/nrf52 build_src_filter = - ${arduino_base.build_src_filter} - - - - - - - - + ${arduino_base.build_src_filter} - - - - - - - - - lib_deps= ${arduino_base.lib_deps} diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 8b4ab5d4b..c4b6d5377 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -10,6 +10,7 @@ build_src_filter = - - - + - - - - diff --git a/arch/rp2040/rp2040.ini b/arch/rp2040/rp2040.ini index 38acde1e0..7674fbd52 100644 --- a/arch/rp2040/rp2040.ini +++ b/arch/rp2040/rp2040.ini @@ -1,8 +1,8 @@ ; Common settings for rp2040 Processor based targets [rp2040_base] -platform = https://github.com/maxgerhardt/platform-raspberrypi.git#0c33219f53faa035e188925ea1324f472e8b93d2 +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#612de5399d68b359053f1307ed223d400aea975c extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#3.2.2 +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#d2461a14ad5aa920e44508d236c2f459e3befbf8 board_build.core = earlephilhower board_build.filesystem_size = 0.5m @@ -12,7 +12,7 @@ build_flags = -D__PLAT_RP2040__ # -D _POSIX_THREADS build_src_filter = - ${arduino_base.build_src_filter} - - - - - - - - + ${arduino_base.build_src_filter} - - - - - - - - lib_ignore = BluetoothOTA diff --git a/arch/stm32/stm32wl5e.ini b/arch/stm32/stm32wl5e.ini index f563eec18..cac7110f2 100644 --- a/arch/stm32/stm32wl5e.ini +++ b/arch/stm32/stm32wl5e.ini @@ -13,7 +13,7 @@ build_flags = -DVECT_TAB_OFFSET=0x08000000 build_src_filter = - ${arduino_base.build_src_filter} - - - - - - - - - - - - + ${arduino_base.build_src_filter} - - - - - - - - - - - - - board_upload.offset_address = 0x08000000 upload_protocol = stlink diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 2e144e41a..e75a432d4 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -45,7 +45,7 @@ along with this program. If not, see . #ifdef ARCH_ESP32 #include "esp_task_wdt.h" -#include "mesh/http/WiFiAPClient.h" +#include "mesh/wifi/WiFiAPClient.h" #include "modules/esp32/StoreForwardModule.h" #endif @@ -1618,12 +1618,19 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Connection Failed"); } else if (WiFi.status() == WL_IDLE_STATUS) { display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Idle ... Reconnecting"); - } else { + } +#ifdef ARCH_ESP32 + else { // Codes: // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-reason-code display->drawString(x, y + FONT_HEIGHT_SMALL * 1, WiFi.disconnectReasonName(static_cast(getWifiDisconnectReason()))); } +#else + else { + display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Unkown status: " + String(WiFi.status())); + } +#endif display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); diff --git a/src/main.cpp b/src/main.cpp index 5cea142bc..b3671c020 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,9 +32,6 @@ #include // #include -#include "mesh/eth/ethClient.h" -#include "mesh/http/WiFiAPClient.h" - #ifdef ARCH_ESP32 #include "mesh/http/WebServer.h" #include "nimble/NimbleBluetooth.h" @@ -48,10 +45,12 @@ NRF52Bluetooth *nrf52Bluetooth; #if HAS_WIFI #include "mesh/api/WiFiServerAPI.h" +#include "mesh/wifi/WiFiAPClient.h" #endif #if HAS_ETHERNET #include "mesh/api/ethServerAPI.h" +#include "mesh/eth/ethClient.h" #endif #include "mqtt/MQTT.h" @@ -835,11 +834,15 @@ void setup() #ifndef ARCH_PORTDUINO // Initialize Wifi +#if HAS_WIFI initWifi(); +#endif +#if HAS_ETHERNET // Initialize Ethernet initEthernet(); #endif +#endif #ifdef ARCH_ESP32 // Start web server thread. @@ -938,4 +941,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} \ No newline at end of file +} diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index cb5c27b49..bb079e5c0 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -21,7 +21,7 @@ #include #ifdef ARCH_ESP32 -#include "mesh/http/WiFiAPClient.h" +#include "mesh/wifi/WiFiAPClient.h" #include "modules/esp32/StoreForwardModule.h" #include #include diff --git a/src/mesh/api/WiFiServerAPI.h b/src/mesh/api/WiFiServerAPI.h index 11b494d23..e436a177d 100644 --- a/src/mesh/api/WiFiServerAPI.h +++ b/src/mesh/api/WiFiServerAPI.h @@ -22,4 +22,4 @@ class WiFiServerPort : public APIServerPort explicit WiFiServerPort(int port); }; -void initApiServer(int port = 4403); +void initApiServer(int port = 4403); \ No newline at end of file diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 2ea2a76a5..4ca37a256 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -5,7 +5,7 @@ #include "main.h" #include "mesh/http/ContentHelper.h" #include "mesh/http/WebServer.h" -#include "mesh/http/WiFiAPClient.h" +#include "mesh/wifi/WiFiAPClient.h" #include "mqtt/JSON.h" #include "power.h" #include "sleep.h" diff --git a/src/mesh/http/ContentHandler.h b/src/mesh/http/ContentHandler.h index 903d5ee08..987e3ffef 100644 --- a/src/mesh/http/ContentHandler.h +++ b/src/mesh/http/ContentHandler.h @@ -1,5 +1,4 @@ #pragma once - void registerHandlers(HTTPServer *insecureServer, HTTPSServer *secureServer); // Declare some handler functions for the various URLs on the server @@ -34,4 +33,4 @@ class HttpAPI : public PhoneAPI protected: /// Check the current underlying physical link to see if the client is currently connected virtual bool checkIsConnected() override { return true; } // FIXME, be smarter about this -}; +}; \ No newline at end of file diff --git a/src/mesh/http/ContentHelper.cpp b/src/mesh/http/ContentHelper.cpp index 249dcbde6..8f283932b 100644 --- a/src/mesh/http/ContentHelper.cpp +++ b/src/mesh/http/ContentHelper.cpp @@ -1,6 +1,6 @@ #include "mesh/http/ContentHelper.h" -//#include -//#include "main.h" +// #include +// #include "main.h" void replaceAll(std::string &str, const std::string &from, const std::string &to) { diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index 2b045c0be..7814f2c29 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -2,7 +2,7 @@ #include "NodeDB.h" #include "graphics/Screen.h" #include "main.h" -#include "mesh/http/WiFiAPClient.h" +#include "mesh/wifi/WiFiAPClient.h" #include "sleep.h" #include #include @@ -210,4 +210,4 @@ void initWebServer() } else { LOG_ERROR("Web Servers Failed! ;-( \n"); } -} +} \ No newline at end of file diff --git a/src/mesh/http/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp similarity index 94% rename from src/mesh/http/WiFiAPClient.cpp rename to src/mesh/wifi/WiFiAPClient.cpp index cc8d4b168..06573fd60 100644 --- a/src/mesh/http/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -1,17 +1,22 @@ -#include "mesh/http/WiFiAPClient.h" +#include "mesh/wifi/WiFiAPClient.h" #include "NodeDB.h" #include "RTC.h" #include "concurrency/Periodic.h" #include "configuration.h" #include "main.h" #include "mesh/api/WiFiServerAPI.h" -#include "mesh/http/WebServer.h" #include "mqtt/MQTT.h" #include "target_specific.h" -#include #include #include +#ifndef ARCH_RP2040 +#include "mesh/http/WebServer.h" +#include #include +static void WiFiEvent(WiFiEvent_t event); +#else +#include +#endif #ifndef DISABLE_NTP #include @@ -19,8 +24,6 @@ using namespace concurrency; -static void WiFiEvent(WiFiEvent_t event); - // NTP WiFiUDP ntpUDP; @@ -44,78 +47,6 @@ Syslog syslog(syslogClient); Periodic *wifiReconnect; -static int32_t reconnectWiFi() -{ - const char *wifiName = config.network.wifi_ssid; - const char *wifiPsw = config.network.wifi_psk; - - if (config.network.wifi_enabled && needReconnect) { - - if (!*wifiPsw) // Treat empty password as no password - wifiPsw = NULL; - - needReconnect = false; - - // Make sure we clear old connection credentials - WiFi.disconnect(false, true); - LOG_INFO("Reconnecting to WiFi access point %s\n", wifiName); - - delay(5000); - - if (!WiFi.isConnected()) { - WiFi.begin(wifiName, wifiPsw); - } - } - -#ifndef DISABLE_NTP - if (WiFi.isConnected() && (((millis() - lastrun_ntp) > 43200000) || (lastrun_ntp == 0))) { // every 12 hours - LOG_DEBUG("Updating NTP time from %s\n", config.network.ntp_server); - if (timeClient.update()) { - LOG_DEBUG("NTP Request Success - Setting RTCQualityNTP if needed\n"); - - struct timeval tv; - tv.tv_sec = timeClient.getEpochTime(); - tv.tv_usec = 0; - - perhapsSetRTC(RTCQualityNTP, &tv); - lastrun_ntp = millis(); - - } else { - LOG_DEBUG("NTP Update failed\n"); - } - } -#endif - - if (config.network.wifi_enabled && !WiFi.isConnected()) { - return 1000; // check once per second - } else { - return 300000; // every 5 minutes - } -} - -bool isWifiAvailable() -{ - - if (config.network.wifi_enabled && (config.network.wifi_ssid[0])) { - return true; - } else { - return false; - } -} - -// Disable WiFi -void deinitWifi() -{ - LOG_INFO("WiFi deinit\n"); - - if (isWifiAvailable()) { - WiFi.disconnect(true); - WiFi.mode(WIFI_MODE_NULL); - LOG_INFO("WiFi Turned Off\n"); - // WiFi.printDiag(Serial); - } -} - static void onNetworkConnected() { if (!APStartupComplete) { @@ -158,7 +89,9 @@ static void onNetworkConnected() syslog.enable(); } +#ifndef ARCH_RP2040 initWebServer(); +#endif initApiServer(); APStartupComplete = true; @@ -169,6 +102,89 @@ static void onNetworkConnected() mqtt->reconnect(); } +static int32_t reconnectWiFi() +{ + const char *wifiName = config.network.wifi_ssid; + const char *wifiPsw = config.network.wifi_psk; + + if (config.network.wifi_enabled && needReconnect) { + + if (!*wifiPsw) // Treat empty password as no password + wifiPsw = NULL; + + needReconnect = false; + + // Make sure we clear old connection credentials +#ifdef ARCH_ESP32 + WiFi.disconnect(false, true); +#else + WiFi.disconnect(false); +#endif + LOG_INFO("Reconnecting to WiFi access point %s\n", wifiName); + + delay(5000); + + if (!WiFi.isConnected()) { + WiFi.begin(wifiName, wifiPsw); + } + } + +#ifndef DISABLE_NTP + if (WiFi.isConnected() && (((millis() - lastrun_ntp) > 43200000) || (lastrun_ntp == 0))) { // every 12 hours + LOG_DEBUG("Updating NTP time from %s\n", config.network.ntp_server); + if (timeClient.update()) { + LOG_DEBUG("NTP Request Success - Setting RTCQualityNTP if needed\n"); + + struct timeval tv; + tv.tv_sec = timeClient.getEpochTime(); + tv.tv_usec = 0; + + perhapsSetRTC(RTCQualityNTP, &tv); + lastrun_ntp = millis(); + + } else { + LOG_DEBUG("NTP Update failed\n"); + } + } +#endif + + if (config.network.wifi_enabled && !WiFi.isConnected()) { + return 1000; // check once per second + } else { +#ifdef ARCH_RP2040 + onNetworkConnected(); // will only do anything once +#endif + return 300000; // every 5 minutes + } +} + +bool isWifiAvailable() +{ + + if (config.network.wifi_enabled && (config.network.wifi_ssid[0])) { + return true; + } else { + return false; + } +} + +// Disable WiFi +void deinitWifi() +{ + LOG_INFO("WiFi deinit\n"); + + if (isWifiAvailable()) { +#ifdef ARCH_ESP32 + WiFi.disconnect(true, false); +#else + WiFi.disconnect(true); +#endif + WiFi.mode(WIFI_OFF); + LOG_INFO("WiFi Turned Off\n"); + // WiFi.printDiag(Serial); + } +} + // Startup WiFi bool initWifi() { @@ -177,10 +193,10 @@ bool initWifi() const char *wifiName = config.network.wifi_ssid; const char *wifiPsw = config.network.wifi_psk; - createSSLCert(); - +#ifndef ARCH_RP2040 + createSSLCert(); // For WebServer esp_wifi_set_storage(WIFI_STORAGE_RAM); // Disable flash storage for WiFi credentials - +#endif if (!*wifiPsw) // Treat empty password as no password wifiPsw = NULL; @@ -189,17 +205,17 @@ bool initWifi() getMacAddr(dmac); snprintf(ourHost, sizeof(ourHost), "Meshtastic-%02x%02x", dmac[4], dmac[5]); - WiFi.mode(WIFI_MODE_STA); + WiFi.mode(WIFI_STA); WiFi.setHostname(ourHost); - WiFi.onEvent(WiFiEvent); - WiFi.setAutoReconnect(true); - WiFi.setSleep(false); if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_STATIC && config.network.ipv4_config.ip != 0) { WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.gateway, config.network.ipv4_config.subnet, - config.network.ipv4_config.dns, - config.network.ipv4_config.dns); // Wifi wants two DNS servers... set both to the same value + config.network.ipv4_config.dns); } +#ifndef ARCH_RP2040 + WiFi.onEvent(WiFiEvent); + WiFi.setAutoReconnect(true); + WiFi.setSleep(false); // This is needed to improve performance. esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving @@ -218,7 +234,7 @@ bool initWifi() wifiDisconnectReason = info.wifi_sta_disconnected.reason; }, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED); - +#endif LOG_DEBUG("JOINING WIFI soon: ssid=%s\n", wifiName); wifiReconnect = new Periodic("WifiConnect", reconnectWiFi); } @@ -229,6 +245,7 @@ bool initWifi() } } +#ifndef ARCH_RP2040 // Called by the Espressif SDK to static void WiFiEvent(WiFiEvent_t event) { @@ -369,8 +386,9 @@ static void WiFiEvent(WiFiEvent_t event) break; } } +#endif uint8_t getWifiDisconnectReason() { return wifiDisconnectReason; -} +} \ No newline at end of file diff --git a/src/mesh/http/WiFiAPClient.h b/src/mesh/wifi/WiFiAPClient.h similarity index 79% rename from src/mesh/http/WiFiAPClient.h rename to src/mesh/wifi/WiFiAPClient.h index 0c08c567b..6625d3e46 100644 --- a/src/mesh/http/WiFiAPClient.h +++ b/src/mesh/wifi/WiFiAPClient.h @@ -5,7 +5,7 @@ #include #include -#ifdef ARCH_ESP32 +#if defined(HAS_WIFI) && !defined(ARCH_PORTDUINO) #include #endif @@ -19,4 +19,4 @@ void deinitWifi(); bool isWifiAvailable(); -uint8_t getWifiDisconnectReason(); +uint8_t getWifiDisconnectReason(); \ No newline at end of file diff --git a/src/modules/AdminModule.h b/src/modules/AdminModule.h index eb06e7b83..6ecc88829 100644 --- a/src/modules/AdminModule.h +++ b/src/modules/AdminModule.h @@ -1,7 +1,7 @@ #pragma once #include "ProtobufModule.h" -#ifdef ARCH_ESP32 -#include "mesh/http/WiFiAPClient.h" +#if HAS_WIFI +#include "mesh/wifi/WiFiAPClient.h" #endif /** @@ -50,4 +50,4 @@ class AdminModule : public ProtobufModule void reboot(int32_t seconds); }; -extern AdminModule *adminModule; +extern AdminModule *adminModule; \ No newline at end of file diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 29a634922..a97aa5255 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -7,9 +7,9 @@ #include "mesh/Router.h" #include "mesh/generated/meshtastic/mqtt.pb.h" #include "mesh/generated/meshtastic/telemetry.pb.h" -#include "mesh/http/WiFiAPClient.h" #include "sleep.h" #if HAS_WIFI +#include "mesh/wifi/WiFiAPClient.h" #include #endif #include "mqtt/JSON.h" diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 833e058d8..7da41512e 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -7,7 +7,7 @@ #include "nimble/NimbleBluetooth.h" #endif #include "BleOta.h" -#include "mesh/http/WiFiAPClient.h" +#include "mesh/wifi/WiFiAPClient.h" #include "meshUtils.h" #include "sleep.h" diff --git a/src/sleep.cpp b/src/sleep.cpp index b0f4aec88..464486d00 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -11,7 +11,7 @@ #ifdef ARCH_ESP32 #include "esp32/pm.h" #include "esp_pm.h" -#include "mesh/http/WiFiAPClient.h" +#include "mesh/wifi/WiFiAPClient.h" #include "rom/rtc.h" #include #include diff --git a/variants/rpipicow/platformio.ini b/variants/rpipicow/platformio.ini index 3228e4c24..4c8cf992d 100644 --- a/variants/rpipicow/platformio.ini +++ b/variants/rpipicow/platformio.ini @@ -8,8 +8,10 @@ upload_protocol = picotool build_flags = ${rp2040_base.build_flags} -DRPI_PICO -Ivariants/rpipicow - -DDEBUG_RP2040_PORT=Serial -DHW_SPI1_DEVICE -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" + -fexceptions # for exception handling in MQTT +build_src_filter = ${rp2040_base.build_src_filter} + lib_deps = - ${rp2040_base.lib_deps} \ No newline at end of file + ${rp2040_base.lib_deps} + ${networking_base.lib_deps} \ No newline at end of file diff --git a/variants/rpipicow/variant.h b/variants/rpipicow/variant.h index abbd1c465..c48b901ac 100644 --- a/variants/rpipicow/variant.h +++ b/variants/rpipicow/variant.h @@ -4,6 +4,10 @@ #define ARDUINO_ARCH_AVR +#ifndef HAS_WIFI +#define HAS_WIFI 1 +#endif + #define USE_SH1106 1 // default I2C pins: @@ -46,4 +50,4 @@ #define SX126X_RESET LORA_RESET #define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO3_TCXO_VOLTAGE 1.8 -#endif +#endif \ No newline at end of file From 31c4693c662dee0a6cab08db9ef9cfbad015ac0d Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 2 Dec 2023 15:50:17 -0600 Subject: [PATCH 08/31] Missed the version bump apparently --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 972a6f6de..8830a26a5 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 2 -build = 14 +build = 15 From 1f931a5e55a7a48ab62e2140d69e5ed6e0e9a3f3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 2 Dec 2023 17:19:29 -0600 Subject: [PATCH 09/31] [create-pull-request] automated change (#2981) Co-authored-by: thebentern --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 8830a26a5..c95d5701a 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 2 -build = 15 +build = 16 From 1c22d2c885194d267f4174eb8f6884ecc0f8af4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 3 Dec 2023 10:56:13 +0100 Subject: [PATCH 10/31] switch onebutton back to PIO registry, since they finally updated the lib there --- arch/stm32/stm32wl5e.ini | 2 +- platformio.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/stm32/stm32wl5e.ini b/arch/stm32/stm32wl5e.ini index cac7110f2..4e47be8c3 100644 --- a/arch/stm32/stm32wl5e.ini +++ b/arch/stm32/stm32wl5e.ini @@ -26,4 +26,4 @@ lib_deps = https://github.com/stm32duino/STM32FreeRTOS.git#10.3.1 lib_ignore = - https://github.com/mathertel/OneButton#2.1.0 \ No newline at end of file + mathertel/OneButton \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 451fe3f1a..f176823d1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -69,7 +69,7 @@ monitor_speed = 115200 lib_deps = https://github.com/meshtastic/esp8266-oled-ssd1306.git#b38094e03dfa964fbc0e799bc374e91a605c1223 ; ESP8266_SSD1306 - https://github.com/mathertel/OneButton#2.1.0 ; OneButton library for non-blocking button debounce + mathertel/OneButton@^2.5.0 ; OneButton library for non-blocking button debounce https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159 https://github.com/meshtastic/TinyGPSPlus.git#076e8d2c8fb702d9be5b08c55b93ff76f8af7e61 https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3 From 07fc5df9c1b46b98ee6c80bb71e021033add3751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 3 Dec 2023 13:02:14 +0100 Subject: [PATCH 11/31] update trunk and linters to latest version --- .trunk/trunk.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index e31b026f4..645d3863a 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,25 +1,25 @@ version: 0.1 cli: - version: 1.17.1 + version: 1.17.2 plugins: sources: - id: trunk - ref: v1.2.6 + ref: v1.3.0 uri: https://github.com/trunk-io/plugins lint: enabled: - bandit@1.7.5 - - checkov@3.0.16 - - terrascan@1.18.3 - - trivy@0.46.1 - - trufflehog@3.62.1 + - checkov@3.1.9 + - terrascan@1.18.5 + - trivy@0.47.0 + - trufflehog@3.63.2-rc0 - taplo@0.8.1 - - ruff@0.1.3 - - yamllint@1.32.0 + - ruff@0.1.6 + - yamllint@1.33.0 - isort@5.12.0 - markdownlint@0.37.0 - oxipng@9.0.0 - - svgo@3.0.2 + - svgo@3.0.5 - actionlint@1.6.26 - flake8@6.1.0 - hadolint@2.12.0 @@ -27,9 +27,9 @@ lint: - shellcheck@0.9.0 - black@23.9.1 - git-diff-check - - gitleaks@8.18.0 + - gitleaks@8.18.1 - clang-format@16.0.3 - - prettier@3.0.3 + - prettier@3.1.0 runtimes: enabled: - python@3.10.8 From 72b4fe51b104ea64277a2724abb70d867d0e4bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 4 Dec 2023 11:05:45 +0100 Subject: [PATCH 12/31] radiolib is stable just use one definition for all targets --- arch/esp32/esp32.ini | 1 - arch/nrf52/nrf52.ini | 1 - arch/portduino/portduino.ini | 1 - arch/rp2040/rp2040.ini | 1 - arch/stm32/stm32wl5e.ini | 1 - platformio.ini | 1 + 6 files changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini index db4b8e0b5..1f28ba6df 100644 --- a/arch/esp32/esp32.ini +++ b/arch/esp32/esp32.ini @@ -39,7 +39,6 @@ lib_deps = ${environmental_base.lib_deps} https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2 h2zero/NimBLE-Arduino@^1.4.1 - jgromes/RadioLib@^6.2.0 https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 https://github.com/meshtastic/ESP32_Codec2.git#633326c78ac251c059ab3a8c430fcdf25b41672f diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 5da571cce..04ca89a54 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -15,7 +15,6 @@ build_src_filter = lib_deps= ${arduino_base.lib_deps} - jgromes/RadioLib@^6.2.0 lib_ignore = BluetoothOTA \ No newline at end of file diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index c4b6d5377..5933850e7 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -23,7 +23,6 @@ lib_deps = ${env.lib_deps} ${networking_base.lib_deps} rweather/Crypto@^0.4.0 - jgromes/RadioLib@^6.1.0 build_flags = ${arduino_base.build_flags} diff --git a/arch/rp2040/rp2040.ini b/arch/rp2040/rp2040.ini index 7674fbd52..2190125fa 100644 --- a/arch/rp2040/rp2040.ini +++ b/arch/rp2040/rp2040.ini @@ -20,5 +20,4 @@ lib_ignore = lib_deps = ${arduino_base.lib_deps} ${environmental_base.lib_deps} - jgromes/RadioLib@^6.2.0 rweather/Crypto \ No newline at end of file diff --git a/arch/stm32/stm32wl5e.ini b/arch/stm32/stm32wl5e.ini index 4e47be8c3..4483ff526 100644 --- a/arch/stm32/stm32wl5e.ini +++ b/arch/stm32/stm32wl5e.ini @@ -20,7 +20,6 @@ upload_protocol = stlink lib_deps = ${env.lib_deps} - jgromes/RadioLib@^6.2.0 https://github.com/kokke/tiny-AES-c.git#f06ac37fc31dfdaca2e0d9bec83f90d5663c319b https://github.com/littlefs-project/littlefs.git#v2.5.1 https://github.com/stm32duino/STM32FreeRTOS.git#10.3.1 diff --git a/platformio.ini b/platformio.ini index f176823d1..d7ad05337 100644 --- a/platformio.ini +++ b/platformio.ini @@ -68,6 +68,7 @@ build_flags = -Wno-missing-field-initializers monitor_speed = 115200 lib_deps = + jgromes/RadioLib@^6.3.0 https://github.com/meshtastic/esp8266-oled-ssd1306.git#b38094e03dfa964fbc0e799bc374e91a605c1223 ; ESP8266_SSD1306 mathertel/OneButton@^2.5.0 ; OneButton library for non-blocking button debounce https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159 From 62329ad11f873da96c2512ef4b0a13d0747549e7 Mon Sep 17 00:00:00 2001 From: Ken McGuire Date: Mon, 4 Dec 2023 11:35:26 -0700 Subject: [PATCH 13/31] Fix typo in GNSS_MODEL defination and usages for the UC6580 (#2988) Correct the $CFGSYS init string for the UC6580 to init the receiver for: GPS L1 & L5 + BDS B1I & B2a + GLONASS L1 + GALILEO E1 & E5a + SBAS --- src/gps/GPS.cpp | 8 ++++---- src/gps/GPS.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index f51fb0588..afd8fb127 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -293,7 +293,7 @@ bool GPS::setup() gnssModel = GNSS_MODEL_UNKNOWN; } #else - gnssModel = GNSS_MODEL_UC6850; + gnssModel = GNSS_MODEL_UC6580; #endif if (gnssModel == GNSS_MODEL_MTK) { @@ -311,10 +311,10 @@ bool GPS::setup() // Switch to Vehicle Mode, since SoftRF enables Aviation < 2g _serial_gps->write("$PCAS11,3*1E\r\n"); delay(250); - } else if (gnssModel == GNSS_MODEL_UC6850) { + } else if (gnssModel == GNSS_MODEL_UC6580) { - // use GPS + GLONASS - _serial_gps->write("$CFGSYS,h15\r\n"); + // use GPS L1 & L5 + BDS B1I & B2a + GLONASS L1 + GALILEO E1 & E5a + SBAS + _serial_gps->write("$CFGSYS,h25155\r\n"); delay(250); } else if (gnssModel == GNSS_MODEL_UBLOX) { // Configure GNSS system to GPS+SBAS+GLONASS (Module may restart after this command) diff --git a/src/gps/GPS.h b/src/gps/GPS.h index d52c79182..4cbdae06b 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -23,7 +23,7 @@ struct uBloxGnssModelInfo { typedef enum { GNSS_MODEL_MTK, GNSS_MODEL_UBLOX, - GNSS_MODEL_UC6850, + GNSS_MODEL_UC6580, GNSS_MODEL_UNKNOWN, } GnssModel_t; From 46d02affe85ca8e2ea1c331ef3e325c619dad2be Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Mon, 4 Dec 2023 22:45:07 +0100 Subject: [PATCH 14/31] Pico W: Wi-Fi improvements (#2989) * Pico W: Initial WiFi support: connects, but freezes after a while * Update arduino-pico core to fix hang with Wi-Fi * Add `picow` to workflow since it's different from `pico` now * Show Wi-Fi frame on screen for all devices with Wi-Fi * Pico W: Disable mDNS as it's unsupported with FreeRTOS * Fix printing IP address * Fix Raspbian build --- src/graphics/Screen.cpp | 7 +++++-- src/mesh/wifi/WiFiAPClient.cpp | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index e75a432d4..417a6e454 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -43,9 +43,12 @@ along with this program. If not, see . #include "sleep.h" #include "target_specific.h" +#if HAS_WIFI && !defined(ARCH_RASPBERRY_PI) +#include "mesh/wifi/WiFiAPClient.h" +#endif + #ifdef ARCH_ESP32 #include "esp_task_wdt.h" -#include "mesh/wifi/WiFiAPClient.h" #include "modules/esp32/StoreForwardModule.h" #endif @@ -1294,7 +1297,7 @@ void Screen::setFrames() // call a method on debugInfoScreen object (for more details) normalFrames[numframes++] = &Screen::drawDebugInfoSettingsTrampoline; -#ifdef ARCH_ESP32 +#if HAS_WIFI && !defined(ARCH_RASPBERRY_PI) if (isWifiAvailable()) { // call a method on debugInfoScreen object (for more details) normalFrames[numframes++] = &Screen::drawDebugInfoWiFiTrampoline; diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index 06573fd60..fb29f54e3 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -9,13 +9,11 @@ #include "target_specific.h" #include #include -#ifndef ARCH_RP2040 +#ifdef ARCH_ESP32 #include "mesh/http/WebServer.h" #include #include static void WiFiEvent(WiFiEvent_t event); -#else -#include #endif #ifndef DISABLE_NTP @@ -53,6 +51,7 @@ static void onNetworkConnected() // Start web server LOG_INFO("Starting network services\n"); +#ifdef ARCH_ESP32 // start mdns if (!MDNS.begin("Meshtastic")) { LOG_ERROR("Error setting up MDNS responder!\n"); @@ -62,6 +61,9 @@ static void onNetworkConnected() MDNS.addService("http", "tcp", 80); MDNS.addService("https", "tcp", 443); } +#else // ESP32 handles this in WiFiEvent + LOG_INFO("Obtained IP address: %s\n", WiFi.localIP().toString().c_str()); +#endif #ifndef DISABLE_NTP LOG_INFO("Starting NTP time client\n"); @@ -89,7 +91,7 @@ static void onNetworkConnected() syslog.enable(); } -#ifndef ARCH_RP2040 +#ifdef ARCH_ESP32 initWebServer(); #endif initApiServer(); @@ -245,7 +247,7 @@ bool initWifi() } } -#ifndef ARCH_RP2040 +#ifdef ARCH_ESP32 // Called by the Espressif SDK to static void WiFiEvent(WiFiEvent_t event) { @@ -279,11 +281,11 @@ static void WiFiEvent(WiFiEvent_t event) LOG_INFO("Authentication mode of access point has changed\n"); break; case ARDUINO_EVENT_WIFI_STA_GOT_IP: - LOG_INFO("Obtained IP address: ", WiFi.localIPv6()); + LOG_INFO("Obtained IP address: %s\n", WiFi.localIP().toString().c_str()); onNetworkConnected(); break; case ARDUINO_EVENT_WIFI_STA_GOT_IP6: - LOG_INFO("Obtained IP6 address: %s", WiFi.localIPv6()); + LOG_INFO("Obtained IP6 address: %s\n", WiFi.localIPv6().toString().c_str()); break; case ARDUINO_EVENT_WIFI_STA_LOST_IP: LOG_INFO("Lost IP address and IP address is reset to 0\n"); @@ -391,4 +393,4 @@ static void WiFiEvent(WiFiEvent_t event) uint8_t getWifiDisconnectReason() { return wifiDisconnectReason; -} \ No newline at end of file +} From 89f0464233cce0949fb35494fa83053cb5b982b2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 06:17:50 -0600 Subject: [PATCH 15/31] [create-pull-request] automated change (#2991) Co-authored-by: thebentern --- protobufs | 2 +- src/mesh/generated/meshtastic/config.pb.h | 26 +++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/protobufs b/protobufs index 9148427a3..1eda884c3 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 9148427a3be535c9e3f17e846ecbb64ce04b6521 +Subproject commit 1eda884c3962b7647aa6a2a3f98a23568cfcff1e diff --git a/src/mesh/generated/meshtastic/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h index 53e92a948..8406dc887 100644 --- a/src/mesh/generated/meshtastic/config.pb.h +++ b/src/mesh/generated/meshtastic/config.pb.h @@ -43,7 +43,18 @@ typedef enum _meshtastic_Config_DeviceConfig_Role { Used for nodes dedicated for connection to an ATAK EUD. Turns off many of the routine broadcasts to favor CoT packet stream from the Meshtastic ATAK plugin -> IMeshService -> Node */ - meshtastic_Config_DeviceConfig_Role_TAK = 7 + meshtastic_Config_DeviceConfig_Role_TAK = 7, + /* Client Hidden device role + Used for nodes that "only speak when spoken to" + Turns all of the routine broadcasts but allows for ad-hoc communication + Still rebroadcasts, but with local only rebroadcast mode (known meshes only) + Can be used for clandestine operation or to dramatically reduce airtime / power consumption */ + meshtastic_Config_DeviceConfig_Role_CLIENT_HIDDEN = 8, + /* Lost and Found device role + Used to automatically send a text message to the mesh + with the current position of the device on a frequent interval: + "I'm lost! Position: lat / long" */ + meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND = 9 } meshtastic_Config_DeviceConfig_Role; /* Defines the device's behavior for how messages are rebroadcast */ @@ -56,7 +67,10 @@ typedef enum _meshtastic_Config_DeviceConfig_RebroadcastMode { meshtastic_Config_DeviceConfig_RebroadcastMode_ALL_SKIP_DECODING = 1, /* Ignores observed messages from foreign meshes that are open or those which it cannot decrypt. Only rebroadcasts message on the nodes local primary / secondary channels. */ - meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY = 2 + meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY = 2, + /* Ignores observed messages from foreign meshes like LOCAL_ONLY, + but takes it step further by also ignoring messages from nodenums not in the node's known list (NodeDB) */ + meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY = 3 } meshtastic_Config_DeviceConfig_RebroadcastMode; /* Bit field of boolean configuration options, indicating which optional @@ -479,12 +493,12 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_Config_DeviceConfig_Role_MIN meshtastic_Config_DeviceConfig_Role_CLIENT -#define _meshtastic_Config_DeviceConfig_Role_MAX meshtastic_Config_DeviceConfig_Role_TAK -#define _meshtastic_Config_DeviceConfig_Role_ARRAYSIZE ((meshtastic_Config_DeviceConfig_Role)(meshtastic_Config_DeviceConfig_Role_TAK+1)) +#define _meshtastic_Config_DeviceConfig_Role_MAX meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND +#define _meshtastic_Config_DeviceConfig_Role_ARRAYSIZE ((meshtastic_Config_DeviceConfig_Role)(meshtastic_Config_DeviceConfig_Role_LOST_AND_FOUND+1)) #define _meshtastic_Config_DeviceConfig_RebroadcastMode_MIN meshtastic_Config_DeviceConfig_RebroadcastMode_ALL -#define _meshtastic_Config_DeviceConfig_RebroadcastMode_MAX meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY -#define _meshtastic_Config_DeviceConfig_RebroadcastMode_ARRAYSIZE ((meshtastic_Config_DeviceConfig_RebroadcastMode)(meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY+1)) +#define _meshtastic_Config_DeviceConfig_RebroadcastMode_MAX meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY +#define _meshtastic_Config_DeviceConfig_RebroadcastMode_ARRAYSIZE ((meshtastic_Config_DeviceConfig_RebroadcastMode)(meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY+1)) #define _meshtastic_Config_PositionConfig_PositionFlags_MIN meshtastic_Config_PositionConfig_PositionFlags_UNSET #define _meshtastic_Config_PositionConfig_PositionFlags_MAX meshtastic_Config_PositionConfig_PositionFlags_SPEED From 28502a762fd02c42d528c76b2a9e10a776040a41 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 6 Dec 2023 14:02:41 -0600 Subject: [PATCH 16/31] Added Known-Only rebroadcast mode behavior (#2993) --- src/mesh/Router.cpp | 6 ++++++ src/modules/RoutingModule.cpp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index b2d8d585d..ff657fd11 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -299,6 +299,12 @@ bool perhapsDecode(meshtastic_MeshPacket *p) config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_ALL_SKIP_DECODING) return false; + if (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY && + !nodeDB.getMeshNode(p->from)->has_user) { + LOG_DEBUG("Node 0x%x not in NodeDB. Rebroadcast mode KNOWN_ONLY will ignore packet\n", p->from); + return false; + } + if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) return true; // If packet was already decoded just return diff --git a/src/modules/RoutingModule.cpp b/src/modules/RoutingModule.cpp index d81311481..edeb1fb86 100644 --- a/src/modules/RoutingModule.cpp +++ b/src/modules/RoutingModule.cpp @@ -46,5 +46,6 @@ void RoutingModule::sendAckNak(meshtastic_Routing_Error err, NodeNum to, PacketI RoutingModule::RoutingModule() : ProtobufModule("routing", meshtastic_PortNum_ROUTING_APP, &meshtastic_Routing_msg) { isPromiscuous = true; - encryptedOk = config.device.rebroadcast_mode != meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY; + encryptedOk = config.device.rebroadcast_mode != meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY && + config.device.rebroadcast_mode != meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY; } From b4ad6b0f418cf5b39ca4fc6721741ee8b0c14f03 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 6 Dec 2023 14:04:09 -0600 Subject: [PATCH 17/31] Added client-hidden role behavior (#2992) * Added client-hidden role behavior * Trunkt * That line got all boogered up --- src/mesh/NodeDB.cpp | 9 +++++++++ src/modules/NodeInfoModule.cpp | 2 +- src/modules/Telemetry/DeviceTelemetry.cpp | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index bb079e5c0..9c623d973 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -302,6 +302,15 @@ void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role) (meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE | meshtastic_Config_PositionConfig_PositionFlags_SPEED | meshtastic_Config_PositionConfig_PositionFlags_HEADING | meshtastic_Config_PositionConfig_PositionFlags_DOP); moduleConfig.telemetry.device_update_interval = ONE_DAY; + } else if (role == meshtastic_Config_DeviceConfig_Role_CLIENT_HIDDEN) { + config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_LOCAL_ONLY; + config.device.node_info_broadcast_secs = UINT32_MAX; + config.position.position_broadcast_smart_enabled = false; + config.position.position_broadcast_secs = UINT32_MAX; + moduleConfig.neighbor_info.update_interval = UINT32_MAX; + moduleConfig.telemetry.device_update_interval = UINT32_MAX; + moduleConfig.telemetry.environment_update_interval = UINT32_MAX; + moduleConfig.telemetry.air_quality_interval = UINT32_MAX; } } diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp index 855ba9cde..799f6ec7c 100644 --- a/src/modules/NodeInfoModule.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -89,7 +89,7 @@ int32_t NodeInfoModule::runOnce() bool requestReplies = currentGeneration != radioGeneration; currentGeneration = radioGeneration; - if (airTime->isTxAllowedAirUtil()) { + if (airTime->isTxAllowedAirUtil() && config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_HIDDEN) { LOG_INFO("Sending our nodeinfo to mesh (wantReplies=%d)\n", requestReplies); sendOurNodeInfo(NODENUM_BROADCAST, requestReplies); // Send our info (don't request replies) } diff --git a/src/modules/Telemetry/DeviceTelemetry.cpp b/src/modules/Telemetry/DeviceTelemetry.cpp index bc6c03c52..a6eecda80 100644 --- a/src/modules/Telemetry/DeviceTelemetry.cpp +++ b/src/modules/Telemetry/DeviceTelemetry.cpp @@ -18,7 +18,8 @@ int32_t DeviceTelemetryModule::runOnce() if (((lastSentToMesh == 0) || ((now - lastSentToMesh) >= getConfiguredOrDefaultMs(moduleConfig.telemetry.device_update_interval))) && airTime->isTxAllowedChannelUtil() && airTime->isTxAllowedAirUtil() && - config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER) { + config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER && + config.device.role != meshtastic_Config_DeviceConfig_Role_CLIENT_HIDDEN) { sendTelemetry(); lastSentToMesh = now; } else if (service.isToPhoneQueueEmpty()) { From ba021c97b2c3512b5552b3ee8671984fb905e42d Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Wed, 6 Dec 2023 22:49:56 +0100 Subject: [PATCH 18/31] Pico W: Handle Wi-Fi reconnects and update core (#2994) * Fix time lost on the Pico W right after NTP Shouldn't check for `#ifdef` as it will always be defined, but might be set to 0 * Handle reconnect for Wi-Fi on RP2040 * Update arduino-core for Wi-Fi + FreeRTOS fixes --------- Co-authored-by: Ben Meadors --- arch/rp2040/rp2040.ini | 2 +- src/gps/RTC.cpp | 4 ++-- src/mesh/wifi/WiFiAPClient.cpp | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/rp2040/rp2040.ini b/arch/rp2040/rp2040.ini index 2190125fa..48fe0dae6 100644 --- a/arch/rp2040/rp2040.ini +++ b/arch/rp2040/rp2040.ini @@ -2,7 +2,7 @@ [rp2040_base] platform = https://github.com/maxgerhardt/platform-raspberrypi.git#612de5399d68b359053f1307ed223d400aea975c extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#d2461a14ad5aa920e44508d236c2f459e3befbf8 +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#3.6.2 board_build.core = earlephilhower board_build.filesystem_size = 0.5m diff --git a/src/gps/RTC.cpp b/src/gps/RTC.cpp index ef438a7dd..10e9e0331 100644 --- a/src/gps/RTC.cpp +++ b/src/gps/RTC.cpp @@ -152,7 +152,7 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv) #endif // nrf52 doesn't have a readable RTC (yet - software not written) -#ifdef HAS_RTC +#if HAS_RTC readFromRTC(); #endif @@ -208,4 +208,4 @@ uint32_t getTime() uint32_t getValidTime(RTCQuality minQuality) { return (currentQuality >= minQuality) ? getTime() : 0; -} \ No newline at end of file +} diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index fb29f54e3..1e521e033 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -151,6 +151,11 @@ static int32_t reconnectWiFi() #endif if (config.network.wifi_enabled && !WiFi.isConnected()) { +#ifdef ARCH_RP2040 // (ESP32 handles this in WiFiEvent) + /* If APStartupComplete, but we're not connected, try again. + Shouldn't try again before APStartupComplete. */ + needReconnect = APStartupComplete; +#endif return 1000; // check once per second } else { #ifdef ARCH_RP2040 From 17f1a450b29a3799874b2411f73f6890bef139c0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:14:41 -0600 Subject: [PATCH 19/31] [create-pull-request] automated change (#2995) Co-authored-by: thebentern --- protobufs | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/protobufs b/protobufs index 1eda884c3..a34b2c680 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 1eda884c3962b7647aa6a2a3f98a23568cfcff1e +Subproject commit a34b2c680e2c1c240643c515e57c5532b29c91a7 diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 59005db48..ae80b3fe5 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -67,6 +67,10 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_STATION_G1 = 25, /* RAK11310 (RP2040 + SX1262) */ meshtastic_HardwareModel_RAK11310 = 26, + /* Makerfabs SenseLoRA Receiver (RP2040 + RFM96) */ + meshtastic_HardwareModel_SENSELORA_RP2040 = 27, + /* Makerfabs SenseLoRA Industrial Monitor (ESP32-S3 + RFM96) */ + meshtastic_HardwareModel_SENSELORA_S3 = 28, /* --------------------------------------------------------------------------- Less common/prototype boards listed here (needs one more byte over the air) --------------------------------------------------------------------------- */ From 9188a9a1f27afb89cfd591a0d137e21e500d60d6 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 6 Dec 2023 21:42:06 -0600 Subject: [PATCH 20/31] Makersense RP2040 support (#2996) * WIP * Do the right things * Add to build matrix * Yaml lint has annoyed me for the final time --- .github/workflows/main_matrix.yml | 1 + .trunk/trunk.yaml | 1 - src/platform/esp32/architecture.h | 4 +++ src/platform/rp2040/architecture.h | 2 ++ variants/senselora_rp2040/platformio.ini | 14 +++++++++ variants/senselora_rp2040/variant.h | 38 ++++++++++++++++++++++++ 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 variants/senselora_rp2040/platformio.ini create mode 100644 variants/senselora_rp2040/variant.h diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index e53c35bd2..9f1de95c5 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -125,6 +125,7 @@ jobs: - board: pico - board: picow - board: rak11310 + - board: senselora_rp2040 uses: ./.github/workflows/build_rpi2040.yml with: board: ${{ matrix.board }} diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 645d3863a..da8face9a 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -15,7 +15,6 @@ lint: - trufflehog@3.63.2-rc0 - taplo@0.8.1 - ruff@0.1.6 - - yamllint@1.33.0 - isort@5.12.0 - markdownlint@0.37.0 - oxipng@9.0.0 diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 0686aa59f..451d7ffbe 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -121,6 +121,10 @@ #define HW_VENDOR meshtastic_HardwareModel_PICOMPUTER_S3 #elif defined(HELTEC_HT62) #define HW_VENDOR meshtastic_HardwareModel_HELTEC_HT62 +#elif defined(SENSELORA_S3) +#define HW_VENDOR meshtastic_HardwareModel_SENSELORA_S3 +#elif defined(HELTEC_HT62) +#define HW_VENDOR meshtastic_HardwareModel_HELTEC_HT62 #endif // ----------------------------------------------------------------------------- diff --git a/src/platform/rp2040/architecture.h b/src/platform/rp2040/architecture.h index 762a2dc83..61eb1bbe8 100644 --- a/src/platform/rp2040/architecture.h +++ b/src/platform/rp2040/architecture.h @@ -25,4 +25,6 @@ #define HW_VENDOR meshtastic_HardwareModel_RPI_PICO #elif defined(RAK11310) #define HW_VENDOR meshtastic_HardwareModel_RAK11310 +#elif defined(SENSELORA_RP2040) +#define HW_VENDOR meshtastic_HardwareModel_SENSELORA_RP2040 #endif \ No newline at end of file diff --git a/variants/senselora_rp2040/platformio.ini b/variants/senselora_rp2040/platformio.ini new file mode 100644 index 000000000..abf28559e --- /dev/null +++ b/variants/senselora_rp2040/platformio.ini @@ -0,0 +1,14 @@ +[env:senselora_rp2040] +extends = rp2040_base +board = rpipico +upload_protocol = picotool + +# add our variants files to the include and src paths +build_flags = ${rp2040_base.build_flags} + -DSENSELORA_RP2040 + -Ivariants/rpipico + -DDEBUG_RP2040_PORT=Serial + -DHW_SPI1_DEVICE + -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" +lib_deps = + ${rp2040_base.lib_deps} \ No newline at end of file diff --git a/variants/senselora_rp2040/variant.h b/variants/senselora_rp2040/variant.h new file mode 100644 index 000000000..78f3e8f14 --- /dev/null +++ b/variants/senselora_rp2040/variant.h @@ -0,0 +1,38 @@ +// #define RADIOLIB_CUSTOM_ARDUINO 1 +// #define RADIOLIB_TONE_UNSUPPORTED 1 +// #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED 1 + +#define ARDUINO_ARCH_AVR + +#define USE_SSD1306 1 + +#define BUTTON_PIN 2 + +#define I2C_SDA1 6 +#define I2C_SCL1 7 + +#define PIN_SPI_MISO (16u) +#define PIN_SPI_MOSI (19u) +#define PIN_SPI_SCK (18u) +#define PIN_SPI_SS (17u) + +#define LED_PIN PIN_LED + +#undef BATTERY_PIN + +#undef LORA_SCK +#undef LORA_MISO +#undef LORA_MOSI +#undef LORA_CS + +#define USE_RF95 +#define LORA_SCK PIN_SPI_SCK +#define LORA_MISO PIN_SPI_MISO +#define LORA_MOSI PIN_SPI_MOSI +#define LORA_CS PIN_SPI_SS + +#define LORA_DIO0 21 +#define LORA_DIO1 22 +#define LORA_DIO2 23 +#define LORA_DIO5 24 +#define LORA_RST 20 From a54e3826e97e0cc9680d4f85eeda19bc5af7e50d Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 7 Dec 2023 07:14:41 -0600 Subject: [PATCH 21/31] Remove truffle-hog tool for now since it's breaking CI --- .trunk/trunk.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index da8face9a..81a35f8f1 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -12,7 +12,7 @@ lint: - checkov@3.1.9 - terrascan@1.18.5 - trivy@0.47.0 - - trufflehog@3.63.2-rc0 + #- trufflehog@3.63.2-rc0 - taplo@0.8.1 - ruff@0.1.6 - isort@5.12.0 From 8f57cfaaf494662664552d7c84c10440fa2acfe4 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 7 Dec 2023 17:12:51 -0600 Subject: [PATCH 22/31] Makersense rp2040 variant fixes (#2997) * WIP * Do the right things * Add to build matrix * Yaml lint has annoyed me for the final time * Fixes to variant --- variants/senselora_rp2040/pins_arduino.h | 50 ++++++++++++++++++++++++ variants/senselora_rp2040/platformio.ini | 3 +- variants/senselora_rp2040/variant.h | 28 ++++--------- 3 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 variants/senselora_rp2040/pins_arduino.h diff --git a/variants/senselora_rp2040/pins_arduino.h b/variants/senselora_rp2040/pins_arduino.h new file mode 100644 index 000000000..bb0ee637e --- /dev/null +++ b/variants/senselora_rp2040/pins_arduino.h @@ -0,0 +1,50 @@ +#pragma once + +#define PIN_A0 (26u) +#define PIN_A1 (27u) +#define PIN_A2 (28u) +#define PIN_A3 (29u) + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; + +// LEDs +#define PIN_LED (23u) +#define PIN_LED1 PIN_LED +#define LED_BUILTIN PIN_LED + +#define ADC_RESOLUTION 12 + +// Serial +#define PIN_SERIAL1_TX (0ul) +#define PIN_SERIAL1_RX (1ul) + +#define PIN_SERIAL2_TX (4ul) +#define PIN_SERIAL2_RX (5ul) + +// SPI +#define PIN_SPI0_MISO (16u) +#define PIN_SPI0_MOSI (19u) +#define PIN_SPI0_SCK (18u) +#define PIN_SPI0_SS (17u) + +// Wire +#define PIN_WIRE0_SDA (6u) +#define PIN_WIRE0_SCL (7u) + +#define PIN_WIRE1_SDA (-1) +#define PIN_WIRE1_SCL (-1) + +#define SERIAL_HOWMANY (3u) +#define SPI_HOWMANY (2u) +#define WIRE_HOWMANY (1u) + +static const uint8_t SS = PIN_SPI0_SS; +static const uint8_t MOSI = PIN_SPI0_MOSI; +static const uint8_t MISO = PIN_SPI0_MISO; +static const uint8_t SCK = PIN_SPI0_SCK; + +static const uint8_t SDA = PIN_WIRE0_SDA; +static const uint8_t SCL = PIN_WIRE0_SCL; \ No newline at end of file diff --git a/variants/senselora_rp2040/platformio.ini b/variants/senselora_rp2040/platformio.ini index abf28559e..3b3253ee8 100644 --- a/variants/senselora_rp2040/platformio.ini +++ b/variants/senselora_rp2040/platformio.ini @@ -6,9 +6,8 @@ upload_protocol = picotool # add our variants files to the include and src paths build_flags = ${rp2040_base.build_flags} -DSENSELORA_RP2040 - -Ivariants/rpipico + -Ivariants/senselora_rp2040 -DDEBUG_RP2040_PORT=Serial - -DHW_SPI1_DEVICE -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} \ No newline at end of file diff --git a/variants/senselora_rp2040/variant.h b/variants/senselora_rp2040/variant.h index 78f3e8f14..9eda65521 100644 --- a/variants/senselora_rp2040/variant.h +++ b/variants/senselora_rp2040/variant.h @@ -1,20 +1,9 @@ -// #define RADIOLIB_CUSTOM_ARDUINO 1 -// #define RADIOLIB_TONE_UNSUPPORTED 1 -// #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED 1 - #define ARDUINO_ARCH_AVR -#define USE_SSD1306 1 +#define USE_SSD1306 #define BUTTON_PIN 2 - -#define I2C_SDA1 6 -#define I2C_SCL1 7 - -#define PIN_SPI_MISO (16u) -#define PIN_SPI_MOSI (19u) -#define PIN_SPI_SCK (18u) -#define PIN_SPI_SS (17u) +#define BUTTON_NEED_PULLUP #define LED_PIN PIN_LED @@ -26,13 +15,12 @@ #undef LORA_CS #define USE_RF95 -#define LORA_SCK PIN_SPI_SCK -#define LORA_MISO PIN_SPI_MISO -#define LORA_MOSI PIN_SPI_MOSI -#define LORA_CS PIN_SPI_SS +#define LORA_SCK PIN_SPI0_SCK +#define LORA_MISO PIN_SPI0_MISO +#define LORA_MOSI PIN_SPI0_MOSI +#define LORA_CS PIN_SPI0_SS #define LORA_DIO0 21 #define LORA_DIO1 22 -#define LORA_DIO2 23 -#define LORA_DIO5 24 -#define LORA_RST 20 +#define LORA_DIO2 RADIOLIB_NC +#define LORA_RESET 20 \ No newline at end of file From 8ea19d665af8142ecd661b96bc14c37b4423776f Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 7 Dec 2023 20:22:22 -0600 Subject: [PATCH 23/31] Update pull-request-artifacts --- .github/workflows/main_matrix.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 9f1de95c5..a3ea7dbb0 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -285,14 +285,14 @@ jobs: - name: Create request artifacts continue-on-error: true # FIXME: Why are we getting 502, but things still work? if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'pull_request' }} - uses: gavv/pull-request-artifacts@v1.1.0 + uses: gavv/pull-request-artifacts@v2.1.0 with: commit: ${{ (github.event.pull_request_target || github.event.pull_request).head.sha }} repo-token: ${{ secrets.GITHUB_TOKEN }} artifacts-token: ${{ secrets.ARTIFACTS_TOKEN }} artifacts-repo: meshtastic/artifacts artifacts-branch: device - artifacts-dir: pr + artifacts-prefix: pr artifacts: ./firmware-${{ steps.version.outputs.version }}.zip release-artifacts: From 671112f47d79a2ec7c778ca1cd635bcdc84922fb Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 7 Dec 2023 21:22:30 -0600 Subject: [PATCH 24/31] Update pull-request-artifacts config --- .github/workflows/main_matrix.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index a3ea7dbb0..056938b90 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -212,6 +212,13 @@ jobs: repository: ${{github.event.pull_request.head.repo.full_name}} gather-artifacts: + permissions: + # Required to upload/save artifact, otherwise you'll get + # "Error: Resource not accessible by integration" + contents: write + # Required to post comment, otherwise you'll get + # "Error: Resource not accessible by integration" + pull-requests: write runs-on: ubuntu-latest needs: [ @@ -292,7 +299,6 @@ jobs: artifacts-token: ${{ secrets.ARTIFACTS_TOKEN }} artifacts-repo: meshtastic/artifacts artifacts-branch: device - artifacts-prefix: pr artifacts: ./firmware-${{ steps.version.outputs.version }}.zip release-artifacts: From 5eac227550accac64f89a53d22b04c5f4bd1f883 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 7 Dec 2023 21:29:04 -0600 Subject: [PATCH 25/31] Fix whitespace in workflow --- .github/workflows/main_matrix.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 056938b90..a2aa11288 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -213,12 +213,8 @@ jobs: gather-artifacts: permissions: - # Required to upload/save artifact, otherwise you'll get - # "Error: Resource not accessible by integration" - contents: write - # Required to post comment, otherwise you'll get - # "Error: Resource not accessible by integration" - pull-requests: write + contents: write + pull-requests: write runs-on: ubuntu-latest needs: [ From abaa37133d503a9b5732064bdddbef71fbf7300c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 8 Dec 2023 11:13:15 -0600 Subject: [PATCH 26/31] Repeater and other power optimizations (#2999) * End wire if we find no i2c devices * Set tx-power to 0 on nrf bluetooth shutdown * Change polling interval of PowerFSM to 100ms instead of 10ms * Guard 3v3 --- src/PowerFSMThread.h | 2 +- src/main.cpp | 20 +++++++++++++++----- src/platform/nrf52/NRF52Bluetooth.cpp | 3 ++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/PowerFSMThread.h b/src/PowerFSMThread.h index 541522f43..b757f3abb 100644 --- a/src/PowerFSMThread.h +++ b/src/PowerFSMThread.h @@ -33,7 +33,7 @@ class PowerFSMThread : public OSThread powerFSM.trigger(EVENT_SHUTDOWN); } - return 10; + return 100; } }; diff --git a/src/main.cpp b/src/main.cpp index b3671c020..c8fc61e4c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -432,6 +432,10 @@ void setup() auto i2cCount = i2cScanner->countDevices(); if (i2cCount == 0) { LOG_INFO("No I2C devices found\n"); + Wire.end(); +#ifdef I2C_SDA1 + Wire1.end(); +#endif } else { LOG_INFO("%i I2C devices found\n", i2cCount); } @@ -576,10 +580,13 @@ void setup() // but we need to do this after main cpu init (esp32setup), because we need the random seed set nodeDB.init(); - // If we're taking on the repeater role, use flood router - if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) + // If we're taking on the repeater role, use flood router and turn off 3V3_S rail because peripherals are not needed + if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) { router = new FloodingRouter(); - else +#ifdef PIN_3V3_EN + digitalWrite(PIN_3V3_EN, LOW); +#endif + } else router = new ReliableRouter(); #if HAS_BUTTON || defined(ARCH_RASPBERRY_PI) @@ -653,7 +660,10 @@ void setup() readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time) - gps = GPS::createGps(); + // If we're taking on the repeater role, ignore GPS + if (config.device.role != meshtastic_Config_DeviceConfig_Role_REPEATER) { + gps = GPS::createGps(); + } if (gps) { gpsStatus->observe(&gps->newStatus); } else { @@ -941,4 +951,4 @@ void loop() mainDelay.delay(delayMsec); } // if (didWake) LOG_DEBUG("wake!\n"); -} +} \ No newline at end of file diff --git a/src/platform/nrf52/NRF52Bluetooth.cpp b/src/platform/nrf52/NRF52Bluetooth.cpp index c29739542..dd81929c8 100644 --- a/src/platform/nrf52/NRF52Bluetooth.cpp +++ b/src/platform/nrf52/NRF52Bluetooth.cpp @@ -211,6 +211,7 @@ void NRF52Bluetooth::shutdown() // Shutdown bluetooth for minimum power draw LOG_INFO("Disable NRF52 bluetooth\n"); Bluefruit.Advertising.stop(); + Bluefruit.setTxPower(0); // Minimum power } bool NRF52Bluetooth::isConnected() @@ -333,4 +334,4 @@ void NRF52Bluetooth::onPairingCompleted(uint16_t conn_handle, uint8_t auth_statu LOG_INFO("BLE pairing failed\n"); screen->stopBluetoothPinScreen(); -} +} \ No newline at end of file From 4de6eb2e1d76278356e236955e272ec0a0e564a9 Mon Sep 17 00:00:00 2001 From: Ken McGuire Date: Fri, 8 Dec 2023 13:51:50 -0700 Subject: [PATCH 27/31] Reduce Serial Traffic on Heltec Wireless Trackers GNSS port (#3004) * Fix typo in GNSS_MODEL defination and usages for the UC6580 Correct the $CFGSYS init string for the UC6580 to init the receiver for: GPS L1 & L5 + BDS B1I & B2a + GLONASS L1 + GALILEO E1 & E5a + SBAS * Reduce GNSS serial traffic on Helted Wireless Tracker Turn off GSV and NOTIFY __TXT messages as neither are necessary to Meshtastic operation. --- src/gps/GPS.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index afd8fb127..d5cd9b682 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -312,10 +312,22 @@ bool GPS::setup() _serial_gps->write("$PCAS11,3*1E\r\n"); delay(250); } else if (gnssModel == GNSS_MODEL_UC6580) { - + // The Unicore UC6580 can use a lot of sat systems, enable it to // use GPS L1 & L5 + BDS B1I & B2a + GLONASS L1 + GALILEO E1 & E5a + SBAS + // This will reset the receiver, so wait a bit afterwards + // The paranoid will wait for the OK*04 confirmation response after each command. _serial_gps->write("$CFGSYS,h25155\r\n"); + delay(750); + // Must be done after the CFGSYS command + // Turn off GSV messages, we don't really care about which and where the sats are, maybe someday. + _serial_gps->write("$CFGMSG,0,3,0\r\n"); delay(250); + // Turn off NOTICE __TXT messages, these may provide Unicore some info but we don't care. + _serial_gps->write("$CFGMSG,6,0,0\r\n"); + delay(250); + _serial_gps->write("$CFGMSG,6,1,0\r\n"); + delay(250); + } else if (gnssModel == GNSS_MODEL_UBLOX) { // Configure GNSS system to GPS+SBAS+GLONASS (Module may restart after this command) // We need set it because by default it is GPS only, and we want to use GLONASS too From 14b31d4d1461af53818668cb9046b825fee66333 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 8 Dec 2023 19:26:37 -0600 Subject: [PATCH 28/31] Fix INA sensor dual use between environment telem and device battery reading (#3002) --- src/modules/Telemetry/EnvironmentTelemetry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 1047ade1d..9c7b406e9 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -97,9 +97,9 @@ int32_t EnvironmentTelemetryModule::runOnce() result = lps22hbSensor.runOnce(); if (sht31Sensor.hasSensor()) result = sht31Sensor.runOnce(); - if (ina219Sensor.hasSensor() && !ina219Sensor.isInitialized()) + if (ina219Sensor.hasSensor()) result = ina219Sensor.runOnce(); - if (ina260Sensor.hasSensor() && !ina260Sensor.isInitialized()) + if (ina260Sensor.hasSensor()) result = ina260Sensor.runOnce(); } return result; From d552ee35564951d785f12b5c2b44f5759bc994a5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 9 Dec 2023 19:12:51 -0600 Subject: [PATCH 29/31] Add heltec-ht62 to CI (#3007) --- .github/workflows/main_matrix.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index a2aa11288..8b28090ca 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -66,6 +66,7 @@ jobs: - board: tlora-v2-1-1_6 - board: tlora-v2-1-1_8 - board: tbeam + - board: heltec-ht62-esp32c3-sx1262 - board: heltec-v1 - board: heltec-v2_0 - board: heltec-v2_1 From 796592b5869ed3655d1143d91d8ca1008db4f488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 22 Aug 2023 16:23:02 +0200 Subject: [PATCH 30/31] UI/UX: Display delivered message on incoming ACK. Needs more work --- src/modules/CannedMessageModule.cpp | 28 ++++++++++++++++++++++++++-- src/modules/CannedMessageModule.h | 28 +++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index ade9d0e5a..f85a7b1fd 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -244,7 +244,8 @@ int32_t CannedMessageModule::runOnce() } // LOG_DEBUG("Check status\n"); UIFrameEvent e = {false, true}; - if (this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) { + if ((this->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) || + (this->runState == CANNED_MESSAGE_RUN_STATE_ACK_RECEIVED)) { // TODO: might have some feedback of sendig state this->runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; e.frameChanged = true; @@ -483,7 +484,12 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st { char buffer[50]; - if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) { + if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_ACK_RECEIVED) { + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->setFont(FONT_MEDIUM); + display->drawStringf(display->getWidth() / 2 + x, 0 + y + 12, buffer, "Delivered to %s", + cannedMessageModule->getNodeName(this->incoming)); + } else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) { display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(FONT_MEDIUM); display->drawString(display->getWidth() / 2 + x, 0 + y + 12, "Sending..."); @@ -546,6 +552,24 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st } } +ProcessMessage CannedMessageModule::handleReceived(const meshtastic_MeshPacket &mp) +{ + if (mp.decoded.portnum == meshtastic_PortNum_ROUTING_APP) { + // look for a request_id + if (mp.decoded.request_id != 0) { + UIFrameEvent e = {false, true}; + e.frameChanged = true; + this->runState = CANNED_MESSAGE_RUN_STATE_ACK_RECEIVED; + this->incoming = mp.decoded.request_id; + this->notifyObservers(&e); + // run the next time 2 seconds later + setIntervalFromNow(2000); + } + } + + return ProcessMessage::CONTINUE; +} + void CannedMessageModule::loadProtoForModule() { if (!nodeDB.loadProto(cannedMessagesConfigFile, meshtastic_CannedMessageModuleConfig_size, diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index 98467215e..a2abcff89 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -9,6 +9,7 @@ enum cannedMessageModuleRunState { CANNED_MESSAGE_RUN_STATE_ACTIVE, CANNED_MESSAGE_RUN_STATE_FREETEXT, CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE, + CANNED_MESSAGE_RUN_STATE_ACK_RECEIVED, CANNED_MESSAGE_RUN_STATE_ACTION_SELECT, CANNED_MESSAGE_RUN_STATE_ACTION_UP, CANNED_MESSAGE_RUN_STATE_ACTION_DOWN, @@ -37,15 +38,29 @@ class CannedMessageModule : public SinglePortModule, public Observabledecoded.portnum) { + case meshtastic_PortNum_TEXT_MESSAGE_APP: + case meshtastic_PortNum_ROUTING_APP: + return true; + default: + return false; + } + } + protected: virtual int32_t runOnce() override; @@ -63,6 +78,12 @@ class CannedMessageModule : public SinglePortModule, public Observable Date: Tue, 22 Aug 2023 20:29:52 +0200 Subject: [PATCH 31/31] Distinguish between ACK/NAK by checking for error reason --- src/modules/CannedMessageModule.cpp | 12 ++++++++++-- src/modules/CannedMessageModule.h | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index f85a7b1fd..3bca5edaa 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -487,7 +487,12 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_ACK_RECEIVED) { display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(FONT_MEDIUM); - display->drawStringf(display->getWidth() / 2 + x, 0 + y + 12, buffer, "Delivered to %s", + String displayString; + if (this->ack) + displayString = "Delivered to\n%s"; + else + displayString = "Delivery failed\nto %s"; + display->drawStringf(display->getWidth() / 2 + x, 0 + y + 12, buffer, displayString, cannedMessageModule->getNodeName(this->incoming)); } else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) { display->setTextAlignment(TEXT_ALIGN_CENTER); @@ -561,6 +566,9 @@ ProcessMessage CannedMessageModule::handleReceived(const meshtastic_MeshPacket & e.frameChanged = true; this->runState = CANNED_MESSAGE_RUN_STATE_ACK_RECEIVED; this->incoming = mp.decoded.request_id; + meshtastic_Routing decoded = meshtastic_Routing_init_default; + pb_decode_from_bytes(mp.decoded.payload.bytes, mp.decoded.payload.size, meshtastic_Routing_fields, &decoded); + this->ack = decoded.error_reason == meshtastic_Routing_Error_NONE; this->notifyObservers(&e); // run the next time 2 seconds later setIntervalFromNow(2000); @@ -674,4 +682,4 @@ String CannedMessageModule::drawWithCursor(String text, int cursor) return result; } -#endif +#endif \ No newline at end of file diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index a2abcff89..8a53d392e 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -97,6 +97,7 @@ class CannedMessageModule : public SinglePortModule, public Observable