From 9545a10361203a6e1c24c3512b6f28a7e136802a Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sat, 16 Nov 2024 01:20:20 +0100 Subject: [PATCH 01/15] RP2040: Update core; add mDNS support (#5355) * Update arduino-pico core * RP2040: Add mDNS support * SimpleMDNS `begin` now returns a bool * Add `-g` option to `debug_build_flags` to link files for gdb * RAK11310 needs old platform as well * Change defines to specific architecture * Core version 4.2.1 is out --- arch/rp2xx0/rp2040.ini | 6 +++--- arch/rp2xx0/rp2350.ini | 4 ++-- src/mesh/wifi/WiFiAPClient.cpp | 24 ++++++++++++++---------- variants/rak11310/platformio.ini | 3 ++- variants/rp2040-lora/platformio.ini | 2 +- variants/rpipico/platformio.ini | 2 +- variants/rpipico2/platformio.ini | 2 +- variants/rpipicow/platformio.ini | 2 +- 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/arch/rp2xx0/rp2040.ini b/arch/rp2xx0/rp2040.ini index 17b5df618..57e5d7bc2 100644 --- a/arch/rp2xx0/rp2040.ini +++ b/arch/rp2xx0/rp2040.ini @@ -1,8 +1,8 @@ ; Common settings for rp2040 Processor based targets [rp2040_base] -platform = https://github.com/maxgerhardt/platform-raspberrypi.git#v1.2.0-gcc12 +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#a606be683748c73e9a0d46baf70163478d298f0f ; For arduino-pico 4.2.0 extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#4.0.3 +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#4.2.1 board_build.core = earlephilhower board_build.filesystem_size = 0.5m @@ -23,4 +23,4 @@ lib_deps = ${arduino_base.lib_deps} ${environmental_base.lib_deps} ${radiolib_base.lib_deps} - rweather/Crypto \ No newline at end of file + rweather/Crypto diff --git a/arch/rp2xx0/rp2350.ini b/arch/rp2xx0/rp2350.ini index 33bb36ad1..58c5e5554 100644 --- a/arch/rp2xx0/rp2350.ini +++ b/arch/rp2xx0/rp2350.ini @@ -1,8 +1,8 @@ ; Common settings for rp2040 Processor based targets [rp2350_base] -platform = https://github.com/maxgerhardt/platform-raspberrypi.git#9e55f6db5c56b9867c69fe473f388beea4546672 +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#a606be683748c73e9a0d46baf70163478d298f0f ; For arduino-pico 4.2.0 extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#a6ab6e1f95bc1428d667d55ea7173c0744acc03c ; 4.0.2+ +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#4.2.1 board_build.core = earlephilhower board_build.filesystem_size = 0.5m diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index faf5ce3de..911a47093 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -20,6 +20,8 @@ #include #include static void WiFiEvent(WiFiEvent_t event); +#elif defined(ARCH_RP2040) +#include #endif #ifndef DISABLE_NTP @@ -59,19 +61,21 @@ static void onNetworkConnected() // Start web server LOG_INFO("Start WiFi network services"); -#ifdef ARCH_ESP32 // start mdns if (!MDNS.begin("Meshtastic")) { LOG_ERROR("Error setting up MDNS responder!"); } else { - LOG_INFO("mDNS responder started"); LOG_INFO("mDNS Host: Meshtastic.local"); +#ifdef ARCH_ESP32 MDNS.addService("http", "tcp", 80); MDNS.addService("https", "tcp", 443); - } -#else // ESP32 handles this in WiFiEvent - LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str()); +#elif defined(ARCH_RP2040) + // ARCH_RP2040 does not support HTTPS, create a "meshtastic" service + MDNS.addService("meshtastic", "tcp", 4403); + // ESP32 handles this in WiFiEvent + LOG_INFO("Obtained IP address: %s", WiFi.localIP().toString().c_str()); #endif + } #ifndef DISABLE_NTP LOG_INFO("Start NTP time client"); @@ -129,7 +133,7 @@ static int32_t reconnectWiFi() // Make sure we clear old connection credentials #ifdef ARCH_ESP32 WiFi.disconnect(false, true); -#else +#elif defined(ARCH_RP2040) WiFi.disconnect(false); #endif LOG_INFO("Reconnecting to WiFi access point %s", wifiName); @@ -193,7 +197,7 @@ void deinitWifi() if (isWifiAvailable()) { #ifdef ARCH_ESP32 WiFi.disconnect(true, false); -#else +#elif defined(ARCH_RP2040) WiFi.disconnect(true); #endif WiFi.mode(WIFI_OFF); @@ -229,15 +233,15 @@ bool initWifi() if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_STATIC && config.network.ipv4_config.ip != 0) { -#ifndef ARCH_RP2040 +#ifdef ARCH_ESP32 WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.gateway, config.network.ipv4_config.subnet, config.network.ipv4_config.dns); -#else +#elif defined(ARCH_RP2040) WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.dns, config.network.ipv4_config.gateway, config.network.ipv4_config.subnet); #endif } -#ifndef ARCH_RP2040 +#ifdef ARCH_ESP32 WiFi.onEvent(WiFiEvent); WiFi.setAutoReconnect(true); WiFi.setSleep(false); diff --git a/variants/rak11310/platformio.ini b/variants/rak11310/platformio.ini index c7b3504fe..923cedaa3 100644 --- a/variants/rak11310/platformio.ini +++ b/variants/rak11310/platformio.ini @@ -3,6 +3,7 @@ extends = rp2040_base board = wiscore_rak11300 upload_protocol = picotool # keep an old SDK to use less memory. +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#v1.2.0-gcc12 platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#3.7.2 # add our variants files to the include and src paths @@ -13,5 +14,5 @@ build_flags = ${rp2040_base.build_flags} -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} -debug_build_flags = ${rp2040_base.build_flags} +debug_build_flags = ${rp2040_base.build_flags}, -g debug_tool = cmsis-dap ; for e.g. Picotool \ No newline at end of file diff --git a/variants/rp2040-lora/platformio.ini b/variants/rp2040-lora/platformio.ini index 8499f6f3c..4c578fb2b 100644 --- a/variants/rp2040-lora/platformio.ini +++ b/variants/rp2040-lora/platformio.ini @@ -12,5 +12,5 @@ build_flags = ${rp2040_base.build_flags} -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} -debug_build_flags = ${rp2040_base.build_flags} +debug_build_flags = ${rp2040_base.build_flags}, -g debug_tool = cmsis-dap ; for e.g. Picotool \ No newline at end of file diff --git a/variants/rpipico/platformio.ini b/variants/rpipico/platformio.ini index e4b9e479f..9c62ebcb5 100644 --- a/variants/rpipico/platformio.ini +++ b/variants/rpipico/platformio.ini @@ -12,5 +12,5 @@ build_flags = ${rp2040_base.build_flags} -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" lib_deps = ${rp2040_base.lib_deps} -debug_build_flags = ${rp2040_base.build_flags} +debug_build_flags = ${rp2040_base.build_flags}, -g debug_tool = cmsis-dap ; for e.g. Picotool \ No newline at end of file diff --git a/variants/rpipico2/platformio.ini b/variants/rpipico2/platformio.ini index a63414418..24714efd5 100644 --- a/variants/rpipico2/platformio.ini +++ b/variants/rpipico2/platformio.ini @@ -12,5 +12,5 @@ build_flags = ${rp2350_base.build_flags} -L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus" lib_deps = ${rp2350_base.lib_deps} -debug_build_flags = ${rp2350_base.build_flags} +debug_build_flags = ${rp2350_base.build_flags}, -g debug_tool = cmsis-dap ; for e.g. Picotool \ No newline at end of file diff --git a/variants/rpipicow/platformio.ini b/variants/rpipicow/platformio.ini index 2600b4b38..7a43ece3b 100644 --- a/variants/rpipicow/platformio.ini +++ b/variants/rpipicow/platformio.ini @@ -14,5 +14,5 @@ build_src_filter = ${rp2040_base.build_src_filter} + lib_deps = ${rp2040_base.lib_deps} ${networking_base.lib_deps} -debug_build_flags = ${rp2040_base.build_flags} +debug_build_flags = ${rp2040_base.build_flags}, -g debug_tool = cmsis-dap ; for e.g. Picotool \ No newline at end of file From 90a3050c1fbe711df4096885a03c87d98317d819 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Sat, 16 Nov 2024 12:01:41 +0800 Subject: [PATCH 02/15] Add sudo to apt-get commands for Raspbian Build (#5364) Without sudo, inadequate permissions to runs the commands meant the build was failing. --- .github/workflows/build_raspbian.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_raspbian.yml b/.github/workflows/build_raspbian.yml index 1fd8fad30..66c65a347 100644 --- a/.github/workflows/build_raspbian.yml +++ b/.github/workflows/build_raspbian.yml @@ -13,8 +13,8 @@ jobs: - name: Install libbluetooth shell: bash run: | - apt-get update -y --fix-missing - apt-get install -y libbluetooth-dev libgpiod-dev libyaml-cpp-dev openssl libssl-dev libulfius-dev liborcania-dev + sudo apt-get update -y --fix-missing + sudp apt-get install -y libbluetooth-dev libgpiod-dev libyaml-cpp-dev openssl libssl-dev libulfius-dev liborcania-dev - name: Checkout code uses: actions/checkout@v4 From 1b99543a1558ddfeeb7e7e2c88ef905ce79b5d12 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Sat, 16 Nov 2024 12:48:15 +0800 Subject: [PATCH 03/15] Typo fix in build_raspbian.yml (#5365) s/sudp/sudo :(:(:( --- .github/workflows/build_raspbian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_raspbian.yml b/.github/workflows/build_raspbian.yml index 66c65a347..e857ae635 100644 --- a/.github/workflows/build_raspbian.yml +++ b/.github/workflows/build_raspbian.yml @@ -14,7 +14,7 @@ jobs: shell: bash run: | sudo apt-get update -y --fix-missing - sudp apt-get install -y libbluetooth-dev libgpiod-dev libyaml-cpp-dev openssl libssl-dev libulfius-dev liborcania-dev + sudo apt-get install -y libbluetooth-dev libgpiod-dev libyaml-cpp-dev openssl libssl-dev libulfius-dev liborcania-dev - name: Checkout code uses: actions/checkout@v4 From add70b522910bd94a4e9efbdcad7750707e98b0c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 16 Nov 2024 05:58:07 -0600 Subject: [PATCH 04/15] Rework some things --- .github/actions/build-variant/action.yml | 1 + arch/nrf52/nrf52.ini | 1 + src/mesh/mesh-pb-constants.h | 6 +----- version.properties | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/actions/build-variant/action.yml b/.github/actions/build-variant/action.yml index 80d2a56bb..e0c5fba06 100644 --- a/.github/actions/build-variant/action.yml +++ b/.github/actions/build-variant/action.yml @@ -51,6 +51,7 @@ runs: file: build.tar target: build.tar token: ${{ inputs.github_token }} + version: v2.5.3 - name: Unpack web ui if: inputs.include-web-ui == 'true' diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 99e8693dc..d75f86306 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -16,6 +16,7 @@ build_flags = -DLFS_NO_ASSERT ; Disable LFS assertions , see https://github.com/meshtastic/firmware/pull/3818 -DMESHTASTIC_EXCLUDE_AUDIO=1 -DMESHTASTIC_EXCLUDE_PAXCOUNTER=1 + -DMAX_NUM_NODES=80 build_src_filter = ${arduino_base.build_src_filter} - - - - - - - - - - diff --git a/src/mesh/mesh-pb-constants.h b/src/mesh/mesh-pb-constants.h index a055804d9..df7ae89e6 100644 --- a/src/mesh/mesh-pb-constants.h +++ b/src/mesh/mesh-pb-constants.h @@ -1,7 +1,7 @@ #pragma once #include -#include "architecture.h" + #include "mesh/generated/meshtastic/admin.pb.h" #include "mesh/generated/meshtastic/deviceonly.pb.h" #include "mesh/generated/meshtastic/localonly.pb.h" @@ -21,12 +21,8 @@ /// max number of nodes allowed in the mesh #ifndef MAX_NUM_NODES -#ifdef ARCH_NRF52 -#define MAX_NUM_NODES 80 -#else #define MAX_NUM_NODES 100 #endif -#endif #define MAX_NUM_NODES_FS 100 diff --git a/version.properties b/version.properties index bed14bad5..091ebde9e 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 5 -build = 14 +build = 13 From fdc473e5faf5d97a58629491559718a504c2364f Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 16 Nov 2024 06:01:07 -0600 Subject: [PATCH 05/15] Trunk --- src/mesh/mesh-pb-constants.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/mesh-pb-constants.h b/src/mesh/mesh-pb-constants.h index df7ae89e6..039b36d8d 100644 --- a/src/mesh/mesh-pb-constants.h +++ b/src/mesh/mesh-pb-constants.h @@ -1,7 +1,6 @@ #pragma once #include - #include "mesh/generated/meshtastic/admin.pb.h" #include "mesh/generated/meshtastic/deviceonly.pb.h" #include "mesh/generated/meshtastic/localonly.pb.h" From be6348388edcb170231bbb75c04b343a5d0db8a6 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 16 Nov 2024 06:12:45 -0600 Subject: [PATCH 06/15] Separate littlefs bundle --- bin/build-esp32.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/build-esp32.sh b/bin/build-esp32.sh index adb6ab12a..b5f7c126e 100755 --- a/bin/build-esp32.sh +++ b/bin/build-esp32.sh @@ -35,6 +35,10 @@ cp $SRCBIN $OUTDIR/$basename-update.bin echo "Building Filesystem for ESP32 targets" pio run --environment $1 -t buildfs +cp .pio/build/$1/littlefs.bin $OUTDIR/littlefswebui-$VERSION.bin +# Remove webserver files from the filesystem and rebuild +rm -rf data/static +pio run --environment $1 -t buildfs cp .pio/build/$1/littlefs.bin $OUTDIR/littlefs-$VERSION.bin cp bin/device-install.* $OUTDIR cp bin/device-update.* $OUTDIR From ca3d8da128b6473a5578f1416c909a92f9750a3c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 16 Nov 2024 06:22:08 -0600 Subject: [PATCH 07/15] version tags --- .github/actions/build-variant/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-variant/action.yml b/.github/actions/build-variant/action.yml index e0c5fba06..b3303d393 100644 --- a/.github/actions/build-variant/action.yml +++ b/.github/actions/build-variant/action.yml @@ -51,7 +51,7 @@ runs: file: build.tar target: build.tar token: ${{ inputs.github_token }} - version: v2.5.3 + version: tags/v2.5.3 - name: Unpack web ui if: inputs.include-web-ui == 'true' From 74d0c58576bd43c24d0bfb68aec86f3da36979a3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 16 Nov 2024 06:24:10 -0600 Subject: [PATCH 08/15] Diag --- bin/build-esp32.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/build-esp32.sh b/bin/build-esp32.sh index b5f7c126e..f8d808ced 100755 --- a/bin/build-esp32.sh +++ b/bin/build-esp32.sh @@ -37,6 +37,7 @@ echo "Building Filesystem for ESP32 targets" pio run --environment $1 -t buildfs cp .pio/build/$1/littlefs.bin $OUTDIR/littlefswebui-$VERSION.bin # Remove webserver files from the filesystem and rebuild +ls -l data/static # Diagnostic list of files rm -rf data/static pio run --environment $1 -t buildfs cp .pio/build/$1/littlefs.bin $OUTDIR/littlefs-$VERSION.bin From 37b29f689951db02cbace46e4896b91f2efec6ad Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 16 Nov 2024 19:36:55 -0600 Subject: [PATCH 09/15] Add littlefswebui --- .github/workflows/main_matrix.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index efdbd2637..37164b758 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -203,6 +203,7 @@ jobs: ./device-*.sh ./device-*.bat ./littlefs-*.bin + ./littlefswebui-*.bin ./bleota*bin ./Meshtastic_nRF52_factory_erase*.uf2 retention-days: 30 From a174ec7cf95be8a4a5400c0df3a205d5a89181fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gjels=C3=B8?= <36234524+gjelsoe@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:36:06 +0100 Subject: [PATCH 10/15] Bug fixed in ExternalNotificationModule (#5375) While `nagging` setExternalState wasn't written to Buzzer & Vibra so output was never toggled. Possible fix for #5348 --- src/modules/ExternalNotificationModule.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/ExternalNotificationModule.cpp b/src/modules/ExternalNotificationModule.cpp index d88f275b9..3ec6ff690 100644 --- a/src/modules/ExternalNotificationModule.cpp +++ b/src/modules/ExternalNotificationModule.cpp @@ -119,12 +119,13 @@ int32_t ExternalNotificationModule::runOnce() if (externalTurnedOn[1] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { - setExternalState(0, !getExternal(1)); + setExternalState(1, !getExternal(1)); } if (externalTurnedOn[2] + (moduleConfig.external_notification.output_ms ? moduleConfig.external_notification.output_ms : EXT_NOTIFICATION_MODULE_OUTPUT_MS) < millis()) { - setExternalState(0, !getExternal(2)); + LOG_DEBUG("EXTERNAL 2 %d compared to %d", externalTurnedOn[2]+moduleConfig.external_notification.output_ms, millis()); + setExternalState(2, !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 From 1a06f88dfb44ecc5bb45fe18d3ce8603c276a0fe Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 17 Nov 2024 07:57:59 -0600 Subject: [PATCH 11/15] Cleanup static files from bad Web UI bundle on 2.5.13 release (#5376) * Cleanup static files from bad Web UI bundle on 2.5.13 release * Check existence first * Esp32 is the only one we care about --- src/mesh/NodeDB.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 7f051ae16..102ac1f61 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -823,6 +823,11 @@ void NodeDB::loadFromDisk() 0; // Mark the current device state as completely unusable, so that if we fail reading the entire file from // disk we will still factoryReset to restore things. +#ifdef ARCH_ESP32 + if (FSCom.exists("/static/static")) + rmDir("/static/static"); // Remove bad static web files bundle from initial 2.5.13 release +#endif + // static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM auto state = loadProto(prefFileName, sizeof(meshtastic_DeviceState) + MAX_NUM_NODES_FS * sizeof(meshtastic_NodeInfo), sizeof(meshtastic_DeviceState), &meshtastic_DeviceState_msg, &devicestate); From 0d1f9e915f676201f1ac21eaa57dd61e20e34bd7 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sun, 17 Nov 2024 17:51:01 +0100 Subject: [PATCH 12/15] Move some actions to after `startTransmit()` (#5383) To minimize the time between channel scan and actual transmit --- src/mesh/RadioInterface.cpp | 2 -- src/mesh/RadioLibInterface.cpp | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index f0d137e2c..53b66ff0a 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -601,8 +601,6 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p) // LOG_DEBUG("Send queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)", rf95.txGood(), rf95.rxGood(), rf95.rxBad()); assert(p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag); // It should have already been encoded by now - lastTxStart = millis(); - radioBuffer.header.from = p->from; radioBuffer.header.to = p->to; radioBuffer.header.id = p->id; diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index 23ef3d6f1..5f82a41ce 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -278,7 +278,8 @@ void RadioLibInterface::onNotify(uint32_t notification) startReceive(); // try receiving this packet, afterwards we'll be trying to transmit again setTransmitDelay(); } else { - // Send any outgoing packets we have ready + // Send any outgoing packets we have ready as fast as possible to keep the time between channel scan and + // actual transmission as short as possible meshtastic_MeshPacket *txp = txQueue.dequeue(); assert(txp); bool sent = startSend(txp); @@ -470,7 +471,8 @@ void RadioLibInterface::setStandby() /** start an immediate transmit */ bool RadioLibInterface::startSend(meshtastic_MeshPacket *txp) { - printPacket("Start low level send", txp); + /* NOTE: Minimize the actions before startTransmit() to keep the time between + channel scan and actual transmit as low as possible to avoid collisions. */ if (disabled || !config.lora.tx_enabled) { LOG_WARN("Drop Tx packet because LoRa Tx disabled"); packetPool.release(txp); @@ -489,6 +491,9 @@ bool RadioLibInterface::startSend(meshtastic_MeshPacket *txp) completeSending(); powerMon->clearState(meshtastic_PowerMon_State_Lora_TXOn); // Transmitter off now startReceive(); // Restart receive mode (because startTransmit failed to put us in xmit mode) + } else { + lastTxStart = millis(); + printPacket("Started Tx", txp); } // Must be done AFTER, starting transmit, because startTransmit clears (possibly stale) interrupt pending register From a8357ebd5296bbed9c952b21cb7255d7911fa54c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2024 10:51:11 -0600 Subject: [PATCH 13/15] [create-pull-request] automated change (#5380) 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 091ebde9e..bed14bad5 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 5 -build = 13 +build = 14 From 89469fcb88240617146dc11bc3cad01dcbf3f3a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gjels=C3=B8?= <36234524+gjelsoe@users.noreply.github.com> Date: Sun, 17 Nov 2024 19:36:41 +0100 Subject: [PATCH 14/15] Allows all 3 PKI keys to be added to userPrefs.h (#4969) and a tool. (#5368) * more userPrefs.h Added PKI Admin keys to userPrefs.h * Update userPrefs.h Allows all 3 PKI keys to be added to userPrefs.h (#4969) * Update NodeDB.cpp Trunk * Update userPrefs.h Changed wording * Create base64_to_hex.py A little tool for converting base64 PKI Keys to decoded byte that userPrefs.h can understand. * more userPrefs.h Added PKI Admin keys to userPrefs.h * Update userPrefs.h Allows all 3 PKI keys to be added to userPrefs.h (#4969) * Update NodeDB.cpp Trunk * Update userPrefs.h Changed wording * Create base64_to_hex.py A little tool for converting base64 PKI Keys to decoded byte that userPrefs.h can understand. --- bin/base64_to_hex.py | 33 +++++++++++++++++++++++++++++++++ src/mesh/NodeDB.cpp | 27 ++++++++++++++++++++++++--- userPrefs.h | 14 +++++++++++--- 3 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 bin/base64_to_hex.py diff --git a/bin/base64_to_hex.py b/bin/base64_to_hex.py new file mode 100644 index 000000000..07c559b9e --- /dev/null +++ b/bin/base64_to_hex.py @@ -0,0 +1,33 @@ +import sys +import base64 + +def base64_to_hex_string(b64_string): + try: + # Decode the Base64 string to raw bytes + decoded_bytes = base64.b64decode(b64_string) + except Exception as e: + raise ValueError(f"Invalid Base64 input: {e}") + + # Check if the decoded result is exactly 32 bytes + if len(decoded_bytes) != 32: + raise ValueError("Decoded Base64 input must be exactly 32 bytes.") + + # Convert each byte to its hex representation + hex_values = [f"0x{byte:02x}" for byte in decoded_bytes] + + # Join the formatted hex values with commas + formatted_output = "{ " + ", ".join(hex_values) + " };" + return formatted_output + +if __name__ == "__main__": + # Check if a Base64 string was provided in command line arguments + if len(sys.argv) != 2: + print("Usage: python script.py ") + sys.exit(1) + + b64_string = sys.argv[1] + try: + formatted_hex = base64_to_hex_string(b64_string) + print(formatted_hex) + except ValueError as e: + print(e) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 102ac1f61..55b8c0b4d 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -407,9 +407,30 @@ void NodeDB::installDefaultConfig(bool preserveKey = false) config.lora.ignore_mqtt = false; #endif #ifdef USERPREFS_USE_ADMIN_KEY - memcpy(config.security.admin_key[0].bytes, USERPREFS_ADMIN_KEY, 32); - config.security.admin_key[0].size = 32; - config.security.admin_key_count = 1; + // Initialize admin_key_count to zero + byte numAdminKeys = 0; + + // Check if USERPREFS_ADMIN_KEY_0 is non-empty + if (sizeof(USERPREFS_ADMIN_KEY_0) > 0) { + memcpy(config.security.admin_key[numAdminKeys].bytes, USERPREFS_ADMIN_KEY_0, 32); + config.security.admin_key[numAdminKeys].size = 32; + numAdminKeys++; + } + + // Check if USERPREFS_ADMIN_KEY_1 is non-empty + if (sizeof(USERPREFS_ADMIN_KEY_1) > 0) { + memcpy(config.security.admin_key[numAdminKeys].bytes, USERPREFS_ADMIN_KEY_1, 32); + config.security.admin_key[numAdminKeys].size = 32; + numAdminKeys++; + } + + // Check if USERPREFS_ADMIN_KEY_2 is non-empty + if (sizeof(USERPREFS_ADMIN_KEY_2) > 0) { + memcpy(config.security.admin_key[config.security.admin_key_count].bytes, USERPREFS_ADMIN_KEY_2, 32); + config.security.admin_key[config.security.admin_key_count].size = 32; + numAdminKeys++; + } + config.security.admin_key_count = numAdminKeys; #endif if (shouldPreserveKey) { config.security.private_key.size = 32; diff --git a/userPrefs.h b/userPrefs.h index c105e6b52..622a491c3 100644 --- a/userPrefs.h +++ b/userPrefs.h @@ -68,11 +68,19 @@ static unsigned char icon_bits[] = { 0x98, 0x3F, 0xF0, 0x23, 0x00, 0xFC, 0x0F, 0xE0, 0x7F, 0x00, 0xFC, 0x03, 0x80, 0xFF, 0x01, 0xFC, 0x00, 0x00, 0x3E, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00}; */ + +/* + * PKI Admin keys. + * If a Admin key is set with '{};' + * then it will be ignored, a PKI key must have a size of 32. + */ /* #define USERPREFS_USE_ADMIN_KEY 1 -static unsigned char USERPREFS_ADMIN_KEY[] = {0xcd, 0xc0, 0xb4, 0x3c, 0x53, 0x24, 0xdf, 0x13, 0xca, 0x5a, 0xa6, - 0x0c, 0x0d, 0xec, 0x85, 0x5a, 0x4c, 0xf6, 0x1a, 0x96, 0x04, 0x1a, - 0x3e, 0xfc, 0xbb, 0x8e, 0x33, 0x71, 0xe5, 0xfc, 0xff, 0x3c}; +static unsigned char USERPREFS_ADMIN_KEY_0[] = {0xcd, 0xc0, 0xb4, 0x3c, 0x53, 0x24, 0xdf, 0x13, 0xca, 0x5a, 0xa6, + 0x0c, 0x0d, 0xec, 0x85, 0x5a, 0x4c, 0xf6, 0x1a, 0x96, 0x04, 0x1a, + 0x3e, 0xfc, 0xbb, 0x8e, 0x33, 0x71, 0xe5, 0xfc, 0xff, 0x3c}; +static unsigned char USERPREFS_ADMIN_KEY_1[] = {}; +static unsigned char USERPREFS_ADMIN_KEY_2[] = {}; */ /* From de76caca328f1706d0147262ebbc74d45424515e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2024 19:29:43 -0600 Subject: [PATCH 15/15] [create-pull-request] automated change (#5388) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/device_ui.pb.h | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/protobufs b/protobufs index af2fea10f..52688fdcc 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit af2fea10fe2eba5857fb8e27975bbcea9c10af8e +Subproject commit 52688fdccb8a40c23101cada3736b3b22c2b229e diff --git a/src/mesh/generated/meshtastic/device_ui.pb.h b/src/mesh/generated/meshtastic/device_ui.pb.h index 5c1e067ab..107aa8846 100644 --- a/src/mesh/generated/meshtastic/device_ui.pb.h +++ b/src/mesh/generated/meshtastic/device_ui.pb.h @@ -49,6 +49,8 @@ typedef enum _meshtastic_Language { meshtastic_Language_DUTCH = 12, /* Greek */ meshtastic_Language_GREEK = 13, + /* Norwegian */ + meshtastic_Language_NORWEGIAN = 14, /* Simplified Chinese (experimental) */ meshtastic_Language_SIMPLIFIED_CHINESE = 30, /* Traditional Chinese (experimental) */ @@ -84,6 +86,7 @@ typedef struct _meshtastic_NodeHighlight { char node_name[16]; } meshtastic_NodeHighlight; +typedef PB_BYTES_ARRAY_T(16) meshtastic_DeviceUIConfig_calibration_data_t; typedef struct _meshtastic_DeviceUIConfig { /* A version integer used to invalidate saved files when we make incompatible changes. */ uint32_t version; @@ -109,6 +112,8 @@ typedef struct _meshtastic_DeviceUIConfig { /* Node list highlightening */ bool has_node_highlight; meshtastic_NodeHighlight node_highlight; + /* 8 integers for screen calibration data */ + meshtastic_DeviceUIConfig_calibration_data_t calibration_data; } meshtastic_DeviceUIConfig; @@ -132,10 +137,10 @@ extern "C" { /* Initializer values for message structs */ -#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_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, {0, {0}}} #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, 0, 0, 0, _meshtastic_Theme_MIN, 0, 0, 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, {0, {0}}} #define meshtastic_NodeFilter_init_zero {0, 0, 0, 0, 0, ""} #define meshtastic_NodeHighlight_init_zero {0, 0, 0, 0, ""} @@ -164,6 +169,7 @@ extern "C" { #define meshtastic_DeviceUIConfig_language_tag 11 #define meshtastic_DeviceUIConfig_node_filter_tag 12 #define meshtastic_DeviceUIConfig_node_highlight_tag 13 +#define meshtastic_DeviceUIConfig_calibration_data_tag 14 /* Struct field encoding specification for nanopb */ #define meshtastic_DeviceUIConfig_FIELDLIST(X, a) \ @@ -179,7 +185,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) +X(a, STATIC, OPTIONAL, MESSAGE, node_highlight, 13) \ +X(a, STATIC, SINGULAR, BYTES, calibration_data, 14) #define meshtastic_DeviceUIConfig_CALLBACK NULL #define meshtastic_DeviceUIConfig_DEFAULT NULL #define meshtastic_DeviceUIConfig_node_filter_MSGTYPE meshtastic_NodeFilter @@ -215,7 +222,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 99 +#define meshtastic_DeviceUIConfig_size 117 #define meshtastic_NodeFilter_size 36 #define meshtastic_NodeHighlight_size 25