From adf1bc4b0ee3f78e171fb85eb3a674167f1e1ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 26 Oct 2024 14:40:10 +0200 Subject: [PATCH 01/46] fix tracker build (#5151) fix tracker 1000 build --- src/motion/QMA6100PSensor.cpp | 2 +- src/motion/QMA6100PSensor.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/motion/QMA6100PSensor.cpp b/src/motion/QMA6100PSensor.cpp index 237df0b65..989188fe6 100644 --- a/src/motion/QMA6100PSensor.cpp +++ b/src/motion/QMA6100PSensor.cpp @@ -1,6 +1,6 @@ #include "QMA6100PSensor.h" -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && HAS_QMA6100P +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && defined(HAS_QMA6100P) // Flag when an interrupt has been detected volatile static bool QMA6100P_IRQ = false; diff --git a/src/motion/QMA6100PSensor.h b/src/motion/QMA6100PSensor.h index 986b0366d..7ba00149c 100644 --- a/src/motion/QMA6100PSensor.h +++ b/src/motion/QMA6100PSensor.h @@ -4,7 +4,7 @@ #include "MotionSensor.h" -#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && HAS_QMA6100P +#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !MESHTASTIC_EXCLUDE_I2C && defined(HAS_QMA6100P) #include From 2568d4fcd8ba1a8f3f7033b3ec1ec379745c9dd1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 26 Oct 2024 15:51:28 +0200 Subject: [PATCH 02/46] [create-pull-request] automated change (#5153) Co-authored-by: caveman99 <25002+caveman99@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/config.pb.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/protobufs b/protobufs index 7960241cc..7dc7a6d21 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 7960241ccdd6b262a11b79523857037f755ab847 +Subproject commit 7dc7a6d21991efe362c7cbb556573f6bb285e407 diff --git a/src/mesh/generated/meshtastic/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h index 4c76e74cb..fab23ae34 100644 --- a/src/mesh/generated/meshtastic/config.pb.h +++ b/src/mesh/generated/meshtastic/config.pb.h @@ -4,6 +4,7 @@ #ifndef PB_MESHTASTIC_MESHTASTIC_CONFIG_PB_H_INCLUDED #define PB_MESHTASTIC_MESHTASTIC_CONFIG_PB_H_INCLUDED #include +#include "meshtastic/device_ui.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -576,6 +577,7 @@ typedef struct _meshtastic_Config { meshtastic_Config_BluetoothConfig bluetooth; meshtastic_Config_SecurityConfig security; meshtastic_Config_SessionkeyConfig sessionkey; + meshtastic_DeviceUIConfig device_ui; } payload_variant; } meshtastic_Config; @@ -779,6 +781,7 @@ extern "C" { #define meshtastic_Config_bluetooth_tag 7 #define meshtastic_Config_security_tag 8 #define meshtastic_Config_sessionkey_tag 9 +#define meshtastic_Config_device_ui_tag 10 /* Struct field encoding specification for nanopb */ #define meshtastic_Config_FIELDLIST(X, a) \ @@ -790,7 +793,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,display,payload_variant.disp X(a, STATIC, ONEOF, MESSAGE, (payload_variant,lora,payload_variant.lora), 6) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,bluetooth,payload_variant.bluetooth), 7) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,security,payload_variant.security), 8) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,sessionkey,payload_variant.sessionkey), 9) +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,sessionkey,payload_variant.sessionkey), 9) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,device_ui,payload_variant.device_ui), 10) #define meshtastic_Config_CALLBACK NULL #define meshtastic_Config_DEFAULT NULL #define meshtastic_Config_payload_variant_device_MSGTYPE meshtastic_Config_DeviceConfig @@ -802,6 +806,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,sessionkey,payload_variant.s #define meshtastic_Config_payload_variant_bluetooth_MSGTYPE meshtastic_Config_BluetoothConfig #define meshtastic_Config_payload_variant_security_MSGTYPE meshtastic_Config_SecurityConfig #define meshtastic_Config_payload_variant_sessionkey_MSGTYPE meshtastic_Config_SessionkeyConfig +#define meshtastic_Config_payload_variant_device_ui_MSGTYPE meshtastic_DeviceUIConfig #define meshtastic_Config_DeviceConfig_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, UENUM, role, 1) \ From a8bd1ee0da3a0e68bb9449314d1b0e77f1f12067 Mon Sep 17 00:00:00 2001 From: mverch67 Date: Fri, 25 Oct 2024 16:09:49 +0200 Subject: [PATCH 03/46] stability: add SPI lock before saving via littleFS --- src/main.cpp | 3 ++- src/mesh/NodeDB.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e71d1df5f..6bf38b524 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -642,6 +642,8 @@ void setup() rp2040Setup(); #endif + initSPI(); // needed here before reading from littleFS + // We do this as early as possible because this loads preferences from flash // but we need to do this after main cpu init (esp32setup), because we need the random seed set nodeDB = new NodeDB; @@ -705,7 +707,6 @@ void setup() #endif // Init our SPI controller (must be before screen and lora) - initSPI(); #ifdef ARCH_RP2040 #ifdef HW_SPI1_DEVICE SPI1.setSCK(LORA_SCK); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 87a7ad091..69cd631c0 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -32,6 +32,7 @@ #if HAS_WIFI #include "mesh/wifi/WiFiAPClient.h" #endif +#include "SPILock.h" #include "modules/StoreForwardModule.h" #include #include @@ -870,6 +871,9 @@ void NodeDB::loadFromDisk() bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct, bool fullAtomic) { +#ifdef ARCH_ESP32 + concurrency::LockGuard g(spiLock); +#endif bool okay = false; #ifdef FSCom auto f = SafeFile(filename, fullAtomic); From e37369a25fdef1ca715fdf49779fbf7835402348 Mon Sep 17 00:00:00 2001 From: Muhammad Shah <80623330+Babyyoda777@users.noreply.github.com> Date: Sun, 27 Oct 2024 01:24:30 +0100 Subject: [PATCH 04/46] Icarus - Custom PCB (#5155) * added Icarus * added Icarus * Update platformio.ini * Fixed I2C ports * Update variant.h --- boards/icarus.json | 41 ++++++++++++++++++++++++++++++++++ variants/icarus/pins_arduino.h | 22 ++++++++++++++++++ variants/icarus/platformio.ini | 19 ++++++++++++++++ variants/icarus/variant.h | 30 +++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 boards/icarus.json create mode 100644 variants/icarus/pins_arduino.h create mode 100644 variants/icarus/platformio.ini create mode 100644 variants/icarus/variant.h diff --git a/boards/icarus.json b/boards/icarus.json new file mode 100644 index 000000000..03da4682f --- /dev/null +++ b/boards/icarus.json @@ -0,0 +1,41 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=0", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=0" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [["0x2886", "0x0059"]], + "mcu": "esp32s3", + "variant": "icarus" + }, + "connectivity": ["wifi", "bluetooth", "lora"], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": ["esp-builtin"], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": ["arduino", "espidf"], + "name": "icarus", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 8388608, + "maximum_size": 8388608, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://icarus.azlan.works", + "vendor": "Muhammad Shah" +} diff --git a/variants/icarus/pins_arduino.h b/variants/icarus/pins_arduino.h new file mode 100644 index 000000000..9837a3b34 --- /dev/null +++ b/variants/icarus/pins_arduino.h @@ -0,0 +1,22 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x2886 +#define USB_PID 0x0059 + +// GPIO48 Reference: https://github.com/espressif/arduino-esp32/pull/8600 + +// The default Wire will be mapped to Screen and Sensors +static const uint8_t SDA = 8; +static const uint8_t SCL = 9; + +// Default SPI will be mapped to Radio +static const uint8_t MISO = 39; +static const uint8_t SCK = 21; +static const uint8_t MOSI = 38; +static const uint8_t SS = 17; + +#endif /* Pins_Arduino_h */ + \ No newline at end of file diff --git a/variants/icarus/platformio.ini b/variants/icarus/platformio.ini new file mode 100644 index 000000000..116df130d --- /dev/null +++ b/variants/icarus/platformio.ini @@ -0,0 +1,19 @@ +[env:icarus] +extends = esp32s3_base +board = icarus +board_level = extra +board_check = true +board_build.mcu = esp32s3 +upload_protocol = esptool +upload_speed = 921600 +platform_packages = framework-arduinoespressif32@https://github.com/PowerFeather/powerfeather-meshtastic-arduino-lib/releases/download/2.0.16b/esp32-2.0.16.zip +lib_deps = + ${esp32s3_base.lib_deps} +build_unflags = + ${esp32s3_base.build_unflags} + -DARDUINO_USB_MODE=1 +build_flags = + ${esp32s3_base.build_flags} -D PRIVATE_HW -I variants/icarus + -DBOARD_HAS_PSRAM + + -DARDUINO_USB_MODE=0 \ No newline at end of file diff --git a/variants/icarus/variant.h b/variants/icarus/variant.h new file mode 100644 index 000000000..f78f27e39 --- /dev/null +++ b/variants/icarus/variant.h @@ -0,0 +1,30 @@ +// Icarus has a 1.3 inch OLED Screen +#define SCREEN_SSD106 + +#define I2C_SDA 8 +#define I2C_SCL 9 + +#define I2C_SDA1 18 +#define I2C_SCL1 6 + + +// XIAO S3 LORA module +#define USE_SX1262 + +#define LORA_MISO 39 +#define LORA_SCK 21 +#define LORA_MOSI 38 +#define LORA_CS 17 + +#define LORA_RESET 42 +#define LORA_DIO1 5 + +#ifdef USE_SX1262 +#define SX126X_CS LORA_CS +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY 47 +#define SX126X_RESET LORA_RESET + +// DIO2 controlls an antenna switch +#define SX126X_DIO2_AS_RF_SWITCH +#endif From 94ff67e927bb7a3a3bc9fba62fff8fc54a1d5ae1 Mon Sep 17 00:00:00 2001 From: mverch67 Date: Sun, 25 Aug 2024 12:37:50 +0200 Subject: [PATCH 05/46] fix spiLock in RadioLibInterface --- src/mesh/RadioLibInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index f44d50d36..9bf1f27ba 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -20,9 +20,9 @@ void LockingArduinoHal::spiBeginTransaction() void LockingArduinoHal::spiEndTransaction() { - spiLock->unlock(); - ArduinoHal::spiEndTransaction(); + + spiLock->unlock(); } #if ARCH_PORTDUINO void LockingArduinoHal::spiTransfer(uint8_t *out, size_t len, uint8_t *in) From bf760a44bac738f6435423ae7fc888a1ac646c0c Mon Sep 17 00:00:00 2001 From: Muhammad Shah <80623330+Babyyoda777@users.noreply.github.com> Date: Sun, 27 Oct 2024 10:51:51 +0000 Subject: [PATCH 06/46] Icarus - Fix platform dependency version and add selection button (#5161) * Update variant.h * Update platformio.ini --- variants/icarus/platformio.ini | 4 ++-- variants/icarus/variant.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/variants/icarus/platformio.ini b/variants/icarus/platformio.ini index 116df130d..11f09cab4 100644 --- a/variants/icarus/platformio.ini +++ b/variants/icarus/platformio.ini @@ -6,7 +6,7 @@ board_check = true board_build.mcu = esp32s3 upload_protocol = esptool upload_speed = 921600 -platform_packages = framework-arduinoespressif32@https://github.com/PowerFeather/powerfeather-meshtastic-arduino-lib/releases/download/2.0.16b/esp32-2.0.16.zip +platform_packages = framework-arduinoespressif32@https://github.com/PowerFeather/powerfeather-meshtastic-arduino-lib/releases/download/2.0.16a/esp32-2.0.16.zip lib_deps = ${esp32s3_base.lib_deps} build_unflags = @@ -16,4 +16,4 @@ build_flags = ${esp32s3_base.build_flags} -D PRIVATE_HW -I variants/icarus -DBOARD_HAS_PSRAM - -DARDUINO_USB_MODE=0 \ No newline at end of file + -DARDUINO_USB_MODE=0 diff --git a/variants/icarus/variant.h b/variants/icarus/variant.h index f78f27e39..c9c74b45a 100644 --- a/variants/icarus/variant.h +++ b/variants/icarus/variant.h @@ -7,8 +7,9 @@ #define I2C_SDA1 18 #define I2C_SCL1 6 +#define BUTTON_PIN 7 // Selection button -// XIAO S3 LORA module +// RA-01SH/HT-RA62 LORA module #define USE_SX1262 #define LORA_MISO 39 From 1334d07c6ae53f1f069b2df120c69d1ac2348ebc Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 27 Oct 2024 06:57:11 -0500 Subject: [PATCH 07/46] Trunk updates --- .trunk/trunk.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index ea4045a16..ad8864ab7 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,22 +1,22 @@ version: 0.1 cli: - version: 1.22.6 + version: 1.22.7 plugins: sources: - id: trunk - ref: v1.6.3 + ref: v1.6.4 uri: https://github.com/trunk-io/plugins lint: enabled: - - trufflehog@3.82.6 + - trufflehog@3.82.12 - yamllint@1.35.1 - bandit@1.7.10 - checkov@3.2.256 - - terrascan@1.19.1 + - terrascan@1.19.9 - trivy@0.55.2 #- trufflehog@3.63.2-rc0 - taplo@0.9.3 - - ruff@0.6.8 + - ruff@0.7.0 - isort@5.13.2 - markdownlint@0.42.0 - oxipng@9.1.2 @@ -26,9 +26,9 @@ lint: - hadolint@2.12.0 - shfmt@3.6.0 - shellcheck@0.10.0 - - black@24.8.0 + - black@24.10.0 - git-diff-check - - gitleaks@8.20.0 + - gitleaks@8.21.1 - clang-format@16.0.3 - prettier@3.3.3 ignore: From 82145e0661ac7b65b298028285a264c5e6bc712b Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sun, 27 Oct 2024 19:21:57 -0500 Subject: [PATCH 08/46] Cherry picks (#5166) * fix compiler error std::find() * fix wifi/bt connection status * try-fix crash * added 1200baud reset --------- Co-authored-by: mverch67 --- boards/bpi_picow_esp32_s3.json | 2 ++ src/gps/GPS.cpp | 1 + src/modules/AdminModule.cpp | 12 ++++++++---- src/modules/ExternalNotificationModule.cpp | 2 +- src/modules/ExternalNotificationModule.h | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/boards/bpi_picow_esp32_s3.json b/boards/bpi_picow_esp32_s3.json index 9a20dd57f..75983d845 100644 --- a/boards/bpi_picow_esp32_s3.json +++ b/boards/bpi_picow_esp32_s3.json @@ -28,6 +28,8 @@ "flash_size": "8MB", "maximum_ram_size": 327680, "maximum_size": 8388608, + "use_1200bps_touch": true, + "wait_for_upload_port": true, "require_upload_port": true, "speed": 921600 }, diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 3a9516c84..2dda776e1 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -20,6 +20,7 @@ #ifdef ARCH_PORTDUINO #include "PortduinoGlue.h" #include "meshUtils.h" +#include #include #endif diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index c0580ab33..90722f547 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -900,7 +900,7 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r #ifdef ARCH_PORTDUINO conn.wifi.status.is_connected = true; #else - conn.wifi.status.is_connected = WiFi.status() != WL_CONNECTED; + conn.wifi.status.is_connected = WiFi.status() == WL_CONNECTED; #endif strncpy(conn.wifi.ssid, config.network.wifi_ssid, 33); if (conn.wifi.status.is_connected) { @@ -932,10 +932,14 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r conn.has_bluetooth = true; conn.bluetooth.pin = config.bluetooth.fixed_pin; #ifdef ARCH_ESP32 - conn.bluetooth.is_connected = nimbleBluetooth->isConnected(); - conn.bluetooth.rssi = nimbleBluetooth->getRssi(); + if (config.bluetooth.enabled && nimbleBluetooth) { + conn.bluetooth.is_connected = nimbleBluetooth->isConnected(); + conn.bluetooth.rssi = nimbleBluetooth->getRssi(); + } #elif defined(ARCH_NRF52) - conn.bluetooth.is_connected = nrf52Bluetooth->isConnected(); + if (config.bluetooth.enabled && nrf52Bluetooth) { + conn.bluetooth.is_connected = nrf52Bluetooth->isConnected(); + } #endif #endif conn.has_serial = true; // No serial-less devices diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index a35a74206..87387f0a4 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -184,7 +184,7 @@ int32_t ExternalNotificationModule::runOnce() } #endif // now let the PWM buzzer play - if (moduleConfig.external_notification.use_pwm) { + if (moduleConfig.external_notification.use_pwm && config.device.buzzer_gpio) { if (rtttl::isPlaying()) { rtttl::play(); } else if (isNagging && (nagCycleCutoff >= millis())) { diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index a5dff3651..20d02d68b 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -32,7 +32,7 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency: public: ExternalNotificationModule(); - uint32_t nagCycleCutoff = UINT32_MAX; + uint32_t nagCycleCutoff = 1; void setExternalOn(uint8_t index = 0); void setExternalOff(uint8_t index = 0); From d14d42ba2c13bf7ff901169b466dbe382dd5e260 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Mon, 28 Oct 2024 19:23:49 +1100 Subject: [PATCH 09/46] diy mesh-tab initial files (#5169) Co-authored-by: mverch67 --- variants/diy/mesh-tab/variant.h | 49 +++++++++++++++++++++++ variants/diy/platformio.ini | 70 +++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 variants/diy/mesh-tab/variant.h diff --git a/variants/diy/mesh-tab/variant.h b/variants/diy/mesh-tab/variant.h new file mode 100644 index 000000000..0a23a3c36 --- /dev/null +++ b/variants/diy/mesh-tab/variant.h @@ -0,0 +1,49 @@ +#ifndef _VARIANT_MESHTAB_DIY_ +#define _VARIANT_MESHTAB_DIY_ + +#define HAS_TOUCHSCREEN 1 + +#define SLEEP_TIME 120 + +// Analog pins +#define BATTERY_PIN 4 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +// ratio of voltage divider = 2.0 +#define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. +#define ADC_CHANNEL ADC1_GPIO4_CHANNEL + +// LED +#define LED_PIN 21 + +// Button +#define BUTTON_PIN 0 + +// GPS +#define GPS_RX_PIN 18 +#define GPS_TX_PIN 17 + +// #define HAS_SDCARD 1 +#define SPI_MOSI 13 +#define SPI_SCK 12 +#define SPI_MISO 11 +#define SPI_CS 10 +#define SDCARD_CS 6 + +// LORA SPI +#define LORA_SCK 36 +#define LORA_MISO 37 +#define LORA_MOSI 35 +#define LORA_CS 39 + +// LORA MODULES +#define USE_SX1262 + +// LORA CONFIG +#define SX126X_CS LORA_CS +#define SX126X_DIO1 15 +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_BUSY 40 +#define SX126X_RESET 14 +#define SX126X_RXEN 47 +#define SX126X_TXEN RADIOLIB_NC // Assuming that DIO2 is connected to TXEN pin + +#endif diff --git a/variants/diy/platformio.ini b/variants/diy/platformio.ini index f3c22b7a8..00ff88da2 100644 --- a/variants/diy/platformio.ini +++ b/variants/diy/platformio.ini @@ -88,3 +88,73 @@ build_flags = -D ARDUINO_USB_MODE=0 -D ARDUINO_USB_CDC_ON_BOOT=1 -I variants/diy/t-energy-s3_e22 + +; esp32-s3 + ra-sh01 lora + 3.2" ILI9143 +[env:mesh-tab] +extends = esp32s3_base +board = um_feathers3 +board_level = extra +board_upload.flash_size = 16MB +board_build.partitions = default_16MB.csv +upload_protocol = esptool +build_flags = ${esp32s3_base.build_flags} + -D MESH_TAB + -D PRIVATE_HW + -D CONFIG_ARDUHAL_ESP_LOG + -D CONFIG_ARDUHAL_LOG_COLORS=1 + -D CONFIG_DISABLE_HAL_LOCKS=1 ; "feels" to be a bit more stable without locks + -D MESHTASTIC_EXCLUDE_CANNEDMESSAGES=1 + -D MESHTASTIC_EXCLUDE_INPUTBROKER=1 + -D MESHTASTIC_EXCLUDE_BLUETOOTH=1 + -D MESHTASTIC_EXCLUDE_WEBSERVER=1 + -D LV_LVGL_H_INCLUDE_SIMPLE + -D LV_CONF_INCLUDE_SIMPLE + -D LV_COMP_CONF_INCLUDE_SIMPLE + -D LV_USE_SYSMON=0 + -D LV_USE_PROFILER=0 + -D LV_USE_PERF_MONITOR=0 + -D LV_USE_MEM_MONITOR=0 + -D LV_USE_LOG=0 + -D LV_BUILD_TEST=0 + -D USE_LOG_DEBUG + -D LOG_DEBUG_INC=\"DebugConfiguration.h\" + -D RADIOLIB_SPI_PARANOID=0 + -D MAX_NUM_NODES=250 + -D MAX_THREADS=40 + -D HAS_SCREEN=0 + -D HAS_TFT=1 + -D RAM_SIZE=1024 + -D LGFX_DRIVER_TEMPLATE + -D LGFX_DRIVER=LGFX_GENERIC + -D LGFX_PANEL=ILI9341 + -D LGFX_OFFSET_ROTATION=1 + -D LGFX_TOUCH=XPT2046 + -D LGFX_PIN_SCK=12 + -D LGFX_PIN_MOSI=13 + -D LGFX_PIN_MISO=11 + -D LGFX_PIN_DC=16 + -D LGFX_PIN_CS=10 + -D LGFX_PIN_RST=-1 + -D LGFX_PIN_BL=42 + -D LGFX_TOUCH_INT=41 + -D LGFX_TOUCH_CS=7 + -D LGFX_TOUCH_CLK=12 + -D LGFX_TOUCH_DO=11 + -D LGFX_TOUCH_DIN=13 + -D LGFX_TOUCH_X_MIN=300 + -D LGFX_TOUCH_X_MAX=3900 + -D LGFX_TOUCH_Y_MIN=400 + -D LGFX_TOUCH_Y_MAX=3900 + -D VIEW_320x240 + -D USE_PACKET_API + -I lib/device-ui/generated/ui_320x240 + -I variants/diy/mesh-tab +build_src_filter = ${esp32_base.build_src_filter} + +<../lib/device-ui/generated/ui_320x240> + +<../lib/device-ui/resources> + +<../lib/device-ui/locale> + +<../lib/device-ui/source> +lib_deps = ${esp32_base.lib_deps} + lovyan03/LovyanGFX@^1.1.16 + earlephilhower/ESP8266Audio@^1.9.7 + earlephilhower/ESP8266SAM@^1.0.1 From c071eed6a355e5a01a7f94d75363e5684b148224 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Mon, 28 Oct 2024 19:25:25 +1100 Subject: [PATCH 10/46] cherry-pick: unphone support (#5174) * unphone part 1 * Unphone support * update HWid unphone --------- Co-authored-by: mverch67 --- boards/unphone.json | 46 ++++++++++++++++++++++ src/main.cpp | 9 ++++- variants/unphone/pins_arduino.h | 67 +++++++++++++++++++++++++++++++++ variants/unphone/platformio.ini | 53 ++++++++++++++++++++++++-- 4 files changed, 169 insertions(+), 6 deletions(-) create mode 100644 boards/unphone.json create mode 100644 variants/unphone/pins_arduino.h diff --git a/boards/unphone.json b/boards/unphone.json new file mode 100644 index 000000000..bf711993c --- /dev/null +++ b/boards/unphone.json @@ -0,0 +1,46 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi", + "partitions": "default_8MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DUNPHONE_SPIN=9", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=0", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + ["0x16D0", "0x1178"], + ["0x303a", "0x1001"] + ], + "mcu": "esp32s3", + "variant": "unphone" + }, + "connectivity": ["wifi", "bluetooth", "lora"], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": ["esp-builtin"], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": ["arduino", "espidf"], + "name": "unPhone", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 327680, + "maximum_size": 8323072, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://unphone.net/", + "vendor": "University of Sheffield" +} diff --git a/src/main.cpp b/src/main.cpp index 6bf38b524..0ce6b3bae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -266,14 +266,19 @@ void setup() #ifdef DEBUG_PORT consoleInit(); // Set serial baud rate and init our mesh console #endif + +#ifdef UNPHONE + unphone.printStore(); +#endif + #if ARCH_PORTDUINO struct timeval tv; tv.tv_sec = time(NULL); tv.tv_usec = 0; perhapsSetRTC(RTCQualityNTP, &tv); #endif - powerMonInit(); + powerMonInit(); serialSinceMsec = millis(); LOG_INFO("\n\n//\\ E S H T /\\ S T / C\n"); @@ -1190,4 +1195,4 @@ void loop() mainDelay.delay(delayMsec); } } -#endif \ No newline at end of file +#endif diff --git a/variants/unphone/pins_arduino.h b/variants/unphone/pins_arduino.h new file mode 100644 index 000000000..c4e9add1c --- /dev/null +++ b/variants/unphone/pins_arduino.h @@ -0,0 +1,67 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x16D0 +#define USB_PID 0x1178 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +#define analogInputToDigitalPin(p) (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) +#define digitalPinToInterrupt(p) (((p) < 48) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 46) + +#define LED_BUILTIN 13 +#define BUILTIN_LED LED_BUILTIN // backward compatibility + +static const uint8_t TX = 43; +static const uint8_t RX = 44; + +static const uint8_t SDA = 3; +static const uint8_t SCL = 4; + +static const uint8_t SS = 13; +static const uint8_t MOSI = 40; +static const uint8_t MISO = 41; +static const uint8_t SCK = 39; + +static const uint8_t A0 = 1; +static const uint8_t A1 = 2; +static const uint8_t A2 = 8; +static const uint8_t A3 = 9; +static const uint8_t A4 = 5; +static const uint8_t A5 = 6; +static const uint8_t A6 = 14; +static const uint8_t A7 = 7; +static const uint8_t A8 = 15; +static const uint8_t A9 = 33; +static const uint8_t A10 = 27; +static const uint8_t A11 = 12; +static const uint8_t A12 = 13; +static const uint8_t A13 = 14; +static const uint8_t A14 = 15; +static const uint8_t A15 = 16; +static const uint8_t A16 = 17; +static const uint8_t A17 = 18; +static const uint8_t A18 = 19; +static const uint8_t A19 = 20; + +static const uint8_t T1 = 2; +static const uint8_t T2 = 8; +static const uint8_t T3 = 9; +static const uint8_t T4 = 5; +static const uint8_t T5 = 6; +static const uint8_t T6 = 14; +static const uint8_t T7 = 7; +static const uint8_t T8 = 15; +static const uint8_t T9 = 33; +static const uint8_t T10 = 27; +static const uint8_t T11 = 12; +static const uint8_t T12 = 13; +static const uint8_t T13 = 14; +static const uint8_t T14 = 15; + +#endif /* Pins_Arduino_h */ diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index dbfa0599d..489c70f99 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -13,7 +13,6 @@ build_unflags = -D ARDUINO_USB_MODE build_flags = ${esp32_base.build_flags} - ;-D BOARD_HAS_PSRAM // what's up with this - doesn't seem to be recognised at boot -D UNPHONE -I variants/unphone -D ARDUINO_USB_MODE=0 @@ -27,6 +26,52 @@ build_flags = ${esp32_base.build_flags} build_src_filter = ${esp32_base.build_src_filter} +<../variants/unphone> lib_deps = ${esp32s3_base.lib_deps} - lovyan03/LovyanGFX @ ^1.1.8 - https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic @ ^9.0.0 - adafruit/Adafruit NeoPixel @ ^1.12.0 \ No newline at end of file + lovyan03/LovyanGFX@ 1.1.12 + https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic@9.0.0 + adafruit/Adafruit NeoPixel @ ^1.12.0 + + +[env:unphone-tft] +extends = esp32s3_base +board_level = extra +board = unphone +board_build.partitions = default_8MB.csv +monitor_speed = 115200 +monitor_filters = esp32_exception_decoder +build_flags = ${esp32_base.build_flags} + -D UNPHONE + -D UNPHONE_ACCEL=0 + -D UNPHONE_TOUCHS=0 + -D UNPHONE_SDCARD=0 + -D UNPHONE_UI0=0 + -D UNPHONE_LORA=0 + -D UNPHONE_FACTORY_MODE=0 + -D MAX_THREADS=40 + -D HAS_SCREEN=0 + -D HAS_TFT=1 + -D RAM_SIZE=512 + -D LV_LVGL_H_INCLUDE_SIMPLE + -D LV_CONF_INCLUDE_SIMPLE + -D LV_COMP_CONF_INCLUDE_SIMPLE + -D LV_BUILD_TEST=0 + -D LV_USE_PERF_MONITOR=0 + -D LV_USE_MEM_MONITOR=0 + -D USE_LOG_DEBUG + -D LOG_DEBUG_INC=\"DebugConfiguration.h\" +; -D CALIBRATE_TOUCH=0 + -D LGFX_DRIVER=LGFX_UNPHONE_V9 + -D VIEW_320x240 +; -D USE_DOUBLE_BUFFER + -D USE_PACKET_API + -I lib/device-ui/generated/ui_320x240 + -I variants/unphone + +build_src_filter = ${esp32_base.build_src_filter} +<../variants/unphone> + +<../lib/device-ui/generated/ui_320x240> + +<../lib/device-ui/resources> + +<../lib/device-ui/source> + +lib_deps = ${esp32s3_base.lib_deps} + lovyan03/LovyanGFX@^1.1.12 + https://gitlab.com/hamishcunningham/unphonelibrary#meshtastic@9.0.0 + adafruit/Adafruit NeoPixel@1.12.0 \ No newline at end of file From 3c8ca39effe0136eba355a3199893ad2132092d2 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Mon, 28 Oct 2024 19:30:39 +1100 Subject: [PATCH 11/46] cherry-pick: fix nrf builds (#5172) * fix nrf builds * fix rp2040 + monteops build * Bump lovyan version --------- Co-authored-by: mverch67 --- arch/nrf52/nrf52.ini | 3 ++- arch/portduino/portduino.ini | 2 +- arch/rp2xx0/rp2350.ini | 3 ++- variants/monteops_hw1/platformio.ini | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 04880d540..1af68198b 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -23,4 +23,5 @@ lib_deps= rweather/Crypto@^0.4.0 lib_ignore = - BluetoothOTA \ No newline at end of file + BluetoothOTA + lvgl diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index 8778c32a0..7eb563d77 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -24,7 +24,7 @@ lib_deps = ${env.lib_deps} ${networking_base.lib_deps} rweather/Crypto@^0.4.0 - lovyan03/LovyanGFX@^1.1.16 + https://github.com/lovyan03/LovyanGFX.git#1401c28a47646fe00538d487adcb2eb3c72de805 build_flags = ${arduino_base.build_flags} diff --git a/arch/rp2xx0/rp2350.ini b/arch/rp2xx0/rp2350.ini index 96ed0cb21..7ef6332e3 100644 --- a/arch/rp2xx0/rp2350.ini +++ b/arch/rp2xx0/rp2350.ini @@ -16,8 +16,9 @@ build_src_filter = lib_ignore = BluetoothOTA + lvgl lib_deps = ${arduino_base.lib_deps} ${environmental_base.lib_deps} - rweather/Crypto \ No newline at end of file + rweather/Crypto diff --git a/variants/monteops_hw1/platformio.ini b/variants/monteops_hw1/platformio.ini index 4b42dce39..eaa246526 100644 --- a/variants/monteops_hw1/platformio.ini +++ b/variants/monteops_hw1/platformio.ini @@ -12,4 +12,4 @@ lib_deps = https://github.com/RAKWireless/RAK13800-W5100S.git#1.0.2 debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) -;upload_protocol = jlink \ No newline at end of file +;upload_protocol = jlink From 195f109ef7eab8e93fc4d6d62a2a5b5149de0958 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Mon, 28 Oct 2024 19:31:21 +1100 Subject: [PATCH 12/46] Cherrry pick bin/config-dist.yml from TFT-GUI-Work (#5168) * support SHCHV 3.5 RPi TFT+Touchscreen * add TZT 2.0inch ST7789 config --------- Co-authored-by: mverch67 --- bin/config-dist.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bin/config-dist.yaml b/bin/config-dist.yaml index a755954b1..e20ab0d33 100644 --- a/bin/config-dist.yaml +++ b/bin/config-dist.yaml @@ -115,6 +115,29 @@ Display: # Height: 320 # Rotate: true +### SHCHV 3.5 RPi TFT+Touchscreen +# Panel: ILI9486 +# spidev: spidev0.0 +# BusFrequency: 30000000 +# DC: 24 +# Reset: 25 +# Width: 320 +# Height: 480 +# OffsetRotate: 2 + +### TZT 2.0 Inch TFT Display ST7789V 240RGBx320 +# Panel: ST7789 +# spidev: spidev0.0 +# # CS: 8 # can be freely chosen +# BusFrequency: 80000000 +# DC: 24 # can be freely chosen +# Width: 320 +# Height: 240 +# Reset: 25 # can be freely chosen +# Rotate: true +# OffsetRotate: 1 +# Invert: true + ### You can also specify the spi device for the display to use # spidev: spidev0.0 From c4eb9a6d7fa025557243986176ca989a36177fa4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 06:16:06 -0500 Subject: [PATCH 13/46] [create-pull-request] automated change (#5176) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/device_ui.pb.h | 76 +++++++++++++------- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/protobufs b/protobufs index 7dc7a6d21..807236815 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 7dc7a6d21991efe362c7cbb556573f6bb285e407 +Subproject commit 807236815d61cc0ebd89472c2a2aa76758bc92ac diff --git a/src/mesh/generated/meshtastic/device_ui.pb.h b/src/mesh/generated/meshtastic/device_ui.pb.h index 469fe6f11..5c1e067ab 100644 --- a/src/mesh/generated/meshtastic/device_ui.pb.h +++ b/src/mesh/generated/meshtastic/device_ui.pb.h @@ -40,7 +40,19 @@ typedef enum _meshtastic_Language { /* Polish */ meshtastic_Language_POLISH = 8, /* Turkish */ - meshtastic_Language_TURKISH = 9 + meshtastic_Language_TURKISH = 9, + /* Serbian */ + meshtastic_Language_SERBIAN = 10, + /* Russian */ + meshtastic_Language_RUSSIAN = 11, + /* Dutch */ + meshtastic_Language_DUTCH = 12, + /* Greek */ + meshtastic_Language_GREEK = 13, + /* Simplified Chinese (experimental) */ + meshtastic_Language_SIMPLIFIED_CHINESE = 30, + /* Traditional Chinese (experimental) */ + meshtastic_Language_TRADITIONAL_CHINESE = 31 } meshtastic_Language; /* Struct definitions */ @@ -73,16 +85,22 @@ typedef struct _meshtastic_NodeHighlight { } meshtastic_NodeHighlight; typedef struct _meshtastic_DeviceUIConfig { + /* A version integer used to invalidate saved files when we make incompatible changes. */ + uint32_t version; /* TFT display brightness 1..255 */ uint8_t screen_brightness; /* Screen timeout 0..900 */ uint16_t screen_timeout; - /* Screen lock enabled */ + /* Screen/Settings lock enabled */ bool screen_lock; + bool settings_lock; + uint32_t pin_code; /* Color theme */ meshtastic_Theme theme; - /* Audible message alert enabled */ + /* Audible message, banner and ring tone */ bool alert_enabled; + bool banner_enabled; + uint8_t ring_tone_id; /* Localization */ meshtastic_Language language; /* Node list filter */ @@ -104,8 +122,8 @@ extern "C" { #define _meshtastic_Theme_ARRAYSIZE ((meshtastic_Theme)(meshtastic_Theme_RED+1)) #define _meshtastic_Language_MIN meshtastic_Language_ENGLISH -#define _meshtastic_Language_MAX meshtastic_Language_TURKISH -#define _meshtastic_Language_ARRAYSIZE ((meshtastic_Language)(meshtastic_Language_TURKISH+1)) +#define _meshtastic_Language_MAX meshtastic_Language_TRADITIONAL_CHINESE +#define _meshtastic_Language_ARRAYSIZE ((meshtastic_Language)(meshtastic_Language_TRADITIONAL_CHINESE+1)) #define meshtastic_DeviceUIConfig_theme_ENUMTYPE meshtastic_Theme #define meshtastic_DeviceUIConfig_language_ENUMTYPE meshtastic_Language @@ -114,10 +132,10 @@ extern "C" { /* Initializer values for message structs */ -#define meshtastic_DeviceUIConfig_init_default {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_default, false, meshtastic_NodeHighlight_init_default} +#define meshtastic_DeviceUIConfig_init_default {0, 0, 0, 0, 0, 0, _meshtastic_Theme_MIN, 0, 0, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_default, false, meshtastic_NodeHighlight_init_default} #define meshtastic_NodeFilter_init_default {0, 0, 0, 0, 0, ""} #define meshtastic_NodeHighlight_init_default {0, 0, 0, 0, ""} -#define meshtastic_DeviceUIConfig_init_zero {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_zero, false, meshtastic_NodeHighlight_init_zero} +#define meshtastic_DeviceUIConfig_init_zero {0, 0, 0, 0, 0, 0, _meshtastic_Theme_MIN, 0, 0, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_zero, false, meshtastic_NodeHighlight_init_zero} #define meshtastic_NodeFilter_init_zero {0, 0, 0, 0, 0, ""} #define meshtastic_NodeHighlight_init_zero {0, 0, 0, 0, ""} @@ -133,25 +151,35 @@ extern "C" { #define meshtastic_NodeHighlight_telemetry_switch_tag 3 #define meshtastic_NodeHighlight_iaq_switch_tag 4 #define meshtastic_NodeHighlight_node_name_tag 5 -#define meshtastic_DeviceUIConfig_screen_brightness_tag 1 -#define meshtastic_DeviceUIConfig_screen_timeout_tag 2 -#define meshtastic_DeviceUIConfig_screen_lock_tag 3 -#define meshtastic_DeviceUIConfig_theme_tag 4 -#define meshtastic_DeviceUIConfig_alert_enabled_tag 5 -#define meshtastic_DeviceUIConfig_language_tag 6 -#define meshtastic_DeviceUIConfig_node_filter_tag 7 -#define meshtastic_DeviceUIConfig_node_highlight_tag 8 +#define meshtastic_DeviceUIConfig_version_tag 1 +#define meshtastic_DeviceUIConfig_screen_brightness_tag 2 +#define meshtastic_DeviceUIConfig_screen_timeout_tag 3 +#define meshtastic_DeviceUIConfig_screen_lock_tag 4 +#define meshtastic_DeviceUIConfig_settings_lock_tag 5 +#define meshtastic_DeviceUIConfig_pin_code_tag 6 +#define meshtastic_DeviceUIConfig_theme_tag 7 +#define meshtastic_DeviceUIConfig_alert_enabled_tag 8 +#define meshtastic_DeviceUIConfig_banner_enabled_tag 9 +#define meshtastic_DeviceUIConfig_ring_tone_id_tag 10 +#define meshtastic_DeviceUIConfig_language_tag 11 +#define meshtastic_DeviceUIConfig_node_filter_tag 12 +#define meshtastic_DeviceUIConfig_node_highlight_tag 13 /* Struct field encoding specification for nanopb */ #define meshtastic_DeviceUIConfig_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, screen_brightness, 1) \ -X(a, STATIC, SINGULAR, UINT32, screen_timeout, 2) \ -X(a, STATIC, SINGULAR, BOOL, screen_lock, 3) \ -X(a, STATIC, SINGULAR, UENUM, theme, 4) \ -X(a, STATIC, SINGULAR, BOOL, alert_enabled, 5) \ -X(a, STATIC, SINGULAR, UENUM, language, 6) \ -X(a, STATIC, OPTIONAL, MESSAGE, node_filter, 7) \ -X(a, STATIC, OPTIONAL, MESSAGE, node_highlight, 8) +X(a, STATIC, SINGULAR, UINT32, version, 1) \ +X(a, STATIC, SINGULAR, UINT32, screen_brightness, 2) \ +X(a, STATIC, SINGULAR, UINT32, screen_timeout, 3) \ +X(a, STATIC, SINGULAR, BOOL, screen_lock, 4) \ +X(a, STATIC, SINGULAR, BOOL, settings_lock, 5) \ +X(a, STATIC, SINGULAR, UINT32, pin_code, 6) \ +X(a, STATIC, SINGULAR, UENUM, theme, 7) \ +X(a, STATIC, SINGULAR, BOOL, alert_enabled, 8) \ +X(a, STATIC, SINGULAR, BOOL, banner_enabled, 9) \ +X(a, STATIC, SINGULAR, UINT32, ring_tone_id, 10) \ +X(a, STATIC, SINGULAR, UENUM, language, 11) \ +X(a, STATIC, OPTIONAL, MESSAGE, node_filter, 12) \ +X(a, STATIC, OPTIONAL, MESSAGE, node_highlight, 13) #define meshtastic_DeviceUIConfig_CALLBACK NULL #define meshtastic_DeviceUIConfig_DEFAULT NULL #define meshtastic_DeviceUIConfig_node_filter_MSGTYPE meshtastic_NodeFilter @@ -187,7 +215,7 @@ extern const pb_msgdesc_t meshtastic_NodeHighlight_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_MAX_SIZE meshtastic_DeviceUIConfig_size -#define meshtastic_DeviceUIConfig_size 80 +#define meshtastic_DeviceUIConfig_size 99 #define meshtastic_NodeFilter_size 36 #define meshtastic_NodeHighlight_size 25 From 77dfc92f1e58b3fca0b75c3f99f823ae1dde87f9 Mon Sep 17 00:00:00 2001 From: Spiffysec Date: Mon, 28 Oct 2024 12:18:03 +0100 Subject: [PATCH 14/46] Update GPSUpdateScheduling.cpp (#5160) * Update GPSUpdateScheduling.cpp Default value is too short, resulting in unstable GPS locks on T1000-E (possibly others). Fix has been tested an confirmed working with no adverse effects, by multiple users. Also discussed at length on Discord * Coerce minimum instead of hardcode * config --------- Co-authored-by: Ben Meadors --- src/gps/GPSUpdateScheduling.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gps/GPSUpdateScheduling.cpp b/src/gps/GPSUpdateScheduling.cpp index 9c2626e84..b2bd98f58 100644 --- a/src/gps/GPSUpdateScheduling.cpp +++ b/src/gps/GPSUpdateScheduling.cpp @@ -70,9 +70,10 @@ bool GPSUpdateScheduling::isUpdateDue() // Have we been searching for a GPS position for too long? bool GPSUpdateScheduling::searchedTooLong() { + uint32_t minimumOrConfiguredSecs = Default::getConfiguredOrMinimumValue( + config.position.position_broadcast_secs, default_broadcast_interval_secs); uint32_t maxSearchMs = - Default::getConfiguredOrDefaultMs(config.position.position_broadcast_secs, default_broadcast_interval_secs); - + Default::getConfiguredOrDefaultMs(minimumOrConfiguredSecs, default_broadcast_interval_secs); // If broadcast interval set to max, no such thing as "too long" if (maxSearchMs == UINT32_MAX) return false; @@ -115,4 +116,4 @@ void GPSUpdateScheduling::updateLockTimePrediction() uint32_t GPSUpdateScheduling::predictedSearchDurationMs() { return GPSUpdateScheduling::predictedMsToGetLock; -} \ No newline at end of file +} From e12fd27b498a67d68fd3daeccdf6166f5488056f Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 28 Oct 2024 06:40:48 -0500 Subject: [PATCH 15/46] Trunkdor the burninator --- src/gps/GPSUpdateScheduling.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gps/GPSUpdateScheduling.cpp b/src/gps/GPSUpdateScheduling.cpp index b2bd98f58..abcf6b196 100644 --- a/src/gps/GPSUpdateScheduling.cpp +++ b/src/gps/GPSUpdateScheduling.cpp @@ -70,10 +70,9 @@ bool GPSUpdateScheduling::isUpdateDue() // Have we been searching for a GPS position for too long? bool GPSUpdateScheduling::searchedTooLong() { - uint32_t minimumOrConfiguredSecs = Default::getConfiguredOrMinimumValue( - config.position.position_broadcast_secs, default_broadcast_interval_secs); - uint32_t maxSearchMs = - Default::getConfiguredOrDefaultMs(minimumOrConfiguredSecs, default_broadcast_interval_secs); + uint32_t minimumOrConfiguredSecs = + Default::getConfiguredOrMinimumValue(config.position.position_broadcast_secs, default_broadcast_interval_secs); + uint32_t maxSearchMs = Default::getConfiguredOrDefaultMs(minimumOrConfiguredSecs, default_broadcast_interval_secs); // If broadcast interval set to max, no such thing as "too long" if (maxSearchMs == UINT32_MAX) return false; From 850f61d2d0ec9662b77662de8733f2e47061a239 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Mon, 28 Oct 2024 21:48:10 -0500 Subject: [PATCH 16/46] Native config.d (#5165) * Add support for loading yaml from a config directory * Add waveshare hats to the new config.d approach * Move to available.d for module inactive module configs --- .github/workflows/package_amd64.yml | 3 + .github/workflows/package_raspbian.yml | 3 + .github/workflows/package_raspbian_armv7l.yml | 3 + bin/config-dist.yaml | 11 +- bin/config.d/display-waveshare-2.8.yaml | 18 + bin/config.d/lora-waveshare-sxxx.yaml | 8 + src/platform/portduino/PortduinoGlue.cpp | 375 +++++++++--------- src/platform/portduino/PortduinoGlue.h | 7 +- 8 files changed, 239 insertions(+), 189 deletions(-) create mode 100644 bin/config.d/display-waveshare-2.8.yaml create mode 100644 bin/config.d/lora-waveshare-sxxx.yaml diff --git a/.github/workflows/package_amd64.yml b/.github/workflows/package_amd64.yml index 0b5093f24..a5442246a 100644 --- a/.github/workflows/package_amd64.yml +++ b/.github/workflows/package_amd64.yml @@ -50,11 +50,14 @@ jobs: mkdir -p .debpkg/usr/share/doc/meshtasticd/web mkdir -p .debpkg/usr/sbin mkdir -p .debpkg/etc/meshtasticd + mkdir -p .debpkg/etc/meshtasticd/config.d + mkdir -p .debpkg/etc/meshtasticd/available.d mkdir -p .debpkg/usr/lib/systemd/system/ tar -xf build.tar -C .debpkg/usr/share/doc/meshtasticd/web gunzip .debpkg/usr/share/doc/meshtasticd/web/*.gz cp release/meshtasticd_linux_x86_64 .debpkg/usr/sbin/meshtasticd cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml + cp bin/config.d/* .debpkg/etc/meshtasticd/available.d/ chmod +x .debpkg/usr/sbin/meshtasticd cp bin/meshtasticd.service .debpkg/usr/lib/systemd/system/meshtasticd.service echo "/etc/meshtasticd/config.yaml" > .debpkg/DEBIAN/conffiles diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index bcbda53e2..89efba1de 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -50,11 +50,14 @@ jobs: mkdir -p .debpkg/usr/share/doc/meshtasticd/web mkdir -p .debpkg/usr/sbin mkdir -p .debpkg/etc/meshtasticd + mkdir -p .debpkg/etc/meshtasticd/config.d + mkdir -p .debpkg/etc/meshtasticd/available.d mkdir -p .debpkg/usr/lib/systemd/system/ tar -xf build.tar -C .debpkg/usr/share/doc/meshtasticd/web gunzip .debpkg/usr/share/doc/meshtasticd/web/*.gz cp release/meshtasticd_linux_aarch64 .debpkg/usr/sbin/meshtasticd cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml + cp bin/config.d/* .debpkg/etc/meshtasticd/available.d/ chmod +x .debpkg/usr/sbin/meshtasticd cp bin/meshtasticd.service .debpkg/usr/lib/systemd/system/meshtasticd.service echo "/etc/meshtasticd/config.yaml" > .debpkg/DEBIAN/conffiles diff --git a/.github/workflows/package_raspbian_armv7l.yml b/.github/workflows/package_raspbian_armv7l.yml index 1308fe925..5cbc27097 100644 --- a/.github/workflows/package_raspbian_armv7l.yml +++ b/.github/workflows/package_raspbian_armv7l.yml @@ -50,11 +50,14 @@ jobs: mkdir -p .debpkg/usr/share/doc/meshtasticd/web mkdir -p .debpkg/usr/sbin mkdir -p .debpkg/etc/meshtasticd + mkdir -p .debpkg/etc/meshtasticd/config.d + mkdir -p .debpkg/etc/meshtasticd/available.d mkdir -p .debpkg/usr/lib/systemd/system/ tar -xf build.tar -C .debpkg/usr/share/doc/meshtasticd/web gunzip .debpkg/usr/share/doc/meshtasticd/web/*.gz cp release/meshtasticd_linux_armv7l .debpkg/usr/sbin/meshtasticd cp bin/config-dist.yaml .debpkg/etc/meshtasticd/config.yaml + cp bin/config.d/* .debpkg/etc/meshtasticd/available.d/ chmod +x .debpkg/usr/sbin/meshtasticd cp bin/meshtasticd.service .debpkg/usr/lib/systemd/system/meshtasticd.service echo "/etc/meshtasticd/config.yaml" > .debpkg/DEBIAN/conffiles diff --git a/bin/config-dist.yaml b/bin/config-dist.yaml index e20ab0d33..bf1331a2b 100644 --- a/bin/config-dist.yaml +++ b/bin/config-dist.yaml @@ -1,15 +1,11 @@ +### Many device configs have been moved to /etc/meshtasticd/available.d +### To activate, simply copy or link the appropriate file into /etc/meshtasticd/config.d + ### Define your devices here using Broadcom pin numbering ### Uncomment the block that corresponds to your hardware ### Including the "Module:" line! --- Lora: -# Module: sx1262 # Waveshare SX126X XXXM -# DIO2_AS_RF_SWITCH: true -# CS: 21 -# IRQ: 16 -# Busy: 20 -# Reset: 18 -# SX126X_ANT_SW: 6 # Module: sx1262 # Waveshare SX1302 LISTEN ONLY AT THIS TIME! # CS: 7 @@ -179,3 +175,4 @@ Webserver: General: MaxNodes: 200 MaxMessageQueue: 100 + ConfigDirectory: /etc/meshtasticd/config.d/ \ No newline at end of file diff --git a/bin/config.d/display-waveshare-2.8.yaml b/bin/config.d/display-waveshare-2.8.yaml new file mode 100644 index 000000000..2e28276d8 --- /dev/null +++ b/bin/config.d/display-waveshare-2.8.yaml @@ -0,0 +1,18 @@ +Display: + +### Waveshare 2.8inch RPi LCD + Panel: ST7789 + CS: 8 + DC: 22 # Data/Command pin + Backlight: 18 + Width: 240 + Height: 320 + Reset: 27 + Rotate: true + Invert: true + +Touchscreen: +### Note, at least for now, the touchscreen must have a CS pin defined, even if you let Linux manage the CS switching. + Module: XPT2046 # Waveshare 2.8inch + CS: 7 + IRQ: 17 \ No newline at end of file diff --git a/bin/config.d/lora-waveshare-sxxx.yaml b/bin/config.d/lora-waveshare-sxxx.yaml new file mode 100644 index 000000000..a9ff13653 --- /dev/null +++ b/bin/config.d/lora-waveshare-sxxx.yaml @@ -0,0 +1,8 @@ +Lora: + Module: sx1262 # Waveshare SX126X XXXM + DIO2_AS_RF_SWITCH: true + CS: 21 + IRQ: 16 + Busy: 20 + Reset: 18 + SX126X_ANT_SW: 6 diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index e56016a5b..78562e47a 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -11,6 +11,7 @@ #include "PortduinoGlue.h" #include "linux/gpio/LinuxGPIOPin.h" #include "yaml-cpp/yaml.h" +#include #include #include #include @@ -100,33 +101,22 @@ void portduinoSetup() settingsStrings[displayspidev] = ""; settingsMap[spiSpeed] = 2000000; settingsMap[ascii_logs] = !isatty(1); + settingsMap[displayPanel] = no_screen; + settingsMap[touchscreenModule] = no_touchscreen; YAML::Node yamlConfig; if (configPath != nullptr) { - std::cout << "Using " << configPath << " as config file" << std::endl; - try { - yamlConfig = YAML::LoadFile(configPath); - } catch (YAML::Exception &e) { - std::cout << "Could not open " << configPath << " because of error: " << e.what() << std::endl; + if (loadConfig(configPath)) { + std::cout << "Using " << configPath << " as config file" << std::endl; + } else { + std::cout << "Unable to use " << configPath << " as config file" << std::endl; exit(EXIT_FAILURE); } - } else if (access("config.yaml", R_OK) == 0) { + } else if (access("config.yaml", R_OK) == 0 && loadConfig("config.yaml")) { std::cout << "Using local config.yaml as config file" << std::endl; - try { - yamlConfig = YAML::LoadFile("config.yaml"); - } catch (YAML::Exception &e) { - std::cout << "*** Exception " << e.what() << std::endl; - exit(EXIT_FAILURE); - } - } else if (access("/etc/meshtasticd/config.yaml", R_OK) == 0) { + } else if (access("/etc/meshtasticd/config.yaml", R_OK) == 0 && loadConfig("/etc/meshtasticd/config.yaml")) { std::cout << "Using /etc/meshtasticd/config.yaml as config file" << std::endl; - try { - yamlConfig = YAML::LoadFile("/etc/meshtasticd/config.yaml"); - } catch (YAML::Exception &e) { - std::cout << "*** Exception " << e.what() << std::endl; - exit(EXIT_FAILURE); - } } else { std::cout << "No 'config.yaml' found, running simulated." << std::endl; settingsMap[maxnodes] = 200; // Default to 200 nodes @@ -136,170 +126,21 @@ void portduinoSetup() return; } + if (settingsStrings[config_directory] != "") { + std::string filetype = ".yaml"; + for (const std::filesystem::directory_entry &entry : + std::filesystem::directory_iterator{settingsStrings[config_directory]}) { + if (ends_with(entry.path().string(), ".yaml")) { + std::cout << "Also using " << entry << " as additional config file" << std::endl; + loadConfig(entry.path().c_str()); + } + } + } + // Rather important to set this, if not running simulated. randomSeed(time(NULL)); - try { - if (yamlConfig["Logging"]) { - if (yamlConfig["Logging"]["LogLevel"].as("info") == "trace") { - settingsMap[logoutputlevel] = level_trace; - } else if (yamlConfig["Logging"]["LogLevel"].as("info") == "debug") { - settingsMap[logoutputlevel] = level_debug; - } else if (yamlConfig["Logging"]["LogLevel"].as("info") == "info") { - settingsMap[logoutputlevel] = level_info; - } else if (yamlConfig["Logging"]["LogLevel"].as("info") == "warn") { - settingsMap[logoutputlevel] = level_warn; - } else if (yamlConfig["Logging"]["LogLevel"].as("info") == "error") { - settingsMap[logoutputlevel] = level_error; - } - settingsStrings[traceFilename] = yamlConfig["Logging"]["TraceFile"].as(""); - if (yamlConfig["Logging"]["AsciiLogs"]) { - // Default is !isatty(1) but can be set explicitly in config.yaml - settingsMap[ascii_logs] = yamlConfig["Logging"]["AsciiLogs"].as(); - } - } - if (yamlConfig["Lora"]) { - settingsMap[use_sx1262] = false; - settingsMap[use_rf95] = false; - settingsMap[use_sx1280] = false; - settingsMap[use_sx1268] = false; - - if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1262") { - settingsMap[use_sx1262] = true; - } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "RF95") { - settingsMap[use_rf95] = true; - } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1280") { - settingsMap[use_sx1280] = true; - } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1268") { - settingsMap[use_sx1268] = true; - } - settingsMap[dio2_as_rf_switch] = yamlConfig["Lora"]["DIO2_AS_RF_SWITCH"].as(false); - settingsMap[dio3_tcxo_voltage] = yamlConfig["Lora"]["DIO3_TCXO_VOLTAGE"].as(false); - settingsMap[cs] = yamlConfig["Lora"]["CS"].as(RADIOLIB_NC); - settingsMap[irq] = yamlConfig["Lora"]["IRQ"].as(RADIOLIB_NC); - settingsMap[busy] = yamlConfig["Lora"]["Busy"].as(RADIOLIB_NC); - settingsMap[reset] = yamlConfig["Lora"]["Reset"].as(RADIOLIB_NC); - settingsMap[txen] = yamlConfig["Lora"]["TXen"].as(RADIOLIB_NC); - settingsMap[rxen] = yamlConfig["Lora"]["RXen"].as(RADIOLIB_NC); - settingsMap[sx126x_ant_sw] = yamlConfig["Lora"]["SX126X_ANT_SW"].as(RADIOLIB_NC); - settingsMap[gpiochip] = yamlConfig["Lora"]["gpiochip"].as(0); - settingsMap[ch341Quirk] = yamlConfig["Lora"]["ch341_quirk"].as(false); - settingsMap[spiSpeed] = yamlConfig["Lora"]["spiSpeed"].as(2000000); - gpioChipName += std::to_string(settingsMap[gpiochip]); - - settingsStrings[spidev] = "/dev/" + yamlConfig["Lora"]["spidev"].as("spidev0.0"); - if (settingsStrings[spidev].length() == 14) { - int x = settingsStrings[spidev].at(11) - '0'; - int y = settingsStrings[spidev].at(13) - '0'; - if (x >= 0 && x < 10 && y >= 0 && y < 10) { - settingsMap[spidev] = x + y << 4; - settingsMap[displayspidev] = settingsMap[spidev]; - settingsMap[touchscreenspidev] = settingsMap[spidev]; - } - } - } - if (yamlConfig["GPIO"]) { - settingsMap[user] = yamlConfig["GPIO"]["User"].as(RADIOLIB_NC); - } - if (yamlConfig["GPS"]) { - std::string serialPath = yamlConfig["GPS"]["SerialPath"].as(""); - if (serialPath != "") { - Serial1.setPath(serialPath); - settingsMap[has_gps] = 1; - } - } - if (yamlConfig["I2C"]) { - settingsStrings[i2cdev] = yamlConfig["I2C"]["I2CDevice"].as(""); - } - settingsMap[displayPanel] = no_screen; - if (yamlConfig["Display"]) { - if (yamlConfig["Display"]["Panel"].as("") == "ST7789") - settingsMap[displayPanel] = st7789; - else if (yamlConfig["Display"]["Panel"].as("") == "ST7735") - settingsMap[displayPanel] = st7735; - else if (yamlConfig["Display"]["Panel"].as("") == "ST7735S") - settingsMap[displayPanel] = st7735s; - else if (yamlConfig["Display"]["Panel"].as("") == "ST7796") - settingsMap[displayPanel] = st7796; - else if (yamlConfig["Display"]["Panel"].as("") == "ILI9341") - settingsMap[displayPanel] = ili9341; - else if (yamlConfig["Display"]["Panel"].as("") == "ILI9342") - settingsMap[displayPanel] = ili9342; - else if (yamlConfig["Display"]["Panel"].as("") == "ILI9488") - settingsMap[displayPanel] = ili9488; - else if (yamlConfig["Display"]["Panel"].as("") == "HX8357D") - settingsMap[displayPanel] = hx8357d; - else if (yamlConfig["Display"]["Panel"].as("") == "X11") - settingsMap[displayPanel] = x11; - settingsMap[displayHeight] = yamlConfig["Display"]["Height"].as(0); - settingsMap[displayWidth] = yamlConfig["Display"]["Width"].as(0); - settingsMap[displayDC] = yamlConfig["Display"]["DC"].as(-1); - settingsMap[displayCS] = yamlConfig["Display"]["CS"].as(-1); - settingsMap[displayRGBOrder] = yamlConfig["Display"]["RGBOrder"].as(false); - settingsMap[displayBacklight] = yamlConfig["Display"]["Backlight"].as(-1); - settingsMap[displayBacklightInvert] = yamlConfig["Display"]["BacklightInvert"].as(false); - settingsMap[displayBacklightPWMChannel] = yamlConfig["Display"]["BacklightPWMChannel"].as(-1); - settingsMap[displayReset] = yamlConfig["Display"]["Reset"].as(-1); - settingsMap[displayOffsetX] = yamlConfig["Display"]["OffsetX"].as(0); - settingsMap[displayOffsetY] = yamlConfig["Display"]["OffsetY"].as(0); - settingsMap[displayRotate] = yamlConfig["Display"]["Rotate"].as(false); - settingsMap[displayOffsetRotate] = yamlConfig["Display"]["OffsetRotate"].as(1); - settingsMap[displayInvert] = yamlConfig["Display"]["Invert"].as(false); - settingsMap[displayBusFrequency] = yamlConfig["Display"]["BusFrequency"].as(40000000); - if (yamlConfig["Display"]["spidev"]) { - settingsStrings[displayspidev] = "/dev/" + yamlConfig["Display"]["spidev"].as("spidev0.1"); - if (settingsStrings[displayspidev].length() == 14) { - int x = settingsStrings[displayspidev].at(11) - '0'; - int y = settingsStrings[displayspidev].at(13) - '0'; - if (x >= 0 && x < 10 && y >= 0 && y < 10) { - settingsMap[displayspidev] = x + y << 4; - settingsMap[touchscreenspidev] = settingsMap[displayspidev]; - } - } - } - } - settingsMap[touchscreenModule] = no_touchscreen; - if (yamlConfig["Touchscreen"]) { - if (yamlConfig["Touchscreen"]["Module"].as("") == "XPT2046") - settingsMap[touchscreenModule] = xpt2046; - else if (yamlConfig["Touchscreen"]["Module"].as("") == "STMPE610") - settingsMap[touchscreenModule] = stmpe610; - else if (yamlConfig["Touchscreen"]["Module"].as("") == "GT911") - settingsMap[touchscreenModule] = gt911; - else if (yamlConfig["Touchscreen"]["Module"].as("") == "FT5x06") - settingsMap[touchscreenModule] = ft5x06; - settingsMap[touchscreenCS] = yamlConfig["Touchscreen"]["CS"].as(-1); - settingsMap[touchscreenIRQ] = yamlConfig["Touchscreen"]["IRQ"].as(-1); - settingsMap[touchscreenBusFrequency] = yamlConfig["Touchscreen"]["BusFrequency"].as(1000000); - settingsMap[touchscreenRotate] = yamlConfig["Touchscreen"]["Rotate"].as(-1); - settingsMap[touchscreenI2CAddr] = yamlConfig["Touchscreen"]["I2CAddr"].as(-1); - if (yamlConfig["Touchscreen"]["spidev"]) { - settingsStrings[touchscreenspidev] = "/dev/" + yamlConfig["Touchscreen"]["spidev"].as(""); - if (settingsStrings[touchscreenspidev].length() == 14) { - int x = settingsStrings[touchscreenspidev].at(11) - '0'; - int y = settingsStrings[touchscreenspidev].at(13) - '0'; - if (x >= 0 && x < 10 && y >= 0 && y < 10) { - settingsMap[touchscreenspidev] = x + y << 4; - } - } - } - } - if (yamlConfig["Input"]) { - settingsStrings[keyboardDevice] = (yamlConfig["Input"]["KeyboardDevice"]).as(""); - } - - if (yamlConfig["Webserver"]) { - settingsMap[webserverport] = (yamlConfig["Webserver"]["Port"]).as(-1); - settingsStrings[webserverrootpath] = (yamlConfig["Webserver"]["RootPath"]).as(""); - } - - settingsMap[maxnodes] = (yamlConfig["General"]["MaxNodes"]).as(200); - settingsMap[maxtophone] = (yamlConfig["General"]["MaxMessageQueue"]).as(100); - - } catch (YAML::Exception &e) { - std::cout << "*** Exception " << e.what() << std::endl; - exit(EXIT_FAILURE); - } + gpioChipName += std::to_string(settingsMap[gpiochip]); for (configNames i : GPIO_lines) { if (settingsMap.count(i) && settingsMap[i] > max_GPIO) @@ -402,4 +243,178 @@ int initGPIOPin(int pinNum, const std::string gpioChipName) #else return ERRNO_OK; #endif +} + +bool loadConfig(const char *configPath) +{ + YAML::Node yamlConfig; + try { + yamlConfig = YAML::LoadFile(configPath); + if (yamlConfig["Logging"]) { + if (yamlConfig["Logging"]["LogLevel"].as("info") == "trace") { + settingsMap[logoutputlevel] = level_trace; + } else if (yamlConfig["Logging"]["LogLevel"].as("info") == "debug") { + settingsMap[logoutputlevel] = level_debug; + } else if (yamlConfig["Logging"]["LogLevel"].as("info") == "info") { + settingsMap[logoutputlevel] = level_info; + } else if (yamlConfig["Logging"]["LogLevel"].as("info") == "warn") { + settingsMap[logoutputlevel] = level_warn; + } else if (yamlConfig["Logging"]["LogLevel"].as("info") == "error") { + settingsMap[logoutputlevel] = level_error; + } + settingsStrings[traceFilename] = yamlConfig["Logging"]["TraceFile"].as(""); + if (yamlConfig["Logging"]["AsciiLogs"]) { + // Default is !isatty(1) but can be set explicitly in config.yaml + settingsMap[ascii_logs] = yamlConfig["Logging"]["AsciiLogs"].as(); + } + } + if (yamlConfig["Lora"]) { + settingsMap[use_sx1262] = false; + settingsMap[use_rf95] = false; + settingsMap[use_sx1280] = false; + settingsMap[use_sx1268] = false; + + if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1262") { + settingsMap[use_sx1262] = true; + } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "RF95") { + settingsMap[use_rf95] = true; + } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1280") { + settingsMap[use_sx1280] = true; + } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1268") { + settingsMap[use_sx1268] = true; + } + settingsMap[dio2_as_rf_switch] = yamlConfig["Lora"]["DIO2_AS_RF_SWITCH"].as(false); + settingsMap[dio3_tcxo_voltage] = yamlConfig["Lora"]["DIO3_TCXO_VOLTAGE"].as(false); + settingsMap[cs] = yamlConfig["Lora"]["CS"].as(RADIOLIB_NC); + settingsMap[irq] = yamlConfig["Lora"]["IRQ"].as(RADIOLIB_NC); + settingsMap[busy] = yamlConfig["Lora"]["Busy"].as(RADIOLIB_NC); + settingsMap[reset] = yamlConfig["Lora"]["Reset"].as(RADIOLIB_NC); + settingsMap[txen] = yamlConfig["Lora"]["TXen"].as(RADIOLIB_NC); + settingsMap[rxen] = yamlConfig["Lora"]["RXen"].as(RADIOLIB_NC); + settingsMap[sx126x_ant_sw] = yamlConfig["Lora"]["SX126X_ANT_SW"].as(RADIOLIB_NC); + settingsMap[gpiochip] = yamlConfig["Lora"]["gpiochip"].as(0); + settingsMap[ch341Quirk] = yamlConfig["Lora"]["ch341_quirk"].as(false); + settingsMap[spiSpeed] = yamlConfig["Lora"]["spiSpeed"].as(2000000); + + settingsStrings[spidev] = "/dev/" + yamlConfig["Lora"]["spidev"].as("spidev0.0"); + if (settingsStrings[spidev].length() == 14) { + int x = settingsStrings[spidev].at(11) - '0'; + int y = settingsStrings[spidev].at(13) - '0'; + if (x >= 0 && x < 10 && y >= 0 && y < 10) { + settingsMap[spidev] = x + y << 4; + settingsMap[displayspidev] = settingsMap[spidev]; + settingsMap[touchscreenspidev] = settingsMap[spidev]; + } + } + } + if (yamlConfig["GPIO"]) { + settingsMap[user] = yamlConfig["GPIO"]["User"].as(RADIOLIB_NC); + } + if (yamlConfig["GPS"]) { + std::string serialPath = yamlConfig["GPS"]["SerialPath"].as(""); + if (serialPath != "") { + Serial1.setPath(serialPath); + settingsMap[has_gps] = 1; + } + } + if (yamlConfig["I2C"]) { + settingsStrings[i2cdev] = yamlConfig["I2C"]["I2CDevice"].as(""); + } + if (yamlConfig["Display"]) { + if (yamlConfig["Display"]["Panel"].as("") == "ST7789") + settingsMap[displayPanel] = st7789; + else if (yamlConfig["Display"]["Panel"].as("") == "ST7735") + settingsMap[displayPanel] = st7735; + else if (yamlConfig["Display"]["Panel"].as("") == "ST7735S") + settingsMap[displayPanel] = st7735s; + else if (yamlConfig["Display"]["Panel"].as("") == "ST7796") + settingsMap[displayPanel] = st7796; + else if (yamlConfig["Display"]["Panel"].as("") == "ILI9341") + settingsMap[displayPanel] = ili9341; + else if (yamlConfig["Display"]["Panel"].as("") == "ILI9342") + settingsMap[displayPanel] = ili9342; + else if (yamlConfig["Display"]["Panel"].as("") == "ILI9488") + settingsMap[displayPanel] = ili9488; + else if (yamlConfig["Display"]["Panel"].as("") == "HX8357D") + settingsMap[displayPanel] = hx8357d; + else if (yamlConfig["Display"]["Panel"].as("") == "X11") + settingsMap[displayPanel] = x11; + settingsMap[displayHeight] = yamlConfig["Display"]["Height"].as(0); + settingsMap[displayWidth] = yamlConfig["Display"]["Width"].as(0); + settingsMap[displayDC] = yamlConfig["Display"]["DC"].as(-1); + settingsMap[displayCS] = yamlConfig["Display"]["CS"].as(-1); + settingsMap[displayRGBOrder] = yamlConfig["Display"]["RGBOrder"].as(false); + settingsMap[displayBacklight] = yamlConfig["Display"]["Backlight"].as(-1); + settingsMap[displayBacklightInvert] = yamlConfig["Display"]["BacklightInvert"].as(false); + settingsMap[displayBacklightPWMChannel] = yamlConfig["Display"]["BacklightPWMChannel"].as(-1); + settingsMap[displayReset] = yamlConfig["Display"]["Reset"].as(-1); + settingsMap[displayOffsetX] = yamlConfig["Display"]["OffsetX"].as(0); + settingsMap[displayOffsetY] = yamlConfig["Display"]["OffsetY"].as(0); + settingsMap[displayRotate] = yamlConfig["Display"]["Rotate"].as(false); + settingsMap[displayOffsetRotate] = yamlConfig["Display"]["OffsetRotate"].as(1); + settingsMap[displayInvert] = yamlConfig["Display"]["Invert"].as(false); + settingsMap[displayBusFrequency] = yamlConfig["Display"]["BusFrequency"].as(40000000); + if (yamlConfig["Display"]["spidev"]) { + settingsStrings[displayspidev] = "/dev/" + yamlConfig["Display"]["spidev"].as("spidev0.1"); + if (settingsStrings[displayspidev].length() == 14) { + int x = settingsStrings[displayspidev].at(11) - '0'; + int y = settingsStrings[displayspidev].at(13) - '0'; + if (x >= 0 && x < 10 && y >= 0 && y < 10) { + settingsMap[displayspidev] = x + y << 4; + settingsMap[touchscreenspidev] = settingsMap[displayspidev]; + } + } + } + } + if (yamlConfig["Touchscreen"]) { + if (yamlConfig["Touchscreen"]["Module"].as("") == "XPT2046") + settingsMap[touchscreenModule] = xpt2046; + else if (yamlConfig["Touchscreen"]["Module"].as("") == "STMPE610") + settingsMap[touchscreenModule] = stmpe610; + else if (yamlConfig["Touchscreen"]["Module"].as("") == "GT911") + settingsMap[touchscreenModule] = gt911; + else if (yamlConfig["Touchscreen"]["Module"].as("") == "FT5x06") + settingsMap[touchscreenModule] = ft5x06; + settingsMap[touchscreenCS] = yamlConfig["Touchscreen"]["CS"].as(-1); + settingsMap[touchscreenIRQ] = yamlConfig["Touchscreen"]["IRQ"].as(-1); + settingsMap[touchscreenBusFrequency] = yamlConfig["Touchscreen"]["BusFrequency"].as(1000000); + settingsMap[touchscreenRotate] = yamlConfig["Touchscreen"]["Rotate"].as(-1); + settingsMap[touchscreenI2CAddr] = yamlConfig["Touchscreen"]["I2CAddr"].as(-1); + if (yamlConfig["Touchscreen"]["spidev"]) { + settingsStrings[touchscreenspidev] = "/dev/" + yamlConfig["Touchscreen"]["spidev"].as(""); + if (settingsStrings[touchscreenspidev].length() == 14) { + int x = settingsStrings[touchscreenspidev].at(11) - '0'; + int y = settingsStrings[touchscreenspidev].at(13) - '0'; + if (x >= 0 && x < 10 && y >= 0 && y < 10) { + settingsMap[touchscreenspidev] = x + y << 4; + } + } + } + } + if (yamlConfig["Input"]) { + settingsStrings[keyboardDevice] = (yamlConfig["Input"]["KeyboardDevice"]).as(""); + } + + if (yamlConfig["Webserver"]) { + settingsMap[webserverport] = (yamlConfig["Webserver"]["Port"]).as(-1); + settingsStrings[webserverrootpath] = (yamlConfig["Webserver"]["RootPath"]).as(""); + } + + if (yamlConfig["General"]) { + settingsMap[maxnodes] = (yamlConfig["General"]["MaxNodes"]).as(200); + settingsMap[maxtophone] = (yamlConfig["General"]["MaxMessageQueue"]).as(100); + settingsStrings[config_directory] = (yamlConfig["General"]["ConfigDirectory"]).as(""); + } + + } catch (YAML::Exception &e) { + std::cout << "*** Exception " << e.what() << std::endl; + return false; + } + return true; +} + +// https://stackoverflow.com/questions/874134/find-out-if-string-ends-with-another-string-in-c +static bool ends_with(std::string_view str, std::string_view suffix) +{ + return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } \ No newline at end of file diff --git a/src/platform/portduino/PortduinoGlue.h b/src/platform/portduino/PortduinoGlue.h index 8ee96717e..95d82c1a2 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -55,7 +55,8 @@ enum configNames { webserverrootpath, maxtophone, maxnodes, - ascii_logs + ascii_logs, + config_directory }; enum { no_screen, x11, st7789, st7735, st7735s, st7796, ili9341, ili9342, ili9488, hx8357d }; enum { no_touchscreen, xpt2046, stmpe610, gt911, ft5x06 }; @@ -64,4 +65,6 @@ enum { level_error, level_warn, level_info, level_debug, level_trace }; extern std::map settingsMap; extern std::map settingsStrings; extern std::ofstream traceFile; -int initGPIOPin(int pinNum, std::string gpioChipname); \ No newline at end of file +int initGPIOPin(int pinNum, std::string gpioChipname); +bool loadConfig(const char *configPath); +static bool ends_with(std::string_view str, std::string_view suffix); \ No newline at end of file From ed03d28a838e650ceea68f9fd5e01454bf6e9bf6 Mon Sep 17 00:00:00 2001 From: Megaceryle-alcyon Date: Tue, 29 Oct 2024 01:34:01 -0700 Subject: [PATCH 17/46] Added PA1616S GPS module (#5157) * Added GPS chip PA1616S GPS chip PA1616S is used in some recent Adafruit GPS breakout boards. * Update GPS.cpp --------- Co-authored-by: picusviridis --- src/gps/GPS.cpp | 13 +++++++++++++ src/gps/GPS.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 2dda776e1..e81331760 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -476,6 +476,18 @@ bool GPS::setup() // Switch to Fitness Mode, for running and walking purpose with low speed (<5 m/s) _serial_gps->write("$PMTK886,1*29\r\n"); delay(250); + } else if (gnssModel == GNSS_MODEL_MTK_PA1616S) { + // PA1616S is used in some GPS breakout boards from Adafruit + // PA1616S does not have GLONASS capability. PA1616D does, but is not implemented here. + _serial_gps->write("$PMTK353,1,0,0,0,0*2A\r\n"); + // Above command will reset the GPS and takes longer before it will accept new commands + delay(1000); + // Only ask for RMC and GGA (GNRMC and GNGGA) + _serial_gps->write("$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n"); + delay(250); + // Enable SBAS / WAAS + _serial_gps->write("$PMTK301,2*2E\r\n"); + delay(250); } else if (gnssModel == GNSS_MODEL_ATGM336H) { // Set the intial configuration of the device - these _should_ work for most AT6558 devices msglen = makeCASPacket(0x06, 0x07, sizeof(_message_CAS_CFG_NAVX_CONF), _message_CAS_CFG_NAVX_CONF); @@ -1144,6 +1156,7 @@ GnssModel_t GPS::probe(int serialSpeed) delay(20); PROBE_SIMPLE("L76B", "$PMTK605*31", "Quectel-L76B", GNSS_MODEL_MTK_L76B, 500); + PROBE_SIMPLE("PA1616S", "$PMTK605*31", "1616S", GNSS_MODEL_MTK_PA1616S, 500); uint8_t cfg_rate[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00}; UBXChecksum(cfg_rate, sizeof(cfg_rate)); diff --git a/src/gps/GPS.h b/src/gps/GPS.h index 8b1982cf7..533f6b525 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -34,6 +34,7 @@ typedef enum { GNSS_MODEL_UC6580, GNSS_MODEL_UNKNOWN, GNSS_MODEL_MTK_L76B, + GNSS_MODEL_MTK_PA1616S, GNSS_MODEL_AG3335, GNSS_MODEL_AG3352 } GnssModel_t; From 2945b9cfbeea12a8c5253f58e0cc849cf78ea175 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Tue, 29 Oct 2024 21:41:21 +1100 Subject: [PATCH 18/46] De-duplicate Ambient LED management code (#5156) We currently have 4 different places where we have the logic for modifying LED state of the various types of Ambient LEDs, ExternalNotificationModule::SetExternalOff ExternalNotificationModule::SetExternalOn AmbientLightingThread::setLighting AmbientLightingThread::setLightingOff This patch de-duplicates the methods in ExternalNotification to a single method, using a boolean to toggle whether we're turning things on or off. --- src/modules/ExternalNotificationModule.cpp | 110 +++++++-------------- src/modules/ExternalNotificationModule.h | 3 +- 2 files changed, 35 insertions(+), 78 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index 87387f0a4..41ad0ea65 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -93,7 +93,7 @@ int32_t ExternalNotificationModule::runOnce() nagCycleCutoff = UINT32_MAX; LOG_INFO("Turning off external notification: "); for (int i = 0; i < 3; i++) { - setExternalOff(i); + setExternalState(i, false); externalTurnedOn[i] = 0; LOG_INFO("%d ", i); } @@ -114,17 +114,17 @@ int32_t ExternalNotificationModule::runOnce() if (externalTurnedOn[0] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { - getExternal(0) ? setExternalOff(0) : setExternalOn(0); + setExternalState(0, !getExternal(0)); } if (externalTurnedOn[1] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { - getExternal(1) ? setExternalOff(1) : setExternalOn(1); + setExternalState(0, !getExternal(1)); } if (externalTurnedOn[2] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { - getExternal(2) ? setExternalOff(2) : setExternalOn(2); + setExternalState(0, !getExternal(2)); } #if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) red = (colorState & 4) ? brightnessValues[brightnessIndex] : 0; // Red enabled on colorState = 4,5,6,7 @@ -203,86 +203,42 @@ bool ExternalNotificationModule::wantPacket(const meshtastic_MeshPacket *p) } /** - * Sets the external notification on for the specified index. + * Sets the external notification for the specified index. * - * @param index The index of the external notification to turn on. + * @param index The index of the external notification to change state. + * @param on Whether we are turning things on (true) or off (false). */ -void ExternalNotificationModule::setExternalOn(uint8_t index) +void ExternalNotificationModule::setExternalState(uint8_t index, bool on) { - externalCurrentState[index] = 1; + externalCurrentState[index] = on; externalTurnedOn[index] = millis(); switch (index) { case 1: #ifdef UNPHONE - unphone.vibe(true); // the unPhone's vibration motor is on a i2c GPIO expander + unphone.vibe(on); // the unPhone's vibration motor is on a i2c GPIO expander #endif if (moduleConfig.external_notification.output_vibra) - digitalWrite(moduleConfig.external_notification.output_vibra, true); + digitalWrite(moduleConfig.external_notification.output_vibra, on); break; case 2: if (moduleConfig.external_notification.output_buzzer) - digitalWrite(moduleConfig.external_notification.output_buzzer, true); + digitalWrite(moduleConfig.external_notification.output_buzzer, on); break; default: if (output > 0) - digitalWrite(output, (moduleConfig.external_notification.active ? true : false)); - break; - } - -#ifdef HAS_NCP5623 - if (rgb_found.type == ScanI2C::NCP5623) { - rgb.setColor(red, green, blue); - } -#endif -#ifdef RGBLED_CA - analogWrite(RGBLED_RED, 255 - red); // CA type needs reverse logic - analogWrite(RGBLED_GREEN, 255 - green); - analogWrite(RGBLED_BLUE, 255 - blue); -#elif defined(RGBLED_RED) - analogWrite(RGBLED_RED, red); - analogWrite(RGBLED_GREEN, green); - analogWrite(RGBLED_BLUE, blue); -#endif -#ifdef HAS_NEOPIXEL - pixels.fill(pixels.Color(red, green, blue), 0, NEOPIXEL_COUNT); - pixels.show(); -#endif -#ifdef UNPHONE - unphone.rgb(red, green, blue); -#endif -#ifdef T_WATCH_S3 - drv.go(); -#endif -} - -void ExternalNotificationModule::setExternalOff(uint8_t index) -{ - externalCurrentState[index] = 0; - externalTurnedOn[index] = millis(); - - switch (index) { - case 1: -#ifdef UNPHONE - unphone.vibe(false); // the unPhone's vibration motor is on a i2c GPIO expander -#endif - if (moduleConfig.external_notification.output_vibra) - digitalWrite(moduleConfig.external_notification.output_vibra, false); - break; - case 2: - if (moduleConfig.external_notification.output_buzzer) - digitalWrite(moduleConfig.external_notification.output_buzzer, false); - break; - default: - if (output > 0) - digitalWrite(output, (moduleConfig.external_notification.active ? false : true)); + digitalWrite(output, (moduleConfig.external_notification.active ? on : !on)); break; } #if defined(HAS_NCP5623) || defined(RGBLED_RED) || defined(HAS_NEOPIXEL) || defined(UNPHONE) - red = 0; - green = 0; - blue = 0; + if (!on) { + red = 0; + green = 0; + blue = 0; + } +#endif + #ifdef HAS_NCP5623 if (rgb_found.type == ScanI2C::NCP5623) { rgb.setColor(red, green, blue); @@ -304,10 +260,12 @@ void ExternalNotificationModule::setExternalOff(uint8_t index) #ifdef UNPHONE unphone.rgb(red, green, blue); #endif -#endif - #ifdef T_WATCH_S3 - drv.stop(); + if (on) { + drv.go(); + } else { + drv.stop(); + } #endif } @@ -379,19 +337,19 @@ ExternalNotificationModule::ExternalNotificationModule() LOG_INFO("Using Pin %i in digital mode", output); pinMode(output, OUTPUT); } - setExternalOff(0); + setExternalState(0, false); externalTurnedOn[0] = 0; if (moduleConfig.external_notification.output_vibra) { LOG_INFO("Using Pin %i for vibra motor", moduleConfig.external_notification.output_vibra); pinMode(moduleConfig.external_notification.output_vibra, OUTPUT); - setExternalOff(1); + setExternalState(1, false); externalTurnedOn[1] = 0; } if (moduleConfig.external_notification.output_buzzer) { if (!moduleConfig.external_notification.use_pwm) { LOG_INFO("Using Pin %i for buzzer", moduleConfig.external_notification.output_buzzer); pinMode(moduleConfig.external_notification.output_buzzer, OUTPUT); - setExternalOff(2); + setExternalState(2, false); externalTurnedOn[2] = 0; } else { config.device.buzzer_gpio = config.device.buzzer_gpio ? config.device.buzzer_gpio : PIN_BUZZER; @@ -449,7 +407,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP if (containsBell) { LOG_INFO("externalNotificationModule - Notification Bell"); isNagging = true; - setExternalOn(0); + setExternalState(0, true); if (moduleConfig.external_notification.nag_timeout) { nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000; } else { @@ -462,7 +420,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP if (containsBell) { LOG_INFO("externalNotificationModule - Notification Bell (Vibra)"); isNagging = true; - setExternalOn(1); + setExternalState(1, true); if (moduleConfig.external_notification.nag_timeout) { nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000; } else { @@ -476,7 +434,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP LOG_INFO("externalNotificationModule - Notification Bell (Buzzer)"); isNagging = true; if (!moduleConfig.external_notification.use_pwm) { - setExternalOn(2); + setExternalState(2, true); } else { #ifdef HAS_I2S audioThread->beginRttl(rtttlConfig.ringtone, strlen_P(rtttlConfig.ringtone)); @@ -495,7 +453,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP if (moduleConfig.external_notification.alert_message) { LOG_INFO("externalNotificationModule - Notification Module"); isNagging = true; - setExternalOn(0); + setExternalState(0, true); if (moduleConfig.external_notification.nag_timeout) { nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000; } else { @@ -506,7 +464,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP if (moduleConfig.external_notification.alert_message_vibra) { LOG_INFO("externalNotificationModule - Notification Module (Vibra)"); isNagging = true; - setExternalOn(1); + setExternalState(1, true); if (moduleConfig.external_notification.nag_timeout) { nagCycleCutoff = millis() + moduleConfig.external_notification.nag_timeout * 1000; } else { @@ -518,7 +476,7 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP LOG_INFO("externalNotificationModule - Notification Module (Buzzer)"); isNagging = true; if (!moduleConfig.external_notification.use_pwm && !moduleConfig.external_notification.use_i2s_as_buzzer) { - setExternalOn(2); + setExternalState(2, true); } else { #ifdef HAS_I2S if (moduleConfig.external_notification.use_i2s_as_buzzer) { diff --git a/src/modules/ExternalNotificationModule.h b/src/modules/ExternalNotificationModule.h index 20d02d68b..841ca6de9 100644 --- a/src/modules/ExternalNotificationModule.h +++ b/src/modules/ExternalNotificationModule.h @@ -34,8 +34,7 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency: uint32_t nagCycleCutoff = 1; - void setExternalOn(uint8_t index = 0); - void setExternalOff(uint8_t index = 0); + void setExternalState(uint8_t index = 0, bool on = false); bool getExternal(uint8_t index = 0); void setMute(bool mute) { isMuted = mute; } From 936260fca36cc69f925ca6eb19983965fdf68b31 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 29 Oct 2024 05:44:32 -0500 Subject: [PATCH 19/46] Default rebroadcast mode for Router and Repeater to ignore problematic portnums (#5178) * Default rebroadcast mode for Router and Repeater to ignore problematic portnums * Verbiage * IS_ONE_OF --- src/mesh/NodeDB.cpp | 2 ++ src/mesh/Router.cpp | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 69cd631c0..b842420d3 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -557,8 +557,10 @@ void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role) if (role == meshtastic_Config_DeviceConfig_Role_ROUTER) { initConfigIntervals(); initModuleConfigIntervals(); + config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_CORE_PORTNUMS_ONLY; } else if (role == meshtastic_Config_DeviceConfig_Role_REPEATER) { config.display.screen_on_secs = 1; + config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_CORE_PORTNUMS_ONLY; } else if (role == meshtastic_Config_DeviceConfig_Role_SENSOR) { moduleConfig.telemetry.environment_measurement_enabled = true; moduleConfig.telemetry.environment_update_interval = 300; diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 84ae7bbb0..d82268cc6 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -591,19 +591,20 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) skipHandle = true; } + bool shouldIgnoreNonstandardPorts = + config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_CORE_PORTNUMS_ONLY; #if USERPREFS_EVENT_MODE - if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag && - (p->decoded.portnum == meshtastic_PortNum_ATAK_FORWARDER || p->decoded.portnum == meshtastic_PortNum_ATAK_PLUGIN || - p->decoded.portnum == meshtastic_PortNum_PAXCOUNTER_APP || p->decoded.portnum == meshtastic_PortNum_IP_TUNNEL_APP || - p->decoded.portnum == meshtastic_PortNum_AUDIO_APP || p->decoded.portnum == meshtastic_PortNum_PRIVATE_APP || - p->decoded.portnum == meshtastic_PortNum_DETECTION_SENSOR_APP || - p->decoded.portnum == meshtastic_PortNum_RANGE_TEST_APP || - p->decoded.portnum == meshtastic_PortNum_REMOTE_HARDWARE_APP)) { - LOG_DEBUG("Ignoring packet on blacklisted portnum during event"); + shouldIgnoreNonstandardPorts = true; +#endif + if (shouldIgnoreNonstandardPorts && p->which_payload_variant == meshtastic_MeshPacket_decoded_tag && + IS_ONE_OF(p->decoded.portnum, meshtastic_PortNum_ATAK_FORWARDER, meshtastic_PortNum_ATAK_PLUGIN, + meshtastic_PortNum_PAXCOUNTER_APP, meshtastic_PortNum_IP_TUNNEL_APP, meshtastic_PortNum_AUDIO_APP, + meshtastic_PortNum_PRIVATE_APP, meshtastic_PortNum_DETECTION_SENSOR_APP, meshtastic_PortNum_RANGE_TEST_APP, + meshtastic_PortNum_REMOTE_HARDWARE_APP)) { + LOG_DEBUG("Ignoring packet on blacklisted portnum for CORE_PORTNUMS_ONLY"); cancelSending(p->from, p->id); skipHandle = true; } -#endif } else { printPacket("packet decoding failed or skipped (no PSK?)", p); } From b3ba23b4e897763972c193c860f3e955f947af18 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 29 Oct 2024 14:17:14 -0500 Subject: [PATCH 20/46] Don't generate or populate PKC keys in licensed mode --- src/mesh/NodeDB.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index b842420d3..6b2991958 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -174,21 +174,23 @@ NodeDB::NodeDB() } #if !(MESHTASTIC_EXCLUDE_PKI_KEYGEN || MESHTASTIC_EXCLUDE_PKI) - bool keygenSuccess = false; - if (config.security.private_key.size == 32) { - if (crypto->regeneratePublicKey(config.security.public_key.bytes, config.security.private_key.bytes)) { + if (!owner.is_licensed) { + bool keygenSuccess = false; + if (config.security.private_key.size == 32) { + if (crypto->regeneratePublicKey(config.security.public_key.bytes, config.security.private_key.bytes)) { + keygenSuccess = true; + } + } else { + LOG_INFO("Generating new PKI keys"); + crypto->generateKeyPair(config.security.public_key.bytes, config.security.private_key.bytes); keygenSuccess = true; } - } else { - LOG_INFO("Generating new PKI keys"); - crypto->generateKeyPair(config.security.public_key.bytes, config.security.private_key.bytes); - keygenSuccess = true; - } - if (keygenSuccess) { - config.security.public_key.size = 32; - config.security.private_key.size = 32; - owner.public_key.size = 32; - memcpy(owner.public_key.bytes, config.security.public_key.bytes, 32); + if (keygenSuccess) { + config.security.public_key.size = 32; + config.security.private_key.size = 32; + owner.public_key.size = 32; + memcpy(owner.public_key.bytes, config.security.public_key.bytes, 32); + } } #elif !(MESHTASTIC_EXCLUDE_PKI) // Calculate Curve25519 public and private keys @@ -1276,4 +1278,4 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co LOG_ERROR("A critical failure occurred, portduino is exiting..."); exit(2); #endif -} +} \ No newline at end of file From cc59a50cbabb8fdd13fa3dc555839f9b3572b321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 30 Oct 2024 10:14:59 +0100 Subject: [PATCH 21/46] Test: mark issues as stale --- .github/workflows/stale_bot.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/stale_bot.yml diff --git a/.github/workflows/stale_bot.yml b/.github/workflows/stale_bot.yml new file mode 100644 index 000000000..00ea24737 --- /dev/null +++ b/.github/workflows/stale_bot.yml @@ -0,0 +1,22 @@ +name: Nightly +on: + schedule: + - cron: 0 6 * * * + workflow_dispatch: {} + +permissions: + issues: write + pull-requests: write + +jobs: + stale_issues: + name: Close Stale Issues + runs-on: ubuntu-latest + + steps: + - name: Stale PR+Issues + uses: actions/stale@v9.0.0 + with: + debug-only: true + exempt-issue-labels: pinned + exempt-pr-labels: pinned From 50fb575caa1135118bdfde37ea8175533cf10c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 30 Oct 2024 10:16:40 +0100 Subject: [PATCH 22/46] Update stale_bot.yml --- .github/workflows/stale_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale_bot.yml b/.github/workflows/stale_bot.yml index 00ea24737..63701c68d 100644 --- a/.github/workflows/stale_bot.yml +++ b/.github/workflows/stale_bot.yml @@ -1,4 +1,4 @@ -name: Nightly +name: process stale Issues and PR's on: schedule: - cron: 0 6 * * * From 0726eaa6787cf19c9e5fd475171e5e2042f51ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 30 Oct 2024 10:43:08 +0100 Subject: [PATCH 23/46] Update stale_bot.yml --- .github/workflows/stale_bot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale_bot.yml b/.github/workflows/stale_bot.yml index 63701c68d..a1ece1d19 100644 --- a/.github/workflows/stale_bot.yml +++ b/.github/workflows/stale_bot.yml @@ -18,5 +18,5 @@ jobs: uses: actions/stale@v9.0.0 with: debug-only: true - exempt-issue-labels: pinned - exempt-pr-labels: pinned + exempt-issue-labels: pinned,3.0 + exempt-pr-labels: pinned,3.0 From 5f6e19d971e0ba57f5b42ea9171b26314f74da88 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 30 Oct 2024 06:02:59 -0500 Subject: [PATCH 24/46] As a Router --- .trunk/trunk.yaml | 8 ++++---- src/mesh/RadioInterface.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index ad8864ab7..2fa237d31 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -8,15 +8,15 @@ plugins: uri: https://github.com/trunk-io/plugins lint: enabled: - - trufflehog@3.82.12 + - trufflehog@3.82.13 - yamllint@1.35.1 - bandit@1.7.10 - - checkov@3.2.256 + - checkov@3.2.269 - terrascan@1.19.9 - - trivy@0.55.2 + - trivy@0.56.2 #- trufflehog@3.63.2-rc0 - taplo@0.9.3 - - ruff@0.7.0 + - ruff@0.7.1 - isort@5.13.2 - markdownlint@0.42.0 - oxipng@9.1.2 diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index f51c9bcb9..e8f6d1c07 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -271,7 +271,7 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr) if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER || config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER) { delay = random(0, 2 * CWsize) * slotTimeMsec; - LOG_DEBUG("rx_snr found in packet. As a router, setting tx delay:%d", delay); + LOG_DEBUG("rx_snr found in packet. Router: setting tx delay:%d", delay); } else { // offset the maximum delay for routers: (2 * CWmax * slotTimeMsec) delay = (2 * CWmax * slotTimeMsec) + random(0, pow(2, CWsize)) * slotTimeMsec; From 28b469dbf00e3e341ed4254b5e915592a3618eb6 Mon Sep 17 00:00:00 2001 From: Andre K Date: Wed, 30 Oct 2024 14:05:09 -0300 Subject: [PATCH 25/46] fix: don't broadcast public keys if the user is licensed (#5190) Co-authored-by: Ben Meadors Co-authored-by: Jonathan Bennett --- src/modules/NodeInfoModule.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp index 843711807..855cf4491 100644 --- a/src/modules/NodeInfoModule.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -81,6 +81,12 @@ meshtastic_MeshPacket *NodeInfoModule::allocReply() ignoreRequest = false; // Don't ignore requests anymore meshtastic_User &u = owner; + // Strip the public key if the user is licensed + if (u.is_licensed && u.public_key.size > 0) { + u.public_key.bytes[0] = 0; + u.public_key.size = 0; + } + LOG_INFO("sending owner %s/%s/%s", u.id, u.long_name, u.short_name); lastSentToMesh = millis(); return allocDataProtobuf(u); From aae346aef74b72d5914a470d7f19f18bce2f0ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 30 Oct 2024 23:02:59 +0100 Subject: [PATCH 26/46] Update stale_bot.yml --- .github/workflows/stale_bot.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/stale_bot.yml b/.github/workflows/stale_bot.yml index a1ece1d19..0fd2cd5c3 100644 --- a/.github/workflows/stale_bot.yml +++ b/.github/workflows/stale_bot.yml @@ -17,6 +17,5 @@ jobs: - name: Stale PR+Issues uses: actions/stale@v9.0.0 with: - debug-only: true exempt-issue-labels: pinned,3.0 exempt-pr-labels: pinned,3.0 From 462a0718cfc6c5c0bfa35c20cb644e09a8316639 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:46:00 +0100 Subject: [PATCH 27/46] Fix SerialModule getting packet from ourselves (#5206) --- src/modules/SerialModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index dc9c8aa85..1c45a1d40 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -315,7 +315,7 @@ ProcessMessage SerialModuleRadio::handleReceived(const meshtastic_MeshPacket &mp // LOG_DEBUG("Received text msg self=0x%0x, from=0x%0x, to=0x%0x, id=%d, msg=%.*s", // nodeDB->getNodeNum(), mp.from, mp.to, mp.id, p.payload.size, p.payload.bytes); - if (!isFromUs(&mp)) { + if (isFromUs(&mp)) { /* * If moduleConfig.serial.echo is true, then echo the packets that are sent out From 600208ab0bd002d95fc5681040598816db7fc4ac Mon Sep 17 00:00:00 2001 From: Alexander Begoon Date: Thu, 31 Oct 2024 21:07:59 +0100 Subject: [PATCH 28/46] Refactor getMacAddr function to retrieve MAC address as MAC-48 for IEEE 802.15.4 compatibility (#5208) --- src/platform/esp32/main-esp32.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 7b3493f95..b1185e283 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -51,7 +51,11 @@ void updateBatteryLevel(uint8_t level) {} void getMacAddr(uint8_t *dmac) { +#if defined(CONFIG_IDF_TARGET_ESP32C6) && defined(CONFIG_SOC_IEEE802154_SUPPORTED) + assert(esp_base_mac_addr_get(dmac) == ESP_OK); +#else assert(esp_efuse_mac_get_default(dmac) == ESP_OK); +#endif } #ifdef HAS_32768HZ From 7912c214c7a4a6673a4681082f84d37f3adb76b9 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 31 Oct 2024 15:09:27 -0500 Subject: [PATCH 29/46] Increase NimBLE stack size (#5202) --- arch/esp32/esp32.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini index 36d8b9542..382975e9f 100644 --- a/arch/esp32/esp32.ini +++ b/arch/esp32/esp32.ini @@ -31,7 +31,7 @@ build_flags = -DCONFIG_BT_NIMBLE_ENABLED -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 -DCONFIG_BT_NIMBLE_MAX_CCCDS=20 - -DCONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=5120 + -DCONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE=8192 -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING -DSERIAL_BUFFER_SIZE=4096 -DLIBPAX_ARDUINO From 545ebf9b17a8bffe8b7a73a440ac01fe32870f0e Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 31 Oct 2024 19:44:02 -0500 Subject: [PATCH 30/46] Don't skip GPS serial speeds, and always land on GPS_BAUDRATE (#5195) * Don't skip GPS serial speeds, and always land on GPS_BAUDRATE * Update log message to match. * print the value instead --- src/gps/GPS.cpp | 4 ++-- src/gps/GPS.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index e81331760..1e9e21224 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -421,7 +421,7 @@ bool GPS::setup() if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) { // if GPS_BAUDRATE is specified in variant (i.e. not 9600), skip to the specified rate. - if (speedSelect == 0 && GPS_BAUDRATE != serialSpeeds[speedSelect]) { + if (speedSelect == 0 && probeTries == 2 && GPS_BAUDRATE != serialSpeeds[speedSelect]) { speedSelect = std::find(serialSpeeds, std::end(serialSpeeds), GPS_BAUDRATE) - serialSpeeds; } @@ -431,7 +431,7 @@ bool GPS::setup() if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) { speedSelect = 0; if (--probeTries == 0) { - LOG_WARN("Giving up on GPS probe and setting to 9600."); + LOG_WARN("Giving up on GPS probe and setting to %d", GPS_BAUDRATE); return true; } } diff --git a/src/gps/GPS.h b/src/gps/GPS.h index 533f6b525..240d087f2 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -76,7 +76,7 @@ class GPS : private concurrency::OSThread uint8_t fixType = 0; // fix type from GPGSA #endif private: - const int serialSpeeds[6] = {9600, 115200, 38400, 4800, 57600, 9600}; + const int serialSpeeds[6] = {9600, 115200, 38400, 4800, 57600, GPS_BAUDRATE}; uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0; uint32_t rx_gpio = 0; uint32_t tx_gpio = 0; From 732cf4832a9fc0d67f4bfb1b3f64426157ae9a13 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 1 Nov 2024 05:20:00 -0500 Subject: [PATCH 31/46] Bump version since I killed the PR --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 58380fa5e..b9deaacb2 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 5 -build = 9 +build = 10 From 7e3c369e8768627e0a651eee96eda1be1a5f92be Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 1 Nov 2024 05:58:48 -0500 Subject: [PATCH 32/46] Trunk fmt on comment --- .github/workflows/trunk_format_pr.yml | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/trunk_format_pr.yml diff --git a/.github/workflows/trunk_format_pr.yml b/.github/workflows/trunk_format_pr.yml new file mode 100644 index 000000000..d9b584a12 --- /dev/null +++ b/.github/workflows/trunk_format_pr.yml @@ -0,0 +1,45 @@ +name: Run Trunk Fmt on PR Comment + +on: + issue_comment: + types: [created] + +jobs: + trunk-fmt: + if: github.event.issue.pull_request != null && contains(github.event.comment.body, 'trunk fmt') + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.ARTIFACTS_TOKEN }} + + - name: Set up Trunk + run: | + curl -fsSL https://get.trunk.io -o get-trunk.sh + sh get-trunk.sh -y + + - name: Run Trunk Fmt + run: trunk fmt + + - name: Commit and push changes + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Add firmware version ${{ steps.version.outputs.version }}" + git push + + - name: Comment on PR + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '`trunk fmt` has been run on this PR.' + }) From 9c06c492d9d5f3e343dbf225a9850672c194fd12 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 1 Nov 2024 06:04:14 -0500 Subject: [PATCH 33/46] Use one from the other PR --- .github/workflows/trunk_format_pr.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/trunk_format_pr.yml b/.github/workflows/trunk_format_pr.yml index d9b584a12..267a5cc54 100644 --- a/.github/workflows/trunk_format_pr.yml +++ b/.github/workflows/trunk_format_pr.yml @@ -16,10 +16,8 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} token: ${{ secrets.ARTIFACTS_TOKEN }} - - name: Set up Trunk - run: | - curl -fsSL https://get.trunk.io -o get-trunk.sh - sh get-trunk.sh -y + - name: Install trunk + run: curl https://get.trunk.io -fsSL | bash - name: Run Trunk Fmt run: trunk fmt From 10dd8af61485a139b25fe4185f5b453abd31c4e8 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 1 Nov 2024 06:10:42 -0500 Subject: [PATCH 34/46] Eh? --- .github/workflows/trunk_format_pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/trunk_format_pr.yml b/.github/workflows/trunk_format_pr.yml index 267a5cc54..a6e527c4f 100644 --- a/.github/workflows/trunk_format_pr.yml +++ b/.github/workflows/trunk_format_pr.yml @@ -13,8 +13,8 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.ref }} - token: ${{ secrets.ARTIFACTS_TOKEN }} + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} - name: Install trunk run: curl https://get.trunk.io -fsSL | bash From 8462d65f762ada36c38f813e43ba50b0a0946863 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 07:50:40 -0500 Subject: [PATCH 35/46] Bump actions/github-script from 5 to 7 in /.github/workflows (#5214) Bumps [actions/github-script](https://github.com/actions/github-script) from 5 to 7. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v5...v7) --- updated-dependencies: - dependency-name: actions/github-script dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/trunk_format_pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trunk_format_pr.yml b/.github/workflows/trunk_format_pr.yml index a6e527c4f..c5c20b465 100644 --- a/.github/workflows/trunk_format_pr.yml +++ b/.github/workflows/trunk_format_pr.yml @@ -31,7 +31,7 @@ jobs: git push - name: Comment on PR - uses: actions/github-script@v5 + uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | From a1ac358b0a8ae2078dd5094350ba07a5614f80e1 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 1 Nov 2024 13:20:11 -0500 Subject: [PATCH 36/46] Don't try to count non-lora transmissions into airtime (or attempt to decode) (#5215) * Don't try to count non-lora transmissions into airtime (or attempt to decode) * Don't need to check utilization anymore --- src/mesh/RadioLibInterface.cpp | 9 ++++++--- src/modules/NeighborInfoModule.cpp | 4 +--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 9bf1f27ba..3b20cda14 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -278,11 +278,14 @@ void RadioLibInterface::onNotify(uint32_t notification) // Send any outgoing packets we have ready meshtastic_MeshPacket *txp = txQueue.dequeue(); assert(txp); + bool isLoraTx = txp->to != NODENUM_BROADCAST_NO_LORA; startSend(txp); - // Packet has been sent, count it toward our TX airtime utilization. - uint32_t xmitMsec = getPacketTime(txp); - airTime->logAirtime(TX_LOG, xmitMsec); + if (isLoraTx) { + // Packet has been sent, count it toward our TX airtime utilization. + uint32_t xmitMsec = getPacketTime(txp); + airTime->logAirtime(TX_LOG, xmitMsec); + } } } } else { diff --git a/src/modules/NeighborInfoModule.cpp b/src/modules/NeighborInfoModule.cpp index cbf63e9af..88d434070 100644 --- a/src/modules/NeighborInfoModule.cpp +++ b/src/modules/NeighborInfoModule.cpp @@ -121,9 +121,7 @@ Will be used for broadcast. */ int32_t NeighborInfoModule::runOnce() { - if (airTime->isTxAllowedChannelUtil(true) && airTime->isTxAllowedAirUtil()) { - sendNeighborInfo(NODENUM_BROADCAST_NO_LORA, false); - } + sendNeighborInfo(NODENUM_BROADCAST_NO_LORA, false); return Default::getConfiguredOrDefaultMs(moduleConfig.neighbor_info.update_interval, default_neighbor_info_broadcast_secs); } From 336cdc0efef552b0020606bcbf602f8822736874 Mon Sep 17 00:00:00 2001 From: "Aaron.Lee" <32860565+Heltec-Aaron-Lee@users.noreply.github.com> Date: Sat, 2 Nov 2024 04:12:41 +0800 Subject: [PATCH 37/46] Add Heltec V3 battery read pin detect function (#5196) --- src/Power.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Power.cpp b/src/Power.cpp index 02a07e620..96399f388 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -154,9 +154,16 @@ static void adcEnable() #ifdef ADC_CTRL // enable adc voltage divider when we need to read #ifdef ADC_USE_PULLUP pinMode(ADC_CTRL, INPUT_PULLUP); +#else +#ifdef HELTEC_V3 + pinMode(ADC_CTRL,INPUT); + uint8_t adc_ctl_enable_value=!(digitalRead(ADC_CTRL)); + pinMode(ADC_CTRL, OUTPUT); + digitalWrite(ADC_CTRL, adc_ctl_enable_value); #else pinMode(ADC_CTRL, OUTPUT); digitalWrite(ADC_CTRL, ADC_CTRL_ENABLED); +#endif #endif delay(10); #endif @@ -167,10 +174,14 @@ static void adcDisable() #ifdef ADC_CTRL // disable adc voltage divider when we need to read #ifdef ADC_USE_PULLUP pinMode(ADC_CTRL, INPUT_PULLDOWN); +#else +#ifdef HELTEC_V3 + pinMode(ADC_CTRL,ANALOG); #else digitalWrite(ADC_CTRL, !ADC_CTRL_ENABLED); #endif #endif +#endif } #endif From 701421b50a34d706f378d2d5ed075865f4d39a2d Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 1 Nov 2024 15:17:25 -0500 Subject: [PATCH 38/46] Trunk fmt --- .github/workflows/main_matrix.yml | 3 ++- src/Power.cpp | 6 +++--- variants/icarus/pins_arduino.h | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 0853df19f..efdbd2637 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -245,7 +245,8 @@ jobs: if: ${{ github.event_name == 'workflow_dispatch' }} outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} - needs: [ + needs: + [ gather-artifacts, package-raspbian, package-raspbian-armv7l, diff --git a/src/Power.cpp b/src/Power.cpp index 96399f388..f8d2459bd 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -156,8 +156,8 @@ static void adcEnable() pinMode(ADC_CTRL, INPUT_PULLUP); #else #ifdef HELTEC_V3 - pinMode(ADC_CTRL,INPUT); - uint8_t adc_ctl_enable_value=!(digitalRead(ADC_CTRL)); + pinMode(ADC_CTRL, INPUT); + uint8_t adc_ctl_enable_value = !(digitalRead(ADC_CTRL)); pinMode(ADC_CTRL, OUTPUT); digitalWrite(ADC_CTRL, adc_ctl_enable_value); #else @@ -176,7 +176,7 @@ static void adcDisable() pinMode(ADC_CTRL, INPUT_PULLDOWN); #else #ifdef HELTEC_V3 - pinMode(ADC_CTRL,ANALOG); + pinMode(ADC_CTRL, ANALOG); #else digitalWrite(ADC_CTRL, !ADC_CTRL_ENABLED); #endif diff --git a/variants/icarus/pins_arduino.h b/variants/icarus/pins_arduino.h index 9837a3b34..12d72d6dd 100644 --- a/variants/icarus/pins_arduino.h +++ b/variants/icarus/pins_arduino.h @@ -19,4 +19,3 @@ static const uint8_t MOSI = 38; static const uint8_t SS = 17; #endif /* Pins_Arduino_h */ - \ No newline at end of file From cbe74009a9e5fc20048571b6259f8936c26236c0 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 1 Nov 2024 15:46:11 -0500 Subject: [PATCH 39/46] Comment out unused var to get rid of warning --- .trunk/trunk.yaml | 4 ++-- src/mesh/NodeDB.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 2fa237d31..7e77baa0b 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -8,10 +8,10 @@ plugins: uri: https://github.com/trunk-io/plugins lint: enabled: - - trufflehog@3.82.13 + - trufflehog@3.83.2 - yamllint@1.35.1 - bandit@1.7.10 - - checkov@3.2.269 + - checkov@3.2.276 - terrascan@1.19.9 - trivy@0.56.2 #- trufflehog@3.63.2-rc0 diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 6b2991958..247cbd254 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -137,11 +137,12 @@ NodeDB::NodeDB() memcpy(myNodeInfo.device_id.bytes, &device_id_start, sizeof(device_id_start)); memcpy(myNodeInfo.device_id.bytes + sizeof(device_id_start), &device_id_end, sizeof(device_id_end)); myNodeInfo.device_id.size = 16; - hasUniqueId = true; + // Uncomment below to print the device id + // hasUniqueId = true; #else // FIXME - implement for other platforms #endif - // Uncomment below to print the device id + // if (hasUniqueId) { // std::string deviceIdHex; // for (size_t i = 0; i < myNodeInfo.device_id.size; ++i) { From 2d4d36c60582641795136996f16696305e0a8638 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Fri, 1 Nov 2024 21:48:55 +0100 Subject: [PATCH 40/46] Drop oldest packet from radio when queue is full (#5212) And still notify Router Co-authored-by: Ben Meadors --- src/mesh/Router.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index d82268cc6..e1eb8eddf 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -81,14 +81,17 @@ int32_t Router::runOnce() */ void Router::enqueueReceivedMessage(meshtastic_MeshPacket *p) { - if (fromRadioQueue.enqueue(p, 0)) { // NOWAIT - fixme, if queue is full, delete older messages - - // Nasty hack because our threading is primitive. interfaces shouldn't need to know about routers FIXME - setReceivedMessage(); - } else { - printPacket("BUG! fromRadioQueue is full! Discarding!", p); - packetPool.release(p); + // Try enqueue until successful + while (!fromRadioQueue.enqueue(p, 0)) { + meshtastic_MeshPacket *old_p; + old_p = fromRadioQueue.dequeuePtr(0); // Dequeue and discard the oldest packet + if (old_p) { + printPacket("fromRadioQ full, drop oldest!", old_p); + packetPool.release(old_p); + } } + // Nasty hack because our threading is primitive. interfaces shouldn't need to know about routers FIXME + setReceivedMessage(); } /// Generate a unique packet id From ba2f25293b8280c85cfe8f9fb8c2833d9ebee8e3 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Sat, 2 Nov 2024 23:36:40 +1300 Subject: [PATCH 41/46] Fix flipped logic after move to Throttle::isWithinTimespanMs (#5221) --- src/input/ScanAndSelect.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/input/ScanAndSelect.cpp b/src/input/ScanAndSelect.cpp index e1b39edf5..d8767fab8 100644 --- a/src/input/ScanAndSelect.cpp +++ b/src/input/ScanAndSelect.cpp @@ -59,7 +59,7 @@ int32_t ScanAndSelectInput::runOnce() // If: "no messages added" alert screen currently shown if (alertingNoMessage) { // Dismiss the alert screen several seconds after it appears - if (now > alertingSinceMs + durationAlertMs) { + if (!Throttle::isWithinTimespanMs(alertingSinceMs, durationAlertMs)) { alertingNoMessage = false; screen->endAlert(); } @@ -74,9 +74,9 @@ int32_t ScanAndSelectInput::runOnce() // Existing press else { - // Duration enough for long press + // Longer than shortpress window // Long press not yet fired (prevent repeat firing while held) - if (!longPressFired && Throttle::isWithinTimespanMs(downSinceMs, durationLongMs)) { + if (!longPressFired && !Throttle::isWithinTimespanMs(downSinceMs, durationLongMs)) { longPressFired = true; longPress(); } @@ -91,7 +91,9 @@ int32_t ScanAndSelectInput::runOnce() // Button newly released // Long press event didn't already fire if (held && !longPressFired) { - // Duration enough for short press + // Duration within shortpress window + // - longer than durationShortPress (debounce) + // - shorter than durationLongPress if (!Throttle::isWithinTimespanMs(downSinceMs, durationShortMs)) { shortPress(); } From cf476eb87cfe0dea20296fea1e4e719d6f497050 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Sat, 2 Nov 2024 05:38:44 -0500 Subject: [PATCH 42/46] Remove assert in mesh-pb-constants.cpp (#5207) * Remove assert in mesh-pb-constants.cpp * Add raw packet output to portduino trace logging. --------- Co-authored-by: Ben Meadors --- src/mesh/RadioLibInterface.cpp | 9 +++++++++ src/mesh/mesh-pb-constants.cpp | 5 +---- src/meshUtils.cpp | 16 +++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 3b20cda14..df72a289b 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -11,6 +11,10 @@ #include #include +#if ARCH_PORTDUINO +#include "PortduinoGlue.h" +#include "meshUtils.h" +#endif void LockingArduinoHal::spiBeginTransaction() { spiLock->lock(); @@ -393,6 +397,11 @@ void RadioLibInterface::handleReceiveInterrupt() #endif int state = iface->readData((uint8_t *)&radioBuffer, length); +#if ARCH_PORTDUINO + if (settingsMap[logoutputlevel] == level_trace) { + printBytes("Raw incoming packet: ", (uint8_t *)&radioBuffer, length); + } +#endif if (state != RADIOLIB_ERR_NONE) { LOG_ERROR("ignoring received packet due to error=%d", state); rxBad++; diff --git a/src/mesh/mesh-pb-constants.cpp b/src/mesh/mesh-pb-constants.cpp index a279cd991..deb93d0a6 100644 --- a/src/mesh/mesh-pb-constants.cpp +++ b/src/mesh/mesh-pb-constants.cpp @@ -3,7 +3,6 @@ #include "FSCommon.h" #include "mesh-pb-constants.h" #include -#include #include #include @@ -14,8 +13,6 @@ size_t pb_encode_to_bytes(uint8_t *destbuf, size_t destbufsize, const pb_msgdesc pb_ostream_t stream = pb_ostream_from_buffer(destbuf, destbufsize); if (!pb_encode(&stream, fields, src_struct)) { LOG_ERROR("Panic: can't encode protobuf reason='%s'", PB_GET_ERROR(&stream)); - assert( - 0); // If this assert fails it probably means you made a field too large for the max limits specified in mesh.options return 0; } else { return stream.bytes_written; @@ -71,4 +68,4 @@ bool is_in_helper(uint32_t n, const uint32_t *array, pb_size_t count) return true; return false; -} \ No newline at end of file +} diff --git a/src/meshUtils.cpp b/src/meshUtils.cpp index d211f2922..ea2ba641b 100644 --- a/src/meshUtils.cpp +++ b/src/meshUtils.cpp @@ -61,15 +61,13 @@ char *strnstr(const char *s, const char *find, size_t slen) void printBytes(const char *label, const uint8_t *p, size_t numbytes) { int labelSize = strlen(label); - if (labelSize < 100 && numbytes < 64) { - char *messageBuffer = new char[labelSize + (numbytes * 3) + 2]; - strncpy(messageBuffer, label, labelSize); - for (size_t i = 0; i < numbytes; i++) - snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]); - strcpy(messageBuffer + labelSize + numbytes * 3, "\n"); - LOG_DEBUG(messageBuffer); - delete[] messageBuffer; - } + char *messageBuffer = new char[labelSize + (numbytes * 3) + 2]; + strncpy(messageBuffer, label, labelSize); + for (size_t i = 0; i < numbytes; i++) + snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]); + strcpy(messageBuffer + labelSize + numbytes * 3, "\n"); + LOG_DEBUG(messageBuffer); + delete[] messageBuffer; } bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes) From 8801bc5ce928187537ae60b9ec561cf169f7ecd8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 05:58:06 -0500 Subject: [PATCH 43/46] [create-pull-request] automated change (#5223) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/protobufs b/protobufs index 807236815..015202aea 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 807236815d61cc0ebd89472c2a2aa76758bc92ac +Subproject commit 015202aead5f6807d63537c58f4cb6525f19e56f diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 17254354c..cbc8b00b4 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -408,7 +408,7 @@ typedef enum _meshtastic_LogRecord_Level { } meshtastic_LogRecord_Level; /* Struct definitions */ -/* a gps position */ +/* A GPS Position */ typedef struct _meshtastic_Position { /* The new preferred location encoding, multiply by 1e-7 to get degrees in floating point */ From b0c924f185923b0d87e7bb4dbb94ad8934e340c3 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Sat, 2 Nov 2024 20:51:12 +0800 Subject: [PATCH 44/46] Optimise GPS Baud Rate cycle (#5102) * Optimise GPS Baud Rate cycle Previously, our baud rate cycled through one list twice. There were some rarer baudrates in there, so this code separates out those into a dedicated list that is only run through if detection fails for common bauds. We also only run through each baud rate once. * Fix first time around bug Would have always reset GPS baudrate every time. * Add support for fixing GPS_BAUDRATE If GPS_BAUDRATE is set in variant.h, the deployer knows something we don't about the GPS. Used especially when the GPS is soldered to a board in a commercial product :) If we see that, we don't try other baud rates at all. * Don't print blank lines in GPS_DEBUG. * Try GPS_BAUDRATE first, not only. * Fix spelling mistakes in comments * Only use GPS_BAUDRATE if specified in variant.h * Modify RareSerial Speeds based on FIXED or not. --- src/configuration.h | 3 +++ src/gps/GPS.cpp | 65 ++++++++++++++++++++++++++++----------------- src/gps/GPS.h | 12 +++++++-- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/configuration.h b/src/configuration.h index cb2326470..33f11bd76 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -207,6 +207,9 @@ along with this program. If not, see . #ifndef GPS_BAUDRATE #define GPS_BAUDRATE 9600 +#define GPS_BAUDRATE_FIXED 0 +#else +#define GPS_BAUDRATE_FIXED 1 #endif /* Step #2: follow with defines common to the architecture; diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 1e9e21224..60d9e8b24 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -413,30 +413,42 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t return 0; } +/** + * @brief Setup the GPS based on the model detected. + * We detect the GPS by cycling through a set of baud rates, first common then rare. + * For each baud rate, we run GPS::Probe to send commands and match the responses + * to known GPS responses. + * @retval Whether setup reached the end of its potential to configure the GPS. + */ bool GPS::setup() { if (!didSerialInit) { int msglen = 0; if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) { - - // if GPS_BAUDRATE is specified in variant (i.e. not 9600), skip to the specified rate. - if (speedSelect == 0 && probeTries == 2 && GPS_BAUDRATE != serialSpeeds[speedSelect]) { - speedSelect = std::find(serialSpeeds, std::end(serialSpeeds), GPS_BAUDRATE) - serialSpeeds; + if (probeTries < 2) { + LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]); + gnssModel = probe(serialSpeeds[speedSelect]); + if (gnssModel == GNSS_MODEL_UNKNOWN) { + if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) { + speedSelect = 0; + ++probeTries; + } + } } - - LOG_DEBUG("Probing for GPS at %d", serialSpeeds[speedSelect]); - gnssModel = probe(serialSpeeds[speedSelect]); - if (gnssModel == GNSS_MODEL_UNKNOWN) { - if (++speedSelect == sizeof(serialSpeeds) / sizeof(int)) { - speedSelect = 0; - if (--probeTries == 0) { + // Rare Serial Speeds + if (probeTries == 2) { + LOG_DEBUG("Probing for GPS at %d", rareSerialSpeeds[speedSelect]); + gnssModel = probe(rareSerialSpeeds[speedSelect]); + if (gnssModel == GNSS_MODEL_UNKNOWN) { + if (++speedSelect == sizeof(rareSerialSpeeds) / sizeof(int)) { LOG_WARN("Giving up on GPS probe and setting to %d", GPS_BAUDRATE); return true; } } - return false; } + return false; + } else { gnssModel = GNSS_MODEL_UNKNOWN; } @@ -675,7 +687,8 @@ bool GPS::setup() SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_DISABLE_SBAS_BBR, "disable SBAS M10 GPS BBR", 300); delay(750); // will cause a receiver restart so wait a bit - // Done with initialization, Now enable wanted NMEA messages in BBR layer so they will survive a periodic sleep. + // Done with initialization, Now enable wanted NMEA messages in BBR layer so they will survive a periodic + // sleep. SEND_UBX_PACKET(0x06, 0x8A, _message_VALSET_ENABLE_NMEA_BBR, "enable messages for M10 GPS BBR", 300); delay(750); // Next enable wanted NMEA messages in RAM layer @@ -937,10 +950,10 @@ void GPS::down() #endif if (softsleepSupported) { - // How long does gps_update_interval need to be, for GPS_HARDSLEEP to become more efficient than GPS_SOFTSLEEP? - // Heuristic equation. A compromise manually fitted to power observations from U-blox NEO-6M and M10050 - // https://www.desmos.com/calculator/6gvjghoumr - // This is not particularly accurate, but probably an impromevement over a single, fixed threshold + // How long does gps_update_interval need to be, for GPS_HARDSLEEP to become more efficient than + // GPS_SOFTSLEEP? Heuristic equation. A compromise manually fitted to power observations from U-blox NEO-6M + // and M10050 https://www.desmos.com/calculator/6gvjghoumr This is not particularly accurate, but probably an + // improvement over a single, fixed threshold uint32_t hardsleepThreshold = (2750 * pow(predictedSearchDuration / 1000, 1.22)); LOG_DEBUG("gps_update_interval >= %us needed to justify hardsleep", hardsleepThreshold / 1000); @@ -1293,10 +1306,12 @@ GPS *GPS::createGps() if (!GPS_EN_ACTIVE) { // Need to invert the pin before hardware new GpioNotTransformer( - virtPin, p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio + virtPin, + p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio } else { new GpioUnaryTransformer( - virtPin, p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio + virtPin, + p); // We just leave this created object on the heap so it can stay watching virtPin and driving en_gpio } } @@ -1404,8 +1419,8 @@ bool GPS::factoryReset() _serial_gps->write("$PMTK104*37\r\n"); // No PMTK_ACK for this command. delay(100); - // send the UBLOX Factory Reset Command regardless of detect state, something is very wrong, just assume it's UBLOX. - // Factory Reset + // send the UBLOX Factory Reset Command regardless of detect state, something is very wrong, just assume it's + // UBLOX. Factory Reset byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E}; _serial_gps->write(_message_reset, sizeof(_message_reset)); @@ -1444,8 +1459,8 @@ bool GPS::lookForTime() auto d = reader.date; if (ti.isValid() && d.isValid()) { // Note: we don't check for updated, because we'll only be called if needed /* Convert to unix time -The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 -(midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). +The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, +1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z). */ struct tm t; t.tm_sec = ti.second() + round(ti.age() / 1000); @@ -1678,7 +1693,9 @@ bool GPS::whileActive() } } #ifdef GPS_DEBUG - LOG_DEBUG(debugmsg.c_str()); + if (debugmsg != "") { + LOG_DEBUG(debugmsg.c_str()); + } #endif return isValid; } diff --git a/src/gps/GPS.h b/src/gps/GPS.h index 240d087f2..cd61c5444 100644 --- a/src/gps/GPS.h +++ b/src/gps/GPS.h @@ -76,13 +76,21 @@ class GPS : private concurrency::OSThread uint8_t fixType = 0; // fix type from GPGSA #endif private: - const int serialSpeeds[6] = {9600, 115200, 38400, 4800, 57600, GPS_BAUDRATE}; +#if GPS_BAUDRATE_FIXED + // if GPS_BAUDRATE is specified in variant, only try that. + const int serialSpeeds[1] = {GPS_BAUDRATE}; + const int rareSerialSpeeds[1] = {GPS_BAUDRATE}; +#else + const int serialSpeeds[3] = {9600, 115200, 38400}; + const int rareSerialSpeeds[3] = {4800, 57600, GPS_BAUDRATE}; +#endif + uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0; uint32_t rx_gpio = 0; uint32_t tx_gpio = 0; int speedSelect = 0; - int probeTries = 2; + int probeTries = 0; /** * hasValidLocation - indicates that the position variables contain a complete From 0fc5c9b0d7ce80c8c693dcf20b182b5efb6ef1a5 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 2 Nov 2024 07:57:33 -0500 Subject: [PATCH 45/46] Create CODE_OF_CONDUCT.md (#5225) --- CODE_OF_CONDUCT.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..1e23cdf4d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,4 @@ +# Contributor Covenant Code of Conduct + +The Meshtastic Firmware project is subject to the code of conduct for the parent project, which can be found here: +https://meshtastic.org/docs/legal/conduct/ From 93bc61c8558b234253b02fa647ee9ed49d87c29b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 16:30:43 +0100 Subject: [PATCH 46/46] [create-pull-request] automated change (#5227) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index b9deaacb2..6664f69b9 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 5 -build = 10 +build = 11