From 9f4c8a28043633fbeffc00da8c0ede02cebfdf9a Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Sat, 30 Nov 2024 20:16:02 +0100 Subject: [PATCH 01/11] Update arduino-pico core and remove MDNS restriction (#5483) --- arch/rp2xx0/rp2040.ini | 4 ++-- arch/rp2xx0/rp2350.ini | 4 ++-- src/mesh/wifi/WiFiAPClient.cpp | 6 +----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/rp2xx0/rp2040.ini b/arch/rp2xx0/rp2040.ini index 85efa583c..5cfa678d5 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#19e30129fb1428b823be585c787dcb4ac0d9014c ; For arduino-pico 4.2.1 +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#19e30129fb1428b823be585c787dcb4ac0d9014c ; For arduino-pico >=4.2.1 extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#996c3bfab9758f12c07aa20cc6d352e630c16987 ; 4.2.1 with fix for sporadic hangs +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#6024e9a7e82a72e38dd90f42029ba3748835eb2e ; 4.3.0 with fix MDNS board_build.core = earlephilhower board_build.filesystem_size = 0.5m diff --git a/arch/rp2xx0/rp2350.ini b/arch/rp2xx0/rp2350.ini index 6daf59bdf..c5849ff2a 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#19e30129fb1428b823be585c787dcb4ac0d9014c ; For arduino-pico 4.2.1 +platform = https://github.com/maxgerhardt/platform-raspberrypi.git#19e30129fb1428b823be585c787dcb4ac0d9014c ; For arduino-pico >=4.2.1 extends = arduino_base -platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#96c3bfab9758f12c07aa20cc6d352e630c16987 ; 4.2.1 with fix for sporadic hangs +platform_packages = framework-arduinopico@https://github.com/earlephilhower/arduino-pico.git#6024e9a7e82a72e38dd90f42029ba3748835eb2e ; 4.3.0 with fix MDNS 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 779576d64..911a47093 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -62,11 +62,7 @@ static void onNetworkConnected() LOG_INFO("Start WiFi network services"); // start mdns - if ( -#ifdef ARCH_RP2040 - !moduleConfig.mqtt.enabled && // MDNS is not supported when MQTT is enabled on ARCH_RP2040 -#endif - !MDNS.begin("Meshtastic")) { + if (!MDNS.begin("Meshtastic")) { LOG_ERROR("Error setting up MDNS responder!"); } else { LOG_INFO("mDNS Host: Meshtastic.local"); From 594af0cacd68885aa34192778717b7ca2f5515f3 Mon Sep 17 00:00:00 2001 From: dylanli Date: Mon, 2 Dec 2024 16:59:34 +0800 Subject: [PATCH 02/11] Update xiao_esp32 fully support L67K (#5488) L67K module hardware changed --- variants/seeed_xiao_s3/variant.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variants/seeed_xiao_s3/variant.h b/variants/seeed_xiao_s3/variant.h index ab886d354..f854ba38a 100644 --- a/variants/seeed_xiao_s3/variant.h +++ b/variants/seeed_xiao_s3/variant.h @@ -41,7 +41,7 @@ L76K GPS Module Information : https://www.seeedstudio.com/L76K-GNSS-Module-for-S L76K Expansion Board can not directly used, L76K Reset Pin needs to override or physically remove it, otherwise it will conflict with the SPI pins */ -// #define GPS_L76K +#define GPS_L76K #ifdef GPS_L76K #define GPS_RX_PIN 44 #define GPS_TX_PIN 43 @@ -81,4 +81,4 @@ L76K GPS Module Information : https://www.seeedstudio.com/L76K-GNSS-Module-for-S // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 #define SX126X_DIO2_AS_RF_SWITCH #define SX126X_DIO3_TCXO_VOLTAGE 1.8 -#endif \ No newline at end of file +#endif From d00e0f6911005b2904bed64adcbdc6f0103336ee Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 3 Dec 2024 06:17:25 -0600 Subject: [PATCH 03/11] Convert userprefs to a json file instead of header file which has to be included everywhere (#5471) * WIP * Got string quoting and macro expansion working * Need the placeholder * Cleanup * Missed a user prefs reference * Update jsonc --- .trunk/trunk.yaml | 4 +- bin/build-userprefs-json.py | 2 +- bin/platformio-custom.py | 36 ++++++++++-- src/ButtonThread.cpp | 2 +- src/graphics/Screen.h | 3 +- src/main.cpp | 1 - src/mesh/Channels.cpp | 2 +- src/mesh/Default.cpp | 2 +- src/mesh/FloodingRouter.cpp | 2 +- src/mesh/NodeDB.cpp | 1 - src/mesh/Router.cpp | 1 - src/modules/AdminModule.cpp | 4 +- userPrefs.h | 107 ------------------------------------ userPrefs.json | 16 ------ userPrefs.jsonc | 37 +++++++++++++ 15 files changed, 79 insertions(+), 141 deletions(-) delete mode 100644 userPrefs.h delete mode 100644 userPrefs.json create mode 100644 userPrefs.jsonc diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 040712e1d..743f4214d 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -30,7 +30,7 @@ lint: - git-diff-check - gitleaks@8.21.1 - clang-format@16.0.3 - - prettier@3.3.3 + #- prettier@3.3.3 ignore: - linters: [ALL] paths: @@ -46,4 +46,4 @@ actions: enabled: - trunk-fmt-pre-commit - trunk-check-pre-push - - trunk-upgrade-available + - trunk-upgrade-available \ No newline at end of file diff --git a/bin/build-userprefs-json.py b/bin/build-userprefs-json.py index 58f460bcf..d155bae01 100644 --- a/bin/build-userprefs-json.py +++ b/bin/build-userprefs-json.py @@ -24,7 +24,7 @@ def write_macros_to_json(macros, output_file): def main(): header_file = 'userPrefs.h' - output_file = 'userPrefs.json' + output_file = 'userPrefs.jsonc' # Uncomment all macros in the header file with open(header_file, 'r') as file: lines = file.readlines() diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index 701f6b5d8..acfeae10c 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -3,6 +3,8 @@ # trunk-ignore-all(flake8/F821): For SConstruct imports import sys from os.path import join +import json +import re from readprops import readProps @@ -90,11 +92,37 @@ prefsLoc = projenv["PROJECT_DIR"] + "/version.properties" verObj = readProps(prefsLoc) print("Using meshtastic platformio-custom.py, firmware version " + verObj["long"] + " on " + env.get("PIOENV")) +jsonLoc = env["PROJECT_DIR"] + "/userPrefs.jsonc" +with open(jsonLoc) as f: + jsonStr = re.sub("//.*","", f.read(), flags=re.MULTILINE) + userPrefs = json.loads(jsonStr) + +pref_flags = [] +# Pre-process the userPrefs +for pref in userPrefs: + if userPrefs[pref].startswith("{"): + pref_flags.append("-D" + pref + "=" + userPrefs[pref]) + elif userPrefs[pref].replace(".", "").isdigit(): + pref_flags.append("-D" + pref + "=" + userPrefs[pref]) + elif userPrefs[pref] == "true" or userPrefs[pref] == "false": + pref_flags.append("-D" + pref + "=" + userPrefs[pref]) + elif userPrefs[pref].startswith("meshtastic_"): + pref_flags.append("-D" + pref + "=" + userPrefs[pref]) + # If the value is a string, we need to wrap it in quotes + else: + pref_flags.append("-D" + pref + "=" + env.StringifyMacro(userPrefs[pref]) + "") + # General options that are passed to the C and C++ compilers -projenv.Append( - CCFLAGS=[ +flags = [ "-DAPP_VERSION=" + verObj["long"], "-DAPP_VERSION_SHORT=" + verObj["short"], "-DAPP_ENV=" + env.get("PIOENV"), - ] -) + ] + pref_flags + +print ("Using flags:") +for flag in flags: + print(flag) + +projenv.Append( + CCFLAGS=flags, +) \ No newline at end of file diff --git a/src/ButtonThread.cpp b/src/ButtonThread.cpp index 238359952..3f64b3b3e 100644 --- a/src/ButtonThread.cpp +++ b/src/ButtonThread.cpp @@ -1,5 +1,5 @@ #include "ButtonThread.h" -#include "../userPrefs.h" + #include "configuration.h" #if !MESHTASTIC_EXCLUDE_GPS #include "GPS.h" diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index 41c90ca9a..00884c5af 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -1,6 +1,5 @@ #pragma once -#include "../userPrefs.h" #include "configuration.h" #include "detect/ScanI2C.h" @@ -606,4 +605,4 @@ class Screen : public concurrency::OSThread } // namespace graphics -#endif +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 9036cd59c..902668d23 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,3 @@ -#include "../userPrefs.h" #include "configuration.h" #if !MESHTASTIC_EXCLUDE_GPS #include "GPS.h" diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index a516268eb..cfaff7640 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -1,5 +1,5 @@ #include "Channels.h" -#include "../userPrefs.h" + #include "CryptoEngine.h" #include "Default.h" #include "DisplayFormatters.h" diff --git a/src/mesh/Default.cpp b/src/mesh/Default.cpp index ba1dafe70..1bd0340f8 100644 --- a/src/mesh/Default.cpp +++ b/src/mesh/Default.cpp @@ -1,5 +1,5 @@ #include "Default.h" -#include "../userPrefs.h" + #include "meshUtils.h" uint32_t Default::getConfiguredOrDefaultMs(uint32_t configuredInterval, uint32_t defaultInterval) diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index 81ea72381..e959297bf 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -1,5 +1,5 @@ #include "FloodingRouter.h" -#include "../userPrefs.h" + #include "configuration.h" #include "mesh-pb-constants.h" diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 0d63d3b9b..8935e1215 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1,4 +1,3 @@ -#include "../userPrefs.h" #include "configuration.h" #if !MESHTASTIC_EXCLUDE_GPS #include "GPS.h" diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 7b792db30..1303c5caa 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -20,7 +20,6 @@ #if ENABLE_JSON_LOGGING || ARCH_PORTDUINO #include "serialization/MeshPacketSerializer.h" #endif -#include "../userPrefs.h" #define MAX_RX_FROMRADIO \ 4 // max number of packets destined to our queue, we dispatch packets quickly so it doesn't need to be big diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index c81b6ede4..2d33b723d 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -18,7 +18,7 @@ #ifdef ARCH_PORTDUINO #include "unistd.h" #endif -#include "../userPrefs.h" + #include "Default.h" #include "TypeConversions.h" @@ -1123,4 +1123,4 @@ void disableBluetooth() nrf52Bluetooth->shutdown(); #endif #endif -} +} \ No newline at end of file diff --git a/userPrefs.h b/userPrefs.h deleted file mode 100644 index 00f04149a..000000000 --- a/userPrefs.h +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef _USERPREFS_ -#define _USERPREFS_ - -// Slipstream values: - -#define USERPREFS_TZ_STRING "tzplaceholder " - -// Uncomment and modify to set device defaults - -// #define USERPREFS_EVENT_MODE 1 - -// #define USERPREFS_CONFIG_LORA_REGION meshtastic_Config_LoRaConfig_RegionCode_US -// #define USERPREFS_LORACONFIG_MODEM_PRESET meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST -// #define USERPREFS_LORACONFIG_CHANNEL_NUM 31 -// #define USERPREFS_CONFIG_LORA_IGNORE_MQTT true - -// #define USERPREFS_CONFIG_GPS_MODE meshtastic_Config_PositionConfig_GpsMode_ENABLED - -// #define USERPREFS_CHANNELS_TO_WRITE 3 -/* -#define USERPREFS_CHANNEL_0_PSK \ - { \ - 0x38, 0x4b, 0xbc, 0xc0, 0x1d, 0xc0, 0x22, 0xd1, 0x81, 0xbf, 0x36, 0xb8, 0x61, 0x21, 0xe1, 0xfb, 0x96, 0xb7, 0x2e, 0x55, \ - 0xbf, 0x74, 0x22, 0x7e, 0x9d, 0x6a, 0xfb, 0x48, 0xd6, 0x4c, 0xb1, 0xa1 \ - } -*/ -// #define USERPREFS_CHANNEL_0_NAME "DEFCONnect" -// #define USERPREFS_CHANNEL_0_PRECISION 14 -// #define USERPREFS_CHANNEL_0_UPLINK_ENABLED true -// #define USERPREFS_CHANNEL_0_DOWNLINK_ENABLED true -/* -#define USERPREFS_CHANNEL_1_PSK \ - { \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \ - } -*/ -// #define USERPREFS_CHANNEL_1_NAME "REPLACEME" -// #define USERPREFS_CHANNEL_1_PRECISION 14 -// #define USERPREFS_CHANNEL_1_UPLINK_ENABLED true -// #define USERPREFS_CHANNEL_1_DOWNLINK_ENABLED true -/* -#define USERPREFS_CHANNEL_2_PSK \ - { \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \ - } -*/ -// #define USERPREFS_CHANNEL_2_NAME "REPLACEME" -// #define USERPREFS_CHANNEL_2_PRECISION 14 -// #define USERPREFS_CHANNEL_2_UPLINK_ENABLED true -// #define USERPREFS_CHANNEL_2_DOWNLINK_ENABLED true - -// #define USERPREFS_CONFIG_OWNER_LONG_NAME "My Long Name" -// #define USERPREFS_CONFIG_OWNER_SHORT_NAME "MLN" - -// #define USERPREFS_SPLASH_TITLE "DEFCONtastic" -// #define icon_width 34 -// #define icon_height 29 -// #define USERPREFS_HAS_SPLASH -/* -static unsigned char icon_bits[] = { - 0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0xF8, 0x7F, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0x00, - 0x9E, 0xE7, 0x00, 0x00, 0x00, 0x0E, 0xC7, 0x01, 0x00, 0x1C, 0x0F, 0xC7, 0x01, 0x00, 0x1C, 0xDF, 0xE7, 0x63, 0x00, 0x1C, 0xFF, - 0xBF, 0xE1, 0x00, 0x3C, 0xF3, 0xBF, 0xE3, 0x00, 0x7F, 0xF7, 0xBF, 0xF1, 0x00, 0xFF, 0xF7, 0xBF, 0xF9, 0x03, 0xFF, 0xE7, 0x9F, - 0xFF, 0x03, 0xC0, 0xCF, 0xEF, 0xDF, 0x03, 0x00, 0xDF, 0xE3, 0x8F, 0x00, 0x00, 0x7C, 0xFB, 0x03, 0x00, 0x00, 0xF8, 0xFF, 0x00, - 0x00, 0x00, 0xE0, 0x0F, 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x78, 0x3F, 0x00, 0x00, 0x00, 0xFC, 0xFC, 0x00, 0x00, - 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 byte. - */ -/* -#define USERPREFS_USE_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 \ - }; -*/ -// #define USERPREFS_USE_ADMIN_KEY_1 {}; -// #define USERPREFS_USE_ADMIN_KEY_2 {}; - -/* - * USERPREF_FIXED_GPS_LAT and USERPREF_FIXED_GPS_LON must be set, USERPREF_FIXED_GPS_ALT is optional - * - * Fixed GPS is Eiffel Tower, Paris, France - */ -// #define USERPREFS_FIXED_GPS -// #define USERPREFS_FIXED_GPS_LAT 48.85873920 -// #define USERPREFS_FIXED_GPS_LON 2.294508368 -// #define USERPREFS_FIXED_GPS_ALT 0 - -/* - * Set Fixed Bluetooth paring code - */ -// #define USERPREFS_FIXED_BLUETOOTH 121212 - -/* - * Will overwrite BUTTON_PIN if set - */ -// #define USERPREFS_BUTTON_PIN 36 - -#endif \ No newline at end of file diff --git a/userPrefs.json b/userPrefs.json deleted file mode 100644 index bc62602be..000000000 --- a/userPrefs.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "USERPREFS_CHANNEL_0_NAME": "\"DEFCONnect\"", - "USERPREFS_CHANNEL_0_PRECISION": "14", - "USERPREFS_CHANNEL_0_PSK": "{ 0x38, 0x4b, 0xbc, 0xc0, 0x1d, 0xc0, 0x22, 0xd1, 0x81, 0xbf, 0x36, 0xb8, 0x61, 0x21, 0xe1, 0xfb, 0x96, 0xb7, 0x2e, 0x55, 0xbf, 0x74, 0x22, 0x7e, 0x9d, 0x6a, 0xfb, 0x48, 0xd6, 0x4c, 0xb1, 0xa1 }", - "USERPREFS_CONFIG_LORA_IGNORE_MQTT": "true", - "USERPREFS_CONFIG_LORA_REGION": "meshtastic_Config_LoRaConfig_RegionCode_US", - "USERPREFS_CONFIG_OWNER_LONG_NAME": "\"My Long Name\"", - "USERPREFS_CONFIG_OWNER_SHORT_NAME": "\"MLN\"", - "USERPREFS_EVENT_MODE": "1", - "USERPREFS_HAS_SPLASH": "", - "USERPREFS_LORACONFIG_CHANNEL_NUM": "31", - "USERPREFS_LORACONFIG_MODEM_PRESET": "meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST", - "USERPREFS_SPLASH_TITLE": "\"DEFCONtastic\"", - "USERPREFS_TZ_STRING": "\"tzplaceholder \"", - "USERPREFS_USE_ADMIN_KEY": "1" -} diff --git a/userPrefs.jsonc b/userPrefs.jsonc new file mode 100644 index 000000000..055f59273 --- /dev/null +++ b/userPrefs.jsonc @@ -0,0 +1,37 @@ +{ + // "USERPREFS_BUTTON_PIN": "36", + // "USERPREFS_CHANNELS_TO_WRITE": "3", + // "USERPREFS_CHANNEL_0_DOWNLINK_ENABLED": "true", + // "USERPREFS_CHANNEL_0_NAME": "DEFCONnect", + // "USERPREFS_CHANNEL_0_PRECISION": "14", + // "USERPREFS_CHANNEL_0_PSK": "{ 0x38, 0x4b, 0xbc, 0xc0, 0x1d, 0xc0, 0x22, 0xd1, 0x81, 0xbf, 0x36, 0xb8, 0x61, 0x21, 0xe1, 0xfb, 0x96, 0xb7, 0x2e, 0x55, 0xbf, 0x74, 0x22, 0x7e, 0x9d, 0x6a, 0xfb, 0x48, 0xd6, 0x4c, 0xb1, 0xa1 }", + // "USERPREFS_CHANNEL_0_UPLINK_ENABLED": "true", + // "USERPREFS_CHANNEL_1_DOWNLINK_ENABLED": "true", + // "USERPREFS_CHANNEL_1_NAME": "REPLACEME", + // "USERPREFS_CHANNEL_1_PRECISION": "14", + // "USERPREFS_CHANNEL_1_PSK": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }", + // "USERPREFS_CHANNEL_1_UPLINK_ENABLED": "true", + // "USERPREFS_CHANNEL_2_DOWNLINK_ENABLED": "true", + // "USERPREFS_CHANNEL_2_NAME": "REPLACEME", + // "USERPREFS_CHANNEL_2_PRECISION": "14", + // "USERPREFS_CHANNEL_2_PSK": "{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }", + // "USERPREFS_CHANNEL_2_UPLINK_ENABLED": "true", + // "USERPREFS_CONFIG_GPS_MODE": "meshtastic_Config_PositionConfig_GpsMode_ENABLED", + // "USERPREFS_CONFIG_LORA_IGNORE_MQTT": "true", + // "USERPREFS_CONFIG_LORA_REGION": "meshtastic_Config_LoRaConfig_RegionCode_US", + // "USERPREFS_CONFIG_OWNER_LONG_NAME": "My Long Name", + // "USERPREFS_CONFIG_OWNER_SHORT_NAME": "MLN", + // "USERPREFS_EVENT_MODE": "1", + // "USERPREFS_FIXED_BLUETOOTH": "121212", + // "USERPREFS_FIXED_GPS": "", + // "USERPREFS_FIXED_GPS_ALT": "0", + // "USERPREFS_FIXED_GPS_LAT": "48.85873920", + // "USERPREFS_FIXED_GPS_LON": "2.294508368", + // "USERPREFS_LORACONFIG_CHANNEL_NUM": "31", + // "USERPREFS_LORACONFIG_MODEM_PRESET": "meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST", + // "USERPREFS_SPLASH_TITLE": "DEFCONtastic", + "USERPREFS_TZ_STRING": "tzplaceholder " + // "USERPREFS_USE_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 }", + // "USERPREFS_USE_ADMIN_KEY_1": "{}", + // "USERPREFS_USE_ADMIN_KEY_2": "{}" +} \ No newline at end of file From 57ea6a265e6e35d7ee36d50497dafdca120ea6f3 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:21:24 +0100 Subject: [PATCH 04/11] SimRadio: clean-up and emulate collisions (#5487) * Clean up SimRadio and don't let it use PKC * Add collision emulation for SimRadio * Add stats from SimRadio to LocalStats * Make emulating collisions optional --- src/main.cpp | 4 +- src/mesh/MeshService.cpp | 25 +----- src/mesh/MeshService.h | 4 +- src/mesh/PhoneAPI.cpp | 15 ++-- src/mesh/Router.cpp | 3 + src/modules/Telemetry/DeviceTelemetry.cpp | 8 ++ src/platform/portduino/SimRadio.cpp | 97 ++++++++++++++++++----- src/platform/portduino/SimRadio.h | 19 +++-- src/platform/portduino/architecture.h | 3 + 9 files changed, 121 insertions(+), 57 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 902668d23..33eaa131e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,7 +82,7 @@ NRF52Bluetooth *nrf52Bluetooth = nullptr; #include "STM32WLE5JCInterface.h" #endif -#if !HAS_RADIO && defined(ARCH_PORTDUINO) +#if defined(ARCH_PORTDUINO) #include "platform/portduino/SimRadio.h" #endif @@ -896,7 +896,7 @@ void setup() } #endif -#if !HAS_RADIO && defined(ARCH_PORTDUINO) +#if defined(ARCH_PORTDUINO) if (!rIf) { rIf = new SimRadio; if (!rIf->init()) { diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 8f7717585..773ab7053 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -166,27 +166,10 @@ NodeNum MeshService::getNodenumFromRequestId(uint32_t request_id) */ void MeshService::handleToRadio(meshtastic_MeshPacket &p) { -#if defined(ARCH_PORTDUINO) && !HAS_RADIO - // Simulates device received a packet via the LoRa chip - if (p.decoded.portnum == meshtastic_PortNum_SIMULATOR_APP) { - // Simulator packet (=Compressed packet) is encapsulated in a MeshPacket, so need to unwrap first - meshtastic_Compressed scratch; - meshtastic_Compressed *decoded = NULL; - if (p.which_payload_variant == meshtastic_MeshPacket_decoded_tag) { - memset(&scratch, 0, sizeof(scratch)); - p.decoded.payload.size = - pb_decode_from_bytes(p.decoded.payload.bytes, p.decoded.payload.size, &meshtastic_Compressed_msg, &scratch); - if (p.decoded.payload.size) { - decoded = &scratch; - // Extract the original payload and replace - memcpy(&p.decoded.payload, &decoded->data, sizeof(decoded->data)); - // Switch the port from PortNum_SIMULATOR_APP back to the original PortNum - p.decoded.portnum = decoded->portnum; - } else - LOG_ERROR("Error decoding proto for simulator message!"); - } - // Let SimRadio receive as if it did via its LoRa chip - SimRadio::instance->startReceive(&p); +#if defined(ARCH_PORTDUINO) + if (SimRadio::instance && p.decoded.portnum == meshtastic_PortNum_SIMULATOR_APP) { + // Simulates device received a packet via the LoRa chip + SimRadio::instance->unpackAndReceive(p); return; } #endif diff --git a/src/mesh/MeshService.h b/src/mesh/MeshService.h index 1ccca4e6d..268c4308f 100644 --- a/src/mesh/MeshService.h +++ b/src/mesh/MeshService.h @@ -10,7 +10,7 @@ #include "MeshTypes.h" #include "Observer.h" #include "PointerQueue.h" -#if defined(ARCH_PORTDUINO) && !HAS_RADIO +#if defined(ARCH_PORTDUINO) #include "../platform/portduino/SimRadio.h" #endif #if defined(ARCH_ESP32) || defined(ARCH_PORTDUINO) @@ -165,4 +165,4 @@ class MeshService friend class RoutingModule; }; -extern MeshService *service; +extern MeshService *service; \ No newline at end of file diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 20421e73e..f49718c5e 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -613,13 +613,14 @@ bool PhoneAPI::handleToRadioPacket(meshtastic_MeshPacket &p) { printPacket("PACKET FROM PHONE", &p); -// For use with the simulator, we should not ignore duplicate packets -#if !(defined(ARCH_PORTDUINO) && !HAS_RADIO) - if (p.id > 0 && wasSeenRecently(p.id)) { - LOG_DEBUG("Ignore packet from phone, already seen recently"); - return false; - } +#if defined(ARCH_PORTDUINO) + // For use with the simulator, we should not ignore duplicate packets from the phone + if (SimRadio::instance == nullptr) #endif + if (p.id > 0 && wasSeenRecently(p.id)) { + LOG_DEBUG("Ignore packet from phone, already seen recently"); + return false; + } if (p.decoded.portnum == meshtastic_PortNum_TRACEROUTE_APP && lastPortNumToRadio[p.decoded.portnum] && Throttle::isWithinTimespanMs(lastPortNumToRadio[p.decoded.portnum], THIRTY_SECONDS_MS)) { @@ -656,4 +657,4 @@ int PhoneAPI::onNotify(uint32_t newValue) } return timeout ? -1 : 0; // If we timed out, MeshService should stop iterating through observers as we just removed one -} +} \ No newline at end of file diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 1303c5caa..e9c62ff27 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -6,6 +6,7 @@ #include "NodeDB.h" #include "RTC.h" #include "configuration.h" +#include "detect/LoRaRadioType.h" #include "main.h" #include "mesh-pb-constants.h" #include "meshUtils.h" @@ -491,6 +492,8 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p) // is not in the local nodedb // First, only PKC encrypt packets we are originating if (isFromUs(p) && + // Don't use PKC with simulator + radioType != SIM_RADIO && // Don't use PKC with Ham mode !owner.is_licensed && // Don't use PKC if it's not explicitly requested and a non-primary channel is requested diff --git a/src/modules/Telemetry/DeviceTelemetry.cpp b/src/modules/Telemetry/DeviceTelemetry.cpp index 4989b88e2..192754e09 100644 --- a/src/modules/Telemetry/DeviceTelemetry.cpp +++ b/src/modules/Telemetry/DeviceTelemetry.cpp @@ -130,6 +130,14 @@ meshtastic_Telemetry DeviceTelemetryModule::getLocalStatsTelemetry() telemetry.variant.local_stats.num_packets_rx_bad = RadioLibInterface::instance->rxBad; telemetry.variant.local_stats.num_tx_relay = RadioLibInterface::instance->txRelay; } +#ifdef ARCH_PORTDUINO + if (SimRadio::instance) { + telemetry.variant.local_stats.num_packets_tx = SimRadio::instance->txGood; + telemetry.variant.local_stats.num_packets_rx = SimRadio::instance->rxGood + SimRadio::instance->rxBad; + telemetry.variant.local_stats.num_packets_rx_bad = SimRadio::instance->rxBad; + telemetry.variant.local_stats.num_tx_relay = SimRadio::instance->txRelay; + } +#endif if (router) { telemetry.variant.local_stats.num_rx_dupe = router->rxDupe; telemetry.variant.local_stats.num_tx_relay_canceled = router->txRelayCanceled; diff --git a/src/platform/portduino/SimRadio.cpp b/src/platform/portduino/SimRadio.cpp index 0a77b6088..7e63b995e 100644 --- a/src/platform/portduino/SimRadio.cpp +++ b/src/platform/portduino/SimRadio.cpp @@ -73,6 +73,10 @@ void SimRadio::handleTransmitInterrupt() // ignore the transmit interrupt if (sendingPacket) completeSending(); + + isReceiving = true; + if (receivingPacket) // This happens when we don't consider something a collision if we weren't sending long enough + handleReceiveInterrupt(); } void SimRadio::completeSending() @@ -84,6 +88,8 @@ void SimRadio::completeSending() if (p) { txGood++; + if (!isFromUs(p)) + txRelay++; printPacket("Completed sending", p); // We are done sending that packet, release it @@ -113,12 +119,12 @@ bool SimRadio::canSendImmediately() bool SimRadio::isActivelyReceiving() { - return false; // TODO check how this should be simulated + return receivingPacket != nullptr; } bool SimRadio::isChannelActive() { - return false; // TODO ask simulator + return receivingPacket != nullptr; } /** Attempt to cancel a previously sent packet. Returns true if a packet was found we could cancel */ @@ -142,10 +148,16 @@ void SimRadio::onNotify(uint32_t notification) startTransmitTimer(); break; case ISR_RX: + handleReceiveInterrupt(); // LOG_DEBUG("rx complete - starting timer"); startTransmitTimer(); break; case TRANSMIT_DELAY_COMPLETED: + if (receivingPacket) { // This happens when we had a timer pending and we started receiving + handleReceiveInterrupt(); + startTransmitTimer(); + break; + } LOG_DEBUG("delay done"); // If we are not currently in receive mode, then restart the random delay (this can happen if the main thread @@ -183,6 +195,7 @@ void SimRadio::onNotify(uint32_t notification) void SimRadio::startSend(meshtastic_MeshPacket *txp) { printPacket("Start low level send", txp); + isReceiving = false; size_t numbytes = beginSending(txp); meshtastic_MeshPacket *p = packetPool.allocCopy(*txp); perhapsDecode(p); @@ -201,15 +214,64 @@ void SimRadio::startSend(meshtastic_MeshPacket *txp) service->sendQueueStatusToPhone(router->getQueueStatus(), 0, p->id); service->sendToPhone(p); // Sending back to simulator + service->loop(); // Process the send immediately +} + +// Simulates device received a packet via the LoRa chip +void SimRadio::unpackAndReceive(meshtastic_MeshPacket &p) +{ + // Simulator packet (=Compressed packet) is encapsulated in a MeshPacket, so need to unwrap first + meshtastic_Compressed scratch; + meshtastic_Compressed *decoded = NULL; + if (p.which_payload_variant == meshtastic_MeshPacket_decoded_tag) { + memset(&scratch, 0, sizeof(scratch)); + p.decoded.payload.size = + pb_decode_from_bytes(p.decoded.payload.bytes, p.decoded.payload.size, &meshtastic_Compressed_msg, &scratch); + if (p.decoded.payload.size) { + decoded = &scratch; + // Extract the original payload and replace + memcpy(&p.decoded.payload, &decoded->data, sizeof(decoded->data)); + // Switch the port from PortNum_SIMULATOR_APP back to the original PortNum + p.decoded.portnum = decoded->portnum; + } else + LOG_ERROR("Error decoding proto for simulator message!"); + } + // Let SimRadio receive as if it did via its LoRa chip + startReceive(&p); } void SimRadio::startReceive(meshtastic_MeshPacket *p) { +#ifdef USERPREFS_SIMRADIO_EMULATE_COLLISIONS + if (isActivelyReceiving()) { + LOG_WARN("Collision detected, dropping current and previous packet!"); + rxBad++; + airTime->logAirtime(RX_ALL_LOG, getPacketTime(receivingPacket)); + packetPool.release(receivingPacket); + receivingPacket = nullptr; + return; + } else if (sendingPacket) { + uint32_t airtimeLeft = tillRun(millis()); + if (airtimeLeft <= 0) { + LOG_WARN("Transmitting packet was already done"); + handleTransmitInterrupt(); // Finish sending first + } else if ((interval - airtimeLeft) > preambleTimeMsec) { + // Only if transmitting for longer than preamble there is a collision + // (channel should actually be detected as active otherwise) + LOG_WARN("Collision detected during transmission!"); + return; + } + } isReceiving = true; - size_t length = getPacketLength(p); - uint32_t xmitMsec = getPacketTime(length); - delay(xmitMsec); // Model the time it is busy receiving - handleReceiveInterrupt(p); + receivingPacket = packetPool.allocCopy(*p); + uint32_t airtimeMsec = getPacketTime(p); + notifyLater(airtimeMsec, ISR_RX, false); // Model the time it is busy receiving +#else + isReceiving = true; + receivingPacket = packetPool.allocCopy(*p); + handleReceiveInterrupt(); // Simulate receiving the packet immediately + startTransmitTimer(); +#endif } meshtastic_QueueStatus SimRadio::getQueueStatus() @@ -223,28 +285,27 @@ meshtastic_QueueStatus SimRadio::getQueueStatus() return qs; } -void SimRadio::handleReceiveInterrupt(meshtastic_MeshPacket *p) +void SimRadio::handleReceiveInterrupt() { - LOG_DEBUG("HANDLE RECEIVE INTERRUPT"); - uint32_t xmitMsec; + if (receivingPacket == nullptr) { + return; + } if (!isReceiving) { LOG_DEBUG("*** WAS_ASSERT *** handleReceiveInterrupt called when not in receive mode"); return; } - isReceiving = false; + LOG_DEBUG("HANDLE RECEIVE INTERRUPT"); + rxGood++; - // read the number of actually received bytes - size_t length = getPacketLength(p); - xmitMsec = getPacketTime(length); - // LOG_DEBUG("Payload size %d vs length (includes header) %d", p->decoded.payload.size, length); - - meshtastic_MeshPacket *mp = packetPool.allocCopy(*p); // keep a copy in packetPool + meshtastic_MeshPacket *mp = packetPool.allocCopy(*receivingPacket); // keep a copy in packetPool + packetPool.release(receivingPacket); // release the original + receivingPacket = nullptr; printPacket("Lora RX", mp); - airTime->logAirtime(RX_LOG, xmitMsec); + airTime->logAirtime(RX_LOG, getPacketTime(mp)); deliverToReceiver(mp); } @@ -265,4 +326,4 @@ int16_t SimRadio::readData(uint8_t *data, size_t len) } return state; -} +} \ No newline at end of file diff --git a/src/platform/portduino/SimRadio.h b/src/platform/portduino/SimRadio.h index 1edb4963b..c082444e5 100644 --- a/src/platform/portduino/SimRadio.h +++ b/src/platform/portduino/SimRadio.h @@ -11,11 +11,6 @@ class SimRadio : public RadioInterface, protected concurrency::NotifiedWorkerThr { enum PendingISR { ISR_NONE = 0, ISR_RX, ISR_TX, TRANSMIT_DELAY_COMPLETED }; - /** - * Debugging counts - */ - uint32_t rxBad = 0, rxGood = 0, txGood = 0; - MeshPacketQueue txQueue = MeshPacketQueue(MAX_TX_QUEUE); public: @@ -47,9 +42,17 @@ class SimRadio : public RadioInterface, protected concurrency::NotifiedWorkerThr meshtastic_QueueStatus getQueueStatus() override; + // Convert Compressed_msg to normal msg and receive it + void unpackAndReceive(meshtastic_MeshPacket &p); + + /** + * Debugging counts + */ + uint32_t rxBad = 0, rxGood = 0, txGood = 0, txRelay = 0; + protected: /// are _trying_ to receive a packet currently (note - we might just be waiting for one) - bool isReceiving = false; + bool isReceiving = true; private: void setTransmitDelay(); @@ -61,7 +64,7 @@ class SimRadio : public RadioInterface, protected concurrency::NotifiedWorkerThr void startTransmitTimerSNR(float snr); void handleTransmitInterrupt(); - void handleReceiveInterrupt(meshtastic_MeshPacket *p); + void handleReceiveInterrupt(); void onNotify(uint32_t notification); @@ -73,6 +76,8 @@ class SimRadio : public RadioInterface, protected concurrency::NotifiedWorkerThr int16_t readData(uint8_t *str, size_t len); + meshtastic_MeshPacket *receivingPacket = nullptr; // The packet we are currently receiving + protected: /** Could we send right now (i.e. either not actively receiving or transmitting)? */ virtual bool canSendImmediately(); diff --git a/src/platform/portduino/architecture.h b/src/platform/portduino/architecture.h index 321949226..3dde87199 100644 --- a/src/platform/portduino/architecture.h +++ b/src/platform/portduino/architecture.h @@ -11,6 +11,9 @@ #ifndef HAS_WIFI #define HAS_WIFI 1 #endif +#ifndef HAS_RADIO +#define HAS_RADIO 1 +#endif #ifndef HAS_RTC #define HAS_RTC 1 #endif From 7ad137b56a3fb25606b944de659839ede67269e0 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 3 Dec 2024 06:28:46 -0600 Subject: [PATCH 05/11] add nodeId to nodeinfo update log lines and removed redundant nodeinfo update log line (#5493) --- src/mesh/NodeDB.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 8935e1215..cd5011ea2 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1242,7 +1242,6 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde return false; } - LOG_DEBUG("old user %s/%s, channel=%d", info->user.long_name, info->user.short_name, info->channel); #if !(MESHTASTIC_EXCLUDE_PKI) if (p.public_key.size > 0) { printBytes("Incoming Pubkey: ", p.public_key.bytes, 32); @@ -1266,7 +1265,8 @@ bool NodeDB::updateUser(uint32_t nodeId, meshtastic_User &p, uint8_t channelInde } if (nodeId != getNodeNum()) info->channel = channelIndex; // Set channel we need to use to reach this node (but don't set our own channel) - LOG_DEBUG("Update changed=%d user %s/%s, channel=%d", changed, info->user.long_name, info->user.short_name, info->channel); + LOG_DEBUG("Update changed=%d user %s/%s, id=0x%08x, channel=%d", changed, info->user.long_name, info->user.short_name, nodeId, + info->channel); info->has_user = true; if (changed) { From 85b2bad2753db5db5d67b0b3e4f1dcb04b581cfe Mon Sep 17 00:00:00 2001 From: dylanli Date: Tue, 3 Dec 2024 20:29:33 +0800 Subject: [PATCH 06/11] Refact the macro definition of GPS initialization of GPSDEFAULTD_NOT_PRESENT and added seeeed Indicator to this sequence (#5494) Co-authored-by: Ben Meadors --- src/mesh/NodeDB.cpp | 2 +- variants/seeed-sensecap-indicator/variant.h | 1 + variants/t-deck/variant.h | 2 +- variants/tlora_t3s3_epaper/variant.h | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index cd5011ea2..4bb9e68dd 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -464,7 +464,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false) #endif #if defined(USERPREFS_CONFIG_GPS_MODE) config.position.gps_mode = USERPREFS_CONFIG_GPS_MODE; -#elif !HAS_GPS || defined(T_DECK) || defined(TLORA_T3S3_EPAPER) +#elif !HAS_GPS || GPS_DEFAULT_NOT_PRESENT config.position.gps_mode = meshtastic_Config_PositionConfig_GpsMode_NOT_PRESENT; #elif !defined(GPS_RX_PIN) if (config.position.rx_gpio == 0) diff --git a/variants/seeed-sensecap-indicator/variant.h b/variants/seeed-sensecap-indicator/variant.h index 55895f353..6028a3ffa 100644 --- a/variants/seeed-sensecap-indicator/variant.h +++ b/variants/seeed-sensecap-indicator/variant.h @@ -40,6 +40,7 @@ // // Buzzer // #define PIN_BUZZER 19 +#define GPS_DEFAULT_NOT_PRESENT 1 #define GPS_RX_PIN 20 #define GPS_TX_PIN 19 #define HAS_GPS 1 diff --git a/variants/t-deck/variant.h b/variants/t-deck/variant.h index 6d398391e..91c12ab3d 100644 --- a/variants/t-deck/variant.h +++ b/variants/t-deck/variant.h @@ -29,7 +29,7 @@ #define BUTTON_PIN 0 // #define BUTTON_NEED_PULLUP - +#define GPS_DEFAULT_NOT_PRESENT 1 #define GPS_RX_PIN 44 #define GPS_TX_PIN 43 diff --git a/variants/tlora_t3s3_epaper/variant.h b/variants/tlora_t3s3_epaper/variant.h index 461ce0c31..732869b20 100644 --- a/variants/tlora_t3s3_epaper/variant.h +++ b/variants/tlora_t3s3_epaper/variant.h @@ -19,6 +19,7 @@ #define I2C_SCL SCL // external qwiic connector +#define GPS_DEFAULT_NOT_PRESENT 1 #define GPS_RX_PIN 44 #define GPS_TX_PIN 43 From f846503cbfa55edccdb8ec38b8f6e7b362b7bc53 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 3 Dec 2024 06:30:19 -0600 Subject: [PATCH 07/11] Extend Length of Source and Destination Node IDs Logged (#5492) * show 8 chars for logging source and destination ids * extend legnth of source and destination nodes in log --- src/mesh/RadioInterface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 53b66ff0a..5161ac41f 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -284,8 +284,8 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr) void printPacket(const char *prefix, const meshtastic_MeshPacket *p) { #ifdef DEBUG_PORT - std::string out = DEBUG_PORT.mt_sprintf("%s (id=0x%08x fr=0x%02x to=0x%02x, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id, - p->from & 0xff, p->to & 0xff, p->want_ack, p->hop_limit, p->channel); + std::string out = DEBUG_PORT.mt_sprintf("%s (id=0x%08x fr=0x%08x to=0x%08x, WantAck=%d, HopLim=%d Ch=0x%x", prefix, p->id, + p->from, p->to, p->want_ack, p->hop_limit, p->channel); if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { auto &s = p->decoded; @@ -622,4 +622,4 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p) sendingPacket = p; return p->encrypted.size + sizeof(PacketHeader); -} +} \ No newline at end of file From 10e10450cfb8f8a36fa0934ea38bbdcab15b01ce Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:33:27 +0200 Subject: [PATCH 08/11] Added femtofox configs (#5477) * added femtofox configs * Rename bin/config.d/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml to bin/config.d/femtofox/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml * moved femtofox configs to subdir --- ...ofox_EByte-E22-900M30S_Ebyte-E22-900M22S.yaml | 16 ++++++++++++++++ .../femtofox/femtofox_EByte-E22-900MM22S.yaml | 16 ++++++++++++++++ ...femtofox_Heltec-HT-RA62_Seeed-WIO-SX1262.yaml | 14 ++++++++++++++ ...Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml | 13 +++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 bin/config.d/femtofox/femtofox_EByte-E22-900M30S_Ebyte-E22-900M22S.yaml create mode 100644 bin/config.d/femtofox/femtofox_EByte-E22-900MM22S.yaml create mode 100644 bin/config.d/femtofox/femtofox_Heltec-HT-RA62_Seeed-WIO-SX1262.yaml create mode 100644 bin/config.d/femtofox/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml diff --git a/bin/config.d/femtofox/femtofox_EByte-E22-900M30S_Ebyte-E22-900M22S.yaml b/bin/config.d/femtofox/femtofox_EByte-E22-900M30S_Ebyte-E22-900M22S.yaml new file mode 100644 index 000000000..6c88b1eb2 --- /dev/null +++ b/bin/config.d/femtofox/femtofox_EByte-E22-900M30S_Ebyte-E22-900M22S.yaml @@ -0,0 +1,16 @@ +--- +Lora: +## Ebyte E22-900M30S, E22-900M22S with no external RF switching setup +## Will work with any module without RF switching, and with TCXO + Module: sx1262 + gpiochip: 1 # subtract 32 from the gpio numbers + DIO2_AS_RF_SWITCH: true + DIO3_TCXO_VOLTAGE: true + CS: 16 #pin6 / GPIO48 1C0 + IRQ: 23 #pin17 / GPIO55 1C7 + Busy: 22 #pin16 / GPIO54 1C6 + Reset: 25 #pin13 / GPIO57 1D1 + RXen: 24 #pin12 / GPIO56 1D0 + #TXen: bridge to DIO2 on E22 module + spidev: spidev0.0 + spiSpeed: 2000000 \ No newline at end of file diff --git a/bin/config.d/femtofox/femtofox_EByte-E22-900MM22S.yaml b/bin/config.d/femtofox/femtofox_EByte-E22-900MM22S.yaml new file mode 100644 index 000000000..451d5d3f4 --- /dev/null +++ b/bin/config.d/femtofox/femtofox_EByte-E22-900MM22S.yaml @@ -0,0 +1,16 @@ +--- +Lora: +## Ebyte E22-900MM22S with no external RF switching setup +## Will work with any module without RF switching and no TCXO + Module: sx1262 + gpiochip: 1 # subtract 32 from the gpio numbers + DIO2_AS_RF_SWITCH: true + DIO3_TCXO_VOLTAGE: true + CS: 16 #pin6 / GPIO48 1C0 + IRQ: 23 #pin17 / GPIO55 1C7 + Busy: 22 #pin16 / GPIO54 1C6 + Reset: 25 #pin13 / GPIO57 1D1 + RXen: 24 #pin12 / GPIO56 1D0 + #TXen: bridge to DIO2 on E22 module + spidev: spidev0.0 + spiSpeed: 2000000 \ No newline at end of file diff --git a/bin/config.d/femtofox/femtofox_Heltec-HT-RA62_Seeed-WIO-SX1262.yaml b/bin/config.d/femtofox/femtofox_Heltec-HT-RA62_Seeed-WIO-SX1262.yaml new file mode 100644 index 000000000..d5f02b42c --- /dev/null +++ b/bin/config.d/femtofox/femtofox_Heltec-HT-RA62_Seeed-WIO-SX1262.yaml @@ -0,0 +1,14 @@ +--- +Lora: +## Heltec HT-RA62, Seeed WIO SX1262 +## Will work with any module with automatic RF switching, and with TCXO + Module: sx1262 + gpiochip: 1 # subtract 32 from the gpio numbers + DIO2_AS_RF_SWITCH: true + DIO3_TCXO_VOLTAGE: true + CS: 16 #pin6 (GPIO pin 48 1C0) + IRQ: 23 #pin17 (GPIO pin 55 1C7) + Reset: 25 #pin13 (GPIO pin 57 1D1) + Busy: 22 #pin16 (GPIO pin 54 1C6) + spidev: spidev0.0 #pins are (CS=6, CLK=7, MOSI=8, MISO=9) + spiSpeed: 2000000 \ No newline at end of file diff --git a/bin/config.d/femtofox/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml b/bin/config.d/femtofox/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml new file mode 100644 index 000000000..23834adec --- /dev/null +++ b/bin/config.d/femtofox/femtofox_Waveshare-SX126X-XXXM_AI-Thinker-RA-01SH.yaml @@ -0,0 +1,13 @@ +--- +Lora: +## Waveshare SX126X XXXM, AI Thinker RA-01SH +## Will work with any module with automatic RF switching, and with no TCXO + Module: sx1262 + gpiochip: 1 # subtract 32 from the gpio numbers + DIO2_AS_RF_SWITCH: true + CS: 16 #pin6 (GPIO pin 48 1C0) + IRQ: 23 #pin17 (GPIO pin 55 1C7) + Reset: 25 #pin13 (GPIO pin 57 1D1) + Busy: 22 #pin16 (GPIO pin 54 1C6) + spidev: spidev0.0 #pins are (CS=6, CLK=7, MOSI=8, MISO=9) + spiSpeed: 2000000 From e4f53677fca9ad718706a471b4926e24b7dba2cc Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Wed, 4 Dec 2024 13:39:02 +0200 Subject: [PATCH 09/11] [Add] LR1110, LR1120 and LR1121 to linux native Portduino (#5496) * Update main.cpp * Update PortduinoGlue.h * Update PortduinoGlue.cpp * Update PortduinoGlue.cpp * Update PortduinoGlue.cpp * Update main.cpp --- src/main.cpp | 47 +++++++++++++++++++++++- src/platform/portduino/PortduinoGlue.cpp | 11 +++++- src/platform/portduino/PortduinoGlue.h | 5 ++- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 33eaa131e..53a662272 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -858,6 +858,51 @@ void setup() LOG_INFO("SX1280 init success"); } } + } else if (settingsMap[use_lr1110]) { + if (!rIf) { + LOG_DEBUG("Activate lr1110 radio on SPI port %s", settingsStrings[spidev].c_str()); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); + rIf = new LR1110Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], + settingsMap[busy]); + if (!rIf->init()) { + LOG_WARN("No LR1110 radio"); + delete rIf; + rIf = NULL; + exit(EXIT_FAILURE); + } else { + LOG_INFO("LR1110 init success"); + } + } + } else if (settingsMap[use_lr1120]) { + if (!rIf) { + LOG_DEBUG("Activate lr1120 radio on SPI port %s", settingsStrings[spidev].c_str()); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); + rIf = new LR1120Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], + settingsMap[busy]); + if (!rIf->init()) { + LOG_WARN("No LR1120 radio"); + delete rIf; + rIf = NULL; + exit(EXIT_FAILURE); + } else { + LOG_INFO("LR1120 init success"); + } + } + } else if (settingsMap[use_lr1121]) { + if (!rIf) { + LOG_DEBUG("Activate lr1121 radio on SPI port %s", settingsStrings[spidev].c_str()); + LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings); + rIf = new LR1121Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset], + settingsMap[busy]); + if (!rIf->init()) { + LOG_WARN("No LR1121 radio"); + delete rIf; + rIf = NULL; + exit(EXIT_FAILURE); + } else { + LOG_INFO("LR1121 init success"); + } + } } else if (settingsMap[use_sx1268]) { if (!rIf) { LOG_DEBUG("Activate sx1268 radio on SPI port %s", settingsStrings[spidev].c_str()); @@ -1218,4 +1263,4 @@ void loop() mainDelay.delay(delayMsec); } } -#endif \ No newline at end of file +#endif diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index d53a5be94..a4485e91f 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -272,6 +272,9 @@ bool loadConfig(const char *configPath) settingsMap[use_sx1262] = false; settingsMap[use_rf95] = false; settingsMap[use_sx1280] = false; + settingsMap[use_lr1110] = false; + settingsMap[use_lr1120] = false; + settingsMap[use_lr1121] = false; settingsMap[use_sx1268] = false; if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1262") { @@ -280,6 +283,12 @@ bool loadConfig(const char *configPath) 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("") == "lr1110") { + settingsMap[use_lr1110] = true; + } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "lr1120") { + settingsMap[use_lr1120] = true; + } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "lr1121") { + settingsMap[use_lr1121] = true; } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as("") == "sx1268") { settingsMap[use_sx1268] = true; } @@ -415,4 +424,4 @@ bool loadConfig(const char *configPath) 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 95d82c1a2..1e0223c48 100644 --- a/src/platform/portduino/PortduinoGlue.h +++ b/src/platform/portduino/PortduinoGlue.h @@ -16,6 +16,9 @@ enum configNames { ch341Quirk, use_rf95, use_sx1280, + use_lr1110, + use_lr1120, + use_lr1121, use_sx1268, user, gpiochip, @@ -67,4 +70,4 @@ extern std::map settingsStrings; extern std::ofstream traceFile; 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 +static bool ends_with(std::string_view str, std::string_view suffix); From 8eca6a2df8698196ae98b319000386df0be9a2d3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 08:15:50 -0600 Subject: [PATCH 10/11] [create-pull-request] automated change (#5500) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/protobufs b/protobufs index 02e6576ef..00c9c9932 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 02e6576efaa2f691be9504b8c1c6261703f7a277 +Subproject commit 00c9c9932ea50c14cdc44d497d2672a0031641ce diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index a173adb4d..da439c375 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -215,6 +215,11 @@ typedef enum _meshtastic_HardwareModel { /* WisMesh Tap RAK-4631 w/ TFT in injection modled case */ meshtastic_HardwareModel_WISMESH_TAP = 84, + /* Similar to PORTDUINO but used by Routastic devices, this is not any + particular device and does not run Meshtastic's code but supports + the same frame format. + Runs on linux, see https://github.com/Jorropo/routastic */ + meshtastic_HardwareModel_ROUTASTIC = 85, /* ------------------------------------------------------------------------------------------------------------------------------------------ Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. ------------------------------------------------------------------------------------------------------------------------------------------ */ From d3e3985e397e539417d0cd5ebbcf3081aacf8a91 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Wed, 4 Dec 2024 12:15:17 -0600 Subject: [PATCH 11/11] Fix minor typos in package workflows (#5505) --- .github/workflows/package_amd64.yml | 6 +++--- .github/workflows/package_raspbian.yml | 6 +++--- .github/workflows/package_raspbian_armv7l.yml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/package_amd64.yml b/.github/workflows/package_amd64.yml index c11566deb..ce2c85d54 100644 --- a/.github/workflows/package_amd64.yml +++ b/.github/workflows/package_amd64.yml @@ -57,11 +57,11 @@ jobs: shopt -s dotglob nullglob if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then mv .debpkg/usr/share/doc/meshtasticd/web/build/* .debpkg/usr/share/doc/meshtasticd/web/; fi if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then rmdir .debpkg/usr/share/doc/meshtasticd/web/build; fi - if [ -d .debpkg/usr/share/doc/meshtasticd/web/.DS_Store]; then rm -f .debpkg/usr/share/doc/meshtasticd/web/.DS_Store; fi + if [ -d .debpkg/usr/share/doc/meshtasticd/web/.DS_Store ]; then rm -f .debpkg/usr/share/doc/meshtasticd/web/.DS_Store; fi gunzip .debpkg/usr/share/doc/meshtasticd/web/ -r 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/ + cp bin/config.d/* .debpkg/etc/meshtasticd/available.d/ -r 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 @@ -82,4 +82,4 @@ jobs: name: meshtasticd_${{ steps.version.outputs.version }}_amd64.deb overwrite: true path: | - ./*.deb + ./*.deb \ No newline at end of file diff --git a/.github/workflows/package_raspbian.yml b/.github/workflows/package_raspbian.yml index 56b683fdd..46039b6ea 100644 --- a/.github/workflows/package_raspbian.yml +++ b/.github/workflows/package_raspbian.yml @@ -57,11 +57,11 @@ jobs: shopt -s dotglob nullglob if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then mv .debpkg/usr/share/doc/meshtasticd/web/build/* .debpkg/usr/share/doc/meshtasticd/web/; fi if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then rmdir .debpkg/usr/share/doc/meshtasticd/web/build; fi - if [ -d .debpkg/usr/share/doc/meshtasticd/web/.DS_Store]; then rm -f .debpkg/usr/share/doc/meshtasticd/web/.DS_Store; fi + if [ -d .debpkg/usr/share/doc/meshtasticd/web/.DS_Store ]; then rm -f .debpkg/usr/share/doc/meshtasticd/web/.DS_Store; fi gunzip .debpkg/usr/share/doc/meshtasticd/web/ -r 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/ + cp bin/config.d/* .debpkg/etc/meshtasticd/available.d/ -r 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 @@ -82,4 +82,4 @@ jobs: name: meshtasticd_${{ steps.version.outputs.version }}_arm64.deb overwrite: true path: | - ./*.deb + ./*.deb \ No newline at end of file diff --git a/.github/workflows/package_raspbian_armv7l.yml b/.github/workflows/package_raspbian_armv7l.yml index 663903e10..2eda103ca 100644 --- a/.github/workflows/package_raspbian_armv7l.yml +++ b/.github/workflows/package_raspbian_armv7l.yml @@ -57,11 +57,11 @@ jobs: shopt -s dotglob nullglob if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then mv .debpkg/usr/share/doc/meshtasticd/web/build/* .debpkg/usr/share/doc/meshtasticd/web/; fi if [ -d .debpkg/usr/share/doc/meshtasticd/web/build ]; then rmdir .debpkg/usr/share/doc/meshtasticd/web/build; fi - if [ -d .debpkg/usr/share/doc/meshtasticd/web/.DS_Store]; then rm -f .debpkg/usr/share/doc/meshtasticd/web/.DS_Store; fi + if [ -d .debpkg/usr/share/doc/meshtasticd/web/.DS_Store ]; then rm -f .debpkg/usr/share/doc/meshtasticd/web/.DS_Store; fi gunzip .debpkg/usr/share/doc/meshtasticd/web/ -r 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/ + cp bin/config.d/* .debpkg/etc/meshtasticd/available.d/ -r 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 @@ -82,4 +82,4 @@ jobs: name: meshtasticd_${{ steps.version.outputs.version }}_armhf.deb overwrite: true path: | - ./*.deb + ./*.deb \ No newline at end of file