From 83e309f3bfc9bb6ec3c0af937d3202ee6ba3f913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 10 Feb 2023 01:35:25 +0100 Subject: [PATCH 01/25] label boards as secondary to split the core firmware archive by support level. Ref: https://docs.platformio.org/en/latest/scripting/examples/platformio_ini_custom_options.html --- .../platformio.ini | 1 + variants/betafpv_2400_tx_micro/platformio.ini | 1 + variants/diy/platformio.ini | 3 +++ variants/feather_diy/platformio.ini | 1 + variants/genieblocks/platformio.ini | 7 ----- variants/genieblocks/variant.h | 26 ------------------- variants/heltec_v1/platformio.ini | 1 + variants/heltec_v2.1/platformio.ini | 1 + variants/heltec_v2/platformio.ini | 1 + variants/lora_isp4520/platformio.ini | 1 + variants/lora_relay_v1/platformio.ini | 1 + variants/lora_relay_v2/platformio.ini | 1 + variants/m5stack_core/platformio.ini | 1 + variants/m5stack_coreink/platformio.ini | 1 + variants/pca10056-rc-clock/platformio.ini | 1 + variants/portduino/platformio.ini | 3 +++ variants/ppr/platformio.ini | 1 + variants/ppr1/platformio.ini | 1 + variants/rak11200/platformio.ini | 1 + variants/rpipico/platformio.ini | 1 + variants/rpipicow/platformio.ini | 1 + variants/tbeam_v07/platformio.ini | 1 + variants/tlora_v1_3/platformio.ini | 1 + variants/tlora_v2/platformio.ini | 1 + variants/wio-e5/platformio.ini | 1 + 25 files changed, 27 insertions(+), 33 deletions(-) delete mode 100644 variants/genieblocks/platformio.ini delete mode 100644 variants/genieblocks/variant.h diff --git a/variants/Dongle_nRF52840-pca10059-v1/platformio.ini b/variants/Dongle_nRF52840-pca10059-v1/platformio.ini index 027ab41d5..ea14d1a21 100644 --- a/variants/Dongle_nRF52840-pca10059-v1/platformio.ini +++ b/variants/Dongle_nRF52840-pca10059-v1/platformio.ini @@ -1,6 +1,7 @@ [env:pca10059_diy_eink] extends = nrf52840_base board = nordic_pca10059 +board_level = extra build_flags = ${nrf52840_base.build_flags} -Ivariants/Dongle_nRF52840-pca10059-v1 -D NORDIC_PCA10059 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/Dongle_nRF52840-pca10059-v1> lib_deps = diff --git a/variants/betafpv_2400_tx_micro/platformio.ini b/variants/betafpv_2400_tx_micro/platformio.ini index e04f4efc2..decdb390e 100644 --- a/variants/betafpv_2400_tx_micro/platformio.ini +++ b/variants/betafpv_2400_tx_micro/platformio.ini @@ -1,6 +1,7 @@ [env:betafpv_2400_tx_micro] extends = esp32_base board = esp32doit-devkit-v1 +board_level = extra build_flags = ${esp32_base.build_flags} -D BETAFPV_2400_TX diff --git a/variants/diy/platformio.ini b/variants/diy/platformio.ini index 9a2b5d467..d50d0c4f3 100644 --- a/variants/diy/platformio.ini +++ b/variants/diy/platformio.ini @@ -2,6 +2,7 @@ [env:meshtastic-diy-v1] extends = esp32_base board = esp32doit-devkit-v1 +board_level = extra build_flags = ${esp32_base.build_flags} -D DIY_V1 @@ -13,6 +14,7 @@ build_flags = [env:meshtastic-diy-v1.1] extends = esp32_base board = esp32doit-devkit-v1 +board_level = extra build_flags = ${esp32_base.build_flags} -D DIY_V1 @@ -24,6 +26,7 @@ build_flags = [env:meshtastic-dr-dev] extends = esp32_base board = esp32doit-devkit-v1 +board_level = extra board_upload.maximum_size = 4194304 board_upload.maximum_ram_size = 532480 build_flags = diff --git a/variants/feather_diy/platformio.ini b/variants/feather_diy/platformio.ini index 84c582ab0..9b4806343 100644 --- a/variants/feather_diy/platformio.ini +++ b/variants/feather_diy/platformio.ini @@ -2,6 +2,7 @@ [env:feather_diy] extends = nrf52840_base board = adafruit_feather_nrf52840 +board_level = extra build_flags = ${nrf52840_base.build_flags} -Ivariants/feather_diy -Dfeather_diy build_src_filter = ${nrf52_base.build_src_filter} +<../variants/feather_diy> lib_deps = diff --git a/variants/genieblocks/platformio.ini b/variants/genieblocks/platformio.ini deleted file mode 100644 index b1d32277a..000000000 --- a/variants/genieblocks/platformio.ini +++ /dev/null @@ -1,7 +0,0 @@ -; The GenieBlocks LORA prototype board -; note: @geeksville disabled because genieblocks_lora is not checked into the boards directory, please send in a PR to add it ;-) -;[env:genieblocks_lora] -;extends = esp32_base -;board = genieblocks_lora -;build_flags = -; ${esp32_base.build_flags} -D GENIEBLOCKS -Ivariants/genieblocks \ No newline at end of file diff --git a/variants/genieblocks/variant.h b/variants/genieblocks/variant.h deleted file mode 100644 index 0e51e3a9e..000000000 --- a/variants/genieblocks/variant.h +++ /dev/null @@ -1,26 +0,0 @@ -#undef GPS_RX_PIN -#undef GPS_TX_PIN -#define GPS_RX_PIN 5 -#define GPS_TX_PIN 18 -#define GPS_RESET_N 10 -#define GPS_EXTINT 23 // On MAX-M8 module pin name is EXTINT. On L70 module pin name is STANDBY. - -#define BATTERY_PIN 39 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage -#define BATTERY_EN_PIN 14 // Voltage voltage divider enable pin connected to mosfet - -#define I2C_SDA 4 // I2C pins for this board -#define I2C_SCL 2 - -#define LED_PIN 12 // If defined we will blink this LED -//#define BUTTON_PIN 36 // If defined, this will be used for user button presses (ToDo problem on that line on debug screen --> -// Long press start!) #define BUTTON_NEED_PULLUP //GPIOs 34 to 39 are GPIs – input only pins. These pins don’t have internal -// pull-ups or pull-down resistors. - -#define USE_RF95 -#define LORA_DIO0 38 // a No connect on the SX1262 module -#define LORA_RESET 9 - -#define RF95_SCK 22 -#define RF95_MISO 19 -#define RF95_MOSI 13 -#define RF95_NSS 21 \ No newline at end of file diff --git a/variants/heltec_v1/platformio.ini b/variants/heltec_v1/platformio.ini index 1ed6dff84..ee10ef0f6 100644 --- a/variants/heltec_v1/platformio.ini +++ b/variants/heltec_v1/platformio.ini @@ -1,6 +1,7 @@ [env:heltec-v1] ;build_type = debug ; to make it possible to step through our jtag debugger extends = esp32_base +board_level = extra board = heltec_wifi_lora_32 build_flags = ${esp32_base.build_flags} -D HELTEC_V1 -I variants/heltec_v1 \ No newline at end of file diff --git a/variants/heltec_v2.1/platformio.ini b/variants/heltec_v2.1/platformio.ini index 5fb4c8c32..792a1bb94 100644 --- a/variants/heltec_v2.1/platformio.ini +++ b/variants/heltec_v2.1/platformio.ini @@ -2,5 +2,6 @@ ;build_type = debug ; to make it possible to step through our jtag debugger extends = esp32_base board = heltec_wifi_lora_32_V2 +board_level = extra build_flags = ${esp32_base.build_flags} -D HELTEC_V2_1 -I variants/heltec_v2.1 \ No newline at end of file diff --git a/variants/heltec_v2/platformio.ini b/variants/heltec_v2/platformio.ini index 6211437f0..8a60942a9 100644 --- a/variants/heltec_v2/platformio.ini +++ b/variants/heltec_v2/platformio.ini @@ -2,5 +2,6 @@ ;build_type = debug ; to make it possible to step through our jtag debugger extends = esp32_base board = heltec_wifi_lora_32_V2 +board_level = extra build_flags = ${esp32_base.build_flags} -D HELTEC_V2_0 -I variants/heltec_v2 \ No newline at end of file diff --git a/variants/lora_isp4520/platformio.ini b/variants/lora_isp4520/platformio.ini index fb9fdf913..9d6563515 100644 --- a/variants/lora_isp4520/platformio.ini +++ b/variants/lora_isp4520/platformio.ini @@ -1,6 +1,7 @@ [env:lora_isp4520] extends = nrf52_base board = lora_isp4520 +board_level = extra # add our variants files to the include and src paths build_flags = ${nrf52_base.build_flags} -Ivariants/lora_isp4520 diff --git a/variants/lora_relay_v1/platformio.ini b/variants/lora_relay_v1/platformio.ini index 9a73fda7c..8df7bd1d6 100644 --- a/variants/lora_relay_v1/platformio.ini +++ b/variants/lora_relay_v1/platformio.ini @@ -2,6 +2,7 @@ [env:lora-relay-v1] extends = nrf52840_base board = lora-relay-v1 +board_level = extra # add our variants files to the include and src paths # define build flags for the TFT_eSPI library build_flags = ${nrf52840_base.build_flags} -Ivariants/lora_relay_v1 diff --git a/variants/lora_relay_v2/platformio.ini b/variants/lora_relay_v2/platformio.ini index 93756c6dd..1be8ced1f 100644 --- a/variants/lora_relay_v2/platformio.ini +++ b/variants/lora_relay_v2/platformio.ini @@ -2,6 +2,7 @@ [env:lora-relay-v2] extends = nrf52840_base board = lora-relay-v2 +board_level = extra # add our variants files to the include and src paths # define build flags for the TFT_eSPI library build_flags = ${nrf52840_base.build_flags} -Ivariants/lora_relay_v2 diff --git a/variants/m5stack_core/platformio.ini b/variants/m5stack_core/platformio.ini index f84e04785..a2330922e 100644 --- a/variants/m5stack_core/platformio.ini +++ b/variants/m5stack_core/platformio.ini @@ -1,6 +1,7 @@ [env:m5stack-core] extends = esp32_base board = m5stack-core-esp32 +board_level = extra upload_port = COM8 monitor_port = COM8 monitor_filters = esp32_exception_decoder diff --git a/variants/m5stack_coreink/platformio.ini b/variants/m5stack_coreink/platformio.ini index 06f970dba..1a7926d7e 100644 --- a/variants/m5stack_coreink/platformio.ini +++ b/variants/m5stack_coreink/platformio.ini @@ -1,6 +1,7 @@ [env:m5stack-coreink] extends = esp32_base board = m5stack-coreink +board_level = extra build_src_filter = ${esp32_base.build_src_filter} build_flags = diff --git a/variants/pca10056-rc-clock/platformio.ini b/variants/pca10056-rc-clock/platformio.ini index 0dd317816..d965753d3 100644 --- a/variants/pca10056-rc-clock/platformio.ini +++ b/variants/pca10056-rc-clock/platformio.ini @@ -1,5 +1,6 @@ ; The NRF52840-dk development board, but @geeksville's board - which has a busted oscilliator [env:nrf52840dk-geeksville] +board_level = extra extends = nrf52840_base board = nrf52840_dk_modified # add our variants files to the include and src paths diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index 5bbde2adf..99e9667b6 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -2,6 +2,7 @@ extends = portduino_base build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino board = cross_platform +board_level = extra lib_deps = ${portduino_base.lib_deps} build_src_filter = ${portduino_base.build_src_filter} @@ -10,6 +11,7 @@ build_src_filter = ${portduino_base.build_src_filter} extends = portduino_base build_flags = ${portduino_base.build_flags} -O0 -lgpiod -I variants/portduino board = linux_hardware +board_level = extra lib_deps = ${portduino_base.lib_deps} build_src_filter = ${portduino_base.build_src_filter} @@ -18,5 +20,6 @@ build_src_filter = ${portduino_base.build_src_filter} extends = portduino_base build_flags = ${portduino_base.build_flags} -O0 -lgpiod -I variants/portduino board = linux_arm +board_level = extra lib_deps = ${portduino_base.lib_deps} build_src_filter = ${portduino_base.build_src_filter} diff --git a/variants/ppr/platformio.ini b/variants/ppr/platformio.ini index cb7b21de4..22273ce8e 100644 --- a/variants/ppr/platformio.ini +++ b/variants/ppr/platformio.ini @@ -2,6 +2,7 @@ [env:ppr] extends = nrf52_base board = ppr +board_level = extra lib_deps = ${arduino_base.lib_deps} industruino/UC1701@^1.1.0 \ No newline at end of file diff --git a/variants/ppr1/platformio.ini b/variants/ppr1/platformio.ini index 40ad508f9..f6c2a5e0b 100644 --- a/variants/ppr1/platformio.ini +++ b/variants/ppr1/platformio.ini @@ -2,6 +2,7 @@ [env:ppr1] extends = nrf52_base board = ppr1 +board_level = extra build_flags = ${nrf52_base.build_flags} -Ivariants/ppr1 build_src_filter = ${nrf52_base.build_src_filter} +<../variants/ppr1> lib_deps = diff --git a/variants/rak11200/platformio.ini b/variants/rak11200/platformio.ini index 602f5a246..f653adeb2 100644 --- a/variants/rak11200/platformio.ini +++ b/variants/rak11200/platformio.ini @@ -1,5 +1,6 @@ [env:rak11200] extends = esp32_base +board_level = extra board = wiscore_rak11200 build_flags = ${esp32_base.build_flags} -D RAK_11200 -I variants/rak11200 diff --git a/variants/rpipico/platformio.ini b/variants/rpipico/platformio.ini index 122fbd42f..a169e8a9d 100644 --- a/variants/rpipico/platformio.ini +++ b/variants/rpipico/platformio.ini @@ -1,6 +1,7 @@ [env:pico] extends = rp2040_base board = rpipico +board_level = extra upload_protocol = picotool # add our variants files to the include and src paths diff --git a/variants/rpipicow/platformio.ini b/variants/rpipicow/platformio.ini index 697ec1caa..6e5c32a52 100644 --- a/variants/rpipicow/platformio.ini +++ b/variants/rpipicow/platformio.ini @@ -1,6 +1,7 @@ [env:picow] extends = rp2040_base board = rpipicow +board_level = extra upload_protocol = picotool # add our variants files to the include and src paths diff --git a/variants/tbeam_v07/platformio.ini b/variants/tbeam_v07/platformio.ini index b63184137..22258b64c 100644 --- a/variants/tbeam_v07/platformio.ini +++ b/variants/tbeam_v07/platformio.ini @@ -2,5 +2,6 @@ [env:tbeam0.7] extends = esp32_base board = ttgo-t-beam +board_level = extra build_flags = ${esp32_base.build_flags} -D TBEAM_V07 -I variants/tbeam_v07 \ No newline at end of file diff --git a/variants/tlora_v1_3/platformio.ini b/variants/tlora_v1_3/platformio.ini index 9d9f41a7c..739f76268 100644 --- a/variants/tlora_v1_3/platformio.ini +++ b/variants/tlora_v1_3/platformio.ini @@ -1,5 +1,6 @@ [env:tlora_v1_3] extends = esp32_base +board_level = extra board = ttgo-lora32-v1 build_flags = ${esp32_base.build_flags} -D TLORA_V1_3 -I variants/tlora_v1_3 \ No newline at end of file diff --git a/variants/tlora_v2/platformio.ini b/variants/tlora_v2/platformio.ini index 8710068af..25ae3a360 100644 --- a/variants/tlora_v2/platformio.ini +++ b/variants/tlora_v2/platformio.ini @@ -1,5 +1,6 @@ [env:tlora-v2] extends = esp32_base board = ttgo-lora32-v1 +board_level = extra build_flags = ${esp32_base.build_flags} -D TLORA_V2 -I variants/tlora_v2 \ No newline at end of file diff --git a/variants/wio-e5/platformio.ini b/variants/wio-e5/platformio.ini index 0050d4118..32436dae8 100644 --- a/variants/wio-e5/platformio.ini +++ b/variants/wio-e5/platformio.ini @@ -1,4 +1,5 @@ [env:wio-e5] extends = stm32wl5e_base +board_level = extra build_flags = ${stm32wl5e_base.build_flags} -Ivariants/wio-e5 -DHAL_DAC_MODULE_ONLY -DSERIAL_UART_INSTANCE=1 -DPIN_SERIAL_RX=PB7 -DPIN_SERIAL_TX=PB6 From 7100416142e063af585cefd3594124a13fd4e96f Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 9 Feb 2023 19:32:32 -0600 Subject: [PATCH 02/25] Add short_name --- protobufs | 2 +- src/mesh/generated/meshtastic/admin.pb.h | 12 ++++++++---- src/modules/AdminModule.cpp | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/protobufs b/protobufs index 400dc2358..1d0b4dd24 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 400dc2358942f1954b188cb5698a545850ca3d73 +Subproject commit 1d0b4dd242ae38b844510d4517cfdceeed294cce diff --git a/src/mesh/generated/meshtastic/admin.pb.h b/src/mesh/generated/meshtastic/admin.pb.h index 25bc77241..5995d70f7 100644 --- a/src/mesh/generated/meshtastic/admin.pb.h +++ b/src/mesh/generated/meshtastic/admin.pb.h @@ -67,6 +67,8 @@ typedef struct _meshtastic_HamParameters { Please respect your local laws, regulations, and band plans. Ensure your radio is capable of operating of the selected frequency before setting this. */ float frequency; + /* Optional short name of user */ + char short_name[6]; } meshtastic_HamParameters; /* This message is handled by the Admin module and is responsible for all settings/channel read/write operations. @@ -169,14 +171,15 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_AdminMessage_init_default {0, {0}} -#define meshtastic_HamParameters_init_default {"", 0, 0} +#define meshtastic_HamParameters_init_default {"", 0, 0, ""} #define meshtastic_AdminMessage_init_zero {0, {0}} -#define meshtastic_HamParameters_init_zero {"", 0, 0} +#define meshtastic_HamParameters_init_zero {"", 0, 0, ""} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_HamParameters_call_sign_tag 1 #define meshtastic_HamParameters_tx_power_tag 2 #define meshtastic_HamParameters_frequency_tag 3 +#define meshtastic_HamParameters_short_name_tag 4 #define meshtastic_AdminMessage_get_channel_request_tag 1 #define meshtastic_AdminMessage_get_channel_response_tag 2 #define meshtastic_AdminMessage_get_owner_request_tag 3 @@ -259,7 +262,8 @@ X(a, STATIC, ONEOF, INT32, (payload_variant,nodedb_reset,nodedb_reset), #define meshtastic_HamParameters_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, STRING, call_sign, 1) \ X(a, STATIC, SINGULAR, INT32, tx_power, 2) \ -X(a, STATIC, SINGULAR, FLOAT, frequency, 3) +X(a, STATIC, SINGULAR, FLOAT, frequency, 3) \ +X(a, STATIC, SINGULAR, STRING, short_name, 4) #define meshtastic_HamParameters_CALLBACK NULL #define meshtastic_HamParameters_DEFAULT NULL @@ -272,7 +276,7 @@ extern const pb_msgdesc_t meshtastic_HamParameters_msg; /* Maximum encoded size of messages (where known) */ #define meshtastic_AdminMessage_size 234 -#define meshtastic_HamParameters_size 25 +#define meshtastic_HamParameters_size 32 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 82730b9ca..fd1b84bd2 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -603,6 +603,7 @@ void AdminModule::handleSetHamMode(const meshtastic_HamParameters &p) { // Set call sign and override lora limitations for licensed use strncpy(owner.long_name, p.call_sign, sizeof(owner.long_name)); + strncpy(owner.short_name, p.short_name, sizeof(owner.short_name)); owner.is_licensed = true; config.lora.override_duty_cycle = true; config.lora.tx_power = p.tx_power; From fcbeeac28f86a17559b986fd67e43b93dadb9e82 Mon Sep 17 00:00:00 2001 From: thebentern Date: Fri, 10 Feb 2023 13:30:51 +0000 Subject: [PATCH 03/25] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 6443d32c2..bdda0d97b 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 0 -build = 20 +build = 21 From 09f2ea8938184f18bbb638711ec84a4a06044818 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Fri, 10 Feb 2023 07:47:43 -0600 Subject: [PATCH 04/25] Portduino isn't extra. It's extra special --- variants/portduino/platformio.ini | 3 --- 1 file changed, 3 deletions(-) diff --git a/variants/portduino/platformio.ini b/variants/portduino/platformio.ini index 99e9667b6..5bbde2adf 100644 --- a/variants/portduino/platformio.ini +++ b/variants/portduino/platformio.ini @@ -2,7 +2,6 @@ extends = portduino_base build_flags = ${portduino_base.build_flags} -O0 -I variants/portduino board = cross_platform -board_level = extra lib_deps = ${portduino_base.lib_deps} build_src_filter = ${portduino_base.build_src_filter} @@ -11,7 +10,6 @@ build_src_filter = ${portduino_base.build_src_filter} extends = portduino_base build_flags = ${portduino_base.build_flags} -O0 -lgpiod -I variants/portduino board = linux_hardware -board_level = extra lib_deps = ${portduino_base.lib_deps} build_src_filter = ${portduino_base.build_src_filter} @@ -20,6 +18,5 @@ build_src_filter = ${portduino_base.build_src_filter} extends = portduino_base build_flags = ${portduino_base.build_flags} -O0 -lgpiod -I variants/portduino board = linux_arm -board_level = extra lib_deps = ${portduino_base.lib_deps} build_src_filter = ${portduino_base.build_src_filter} From a280d7f7969a6362cdbb2412c551d96b64587223 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 10:00:19 +0100 Subject: [PATCH 05/25] Guard simulator handling with HAS_RADIO flag --- src/main.cpp | 26 +++++++++++++------------- src/mesh/MeshService.cpp | 2 +- src/mesh/MeshService.h | 2 +- src/platform/portduino/architecture.h | 4 ---- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 89148c22b..f2681bc19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -394,6 +394,19 @@ void setup() // radio init MUST BE AFTER service.init, so we have our radio config settings (from nodedb init) +#if !HAS_RADIO && defined(ARCH_PORTDUINO) + if (!rIf) { + rIf = new SimRadio; + if (!rIf->init()) { + LOG_WARN("Failed to find simulated radio\n"); + delete rIf; + rIf = NULL; + } else { + LOG_INFO("Using SIMULATED radio!\n"); + } + } +#endif + #if defined(RF95_IRQ) if (!rIf) { rIf = new RF95Interface(RF95_NSS, RF95_IRQ, RF95_RESET, SPI); @@ -459,19 +472,6 @@ void setup() } #endif -#ifdef ARCH_PORTDUINO - if (!rIf) { - rIf = new SimRadio; - if (!rIf->init()) { - LOG_WARN("Failed to find simulated radio\n"); - delete rIf; - rIf = NULL; - } else { - LOG_INFO("Using SIMULATED radio!\n"); - } - } -#endif - // check if the radio chip matches the selected region if ((config.lora.region == meshtastic_Config_LoRaConfig_RegionCode_LORA_24) && (!rIf->wideLora())) { diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 85a6390c9..a4d4114b6 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -132,7 +132,7 @@ void MeshService::reloadOwner(bool shouldSave) */ void MeshService::handleToRadio(meshtastic_MeshPacket &p) { -#ifdef ARCH_PORTDUINO +#if defined(ARCH_PORTDUINO) && !HAS_RADIO // Simulates device is receiving 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 diff --git a/src/mesh/MeshService.h b/src/mesh/MeshService.h index b8abac80d..4314ea362 100644 --- a/src/mesh/MeshService.h +++ b/src/mesh/MeshService.h @@ -10,7 +10,7 @@ #include "MeshTypes.h" #include "Observer.h" #include "PointerQueue.h" -#ifdef ARCH_PORTDUINO +#if defined(ARCH_PORTDUINO) && !HAS_RADIO #include "../platform/portduino/SimRadio.h" #endif diff --git a/src/platform/portduino/architecture.h b/src/platform/portduino/architecture.h index 54df672d8..c54895703 100644 --- a/src/platform/portduino/architecture.h +++ b/src/platform/portduino/architecture.h @@ -2,10 +2,6 @@ #define ARCH_PORTDUINO -// -// defaults for NRF52 architecture -// - // // set HW_VENDOR // From 680550b76ce5f9b329222dafbdfcf68dd597c793 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 10:08:25 +0100 Subject: [PATCH 06/25] Add HAS_SENSOR flag To separate DeviceTelemetry and EnvironmentTelemetry --- arch/portduino/portduino.ini | 4 +++- src/modules/Modules.cpp | 6 +++++- src/modules/Telemetry/EnvironmentTelemetry.cpp | 2 -- src/platform/esp32/architecture.h | 3 +++ src/platform/nrf52/architecture.h | 3 +++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/portduino/portduino.ini b/arch/portduino/portduino.ini index b6b17d391..100f3538d 100644 --- a/arch/portduino/portduino.ini +++ b/arch/portduino/portduino.ini @@ -12,7 +12,9 @@ build_src_filter = - - - - - + - + - + - +<../variants/portduino> lib_deps = ${env.lib_deps} diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index bc874a9a3..4119cdc77 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -14,9 +14,11 @@ #include "modules/TraceRouteModule.h" #include "modules/WaypointModule.h" #if HAS_TELEMETRY -#include "modules/Telemetry/AirQualityTelemetry.h" #include "modules/Telemetry/DeviceTelemetry.h" +#endif +#if HAS_SENSOR #include "modules/Telemetry/EnvironmentTelemetry.h" +#include "modules/Telemetry/AirQualityTelemetry.h" #endif #ifdef ARCH_ESP32 #include "modules/esp32/AudioModule.h" @@ -63,6 +65,8 @@ void setupModules() #endif #if HAS_TELEMETRY new DeviceTelemetryModule(); +#endif +#if HAS_SENSOR new EnvironmentTelemetryModule(); if (nodeTelemetrySensorsMap[meshtastic_TelemetrySensorType_PMSA003I] > 0) { new AirQualityTelemetryModule(); diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index d9b129e70..bd7ed539a 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -52,7 +52,6 @@ SHT31Sensor sht31Sensor; int32_t EnvironmentTelemetryModule::runOnce() { -#ifndef ARCH_PORTDUINO int32_t result = INT32_MAX; /* Uncomment the preferences below if you want to use the module @@ -115,7 +114,6 @@ int32_t EnvironmentTelemetryModule::runOnce() } } return sendToPhoneIntervalMs; -#endif } bool EnvironmentTelemetryModule::wantUIFrame() diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 09b754d0f..90c016dae 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -27,6 +27,9 @@ #ifndef HAS_TELEMETRY #define HAS_TELEMETRY 1 #endif +#ifndef HAS_SENSOR +#define HAS_SENSOR 1 +#endif #ifndef HAS_RADIO #define HAS_RADIO 1 #endif diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index 383a0da4e..f21635560 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -23,6 +23,9 @@ #ifndef HAS_TELEMETRY #define HAS_TELEMETRY 1 #endif +#ifndef HAS_SENSOR +#define HAS_SENSOR 1 +#endif #ifndef HAS_RADIO #define HAS_RADIO 1 #endif From 03f584a5ab9cfceaf9826b7ba851ac24cb34d4ad Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 10:09:48 +0100 Subject: [PATCH 07/25] Add HAS_TELEMETRY to portduino --- src/platform/portduino/architecture.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/platform/portduino/architecture.h b/src/platform/portduino/architecture.h index c54895703..9408ad19c 100644 --- a/src/platform/portduino/architecture.h +++ b/src/platform/portduino/architecture.h @@ -8,5 +8,12 @@ #define HW_VENDOR meshtastic_HardwareModel_PORTDUINO -#define HAS_RTC 1 +#ifndef HAS_WIFI #define HAS_WIFI 1 +#endif +#ifndef HAS_RTC +#define HAS_RTC 1 +#endif +#ifndef HAS_TELEMETRY +#define HAS_TELEMETRY 1 +#endif From 97c1cf628aaed69400b30e9f99572a300bf3d163 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 10:34:08 +0100 Subject: [PATCH 08/25] SimRadio in separate thread To use notifyLater when transmitting, fixes packetPool issues --- src/platform/portduino/SimRadio.cpp | 23 +++++++++-------------- src/platform/portduino/SimRadio.h | 3 ++- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/platform/portduino/SimRadio.cpp b/src/platform/portduino/SimRadio.cpp index fa4212669..f71113ab4 100644 --- a/src/platform/portduino/SimRadio.cpp +++ b/src/platform/portduino/SimRadio.cpp @@ -2,7 +2,7 @@ #include "MeshService.h" #include "Router.h" -SimRadio::SimRadio() +SimRadio::SimRadio() : NotifiedWorkerThread("SimRadio") { instance = this; } @@ -53,10 +53,7 @@ void SimRadio::startTransmitTimer(bool withDelay) if (!txQueue.empty()) { uint32_t delayMsec = !withDelay ? 1 : getTxDelayMsec(); // LOG_DEBUG("xmit timer %d\n", delay); - delay(delayMsec); - onNotify(TRANSMIT_DELAY_COMPLETED); - } else { - LOG_DEBUG("TX QUEUE EMPTY!\n"); + notifyLater(delayMsec, TRANSMIT_DELAY_COMPLETED, false); } } @@ -66,8 +63,7 @@ void SimRadio::startTransmitTimerSNR(float snr) if (!txQueue.empty()) { uint32_t delayMsec = getTxDelayMsecWeighted(snr); // LOG_DEBUG("xmit timer %d\n", delay); - delay(delayMsec); - onNotify(TRANSMIT_DELAY_COMPLETED); + notifyLater(delayMsec, TRANSMIT_DELAY_COMPLETED, false); } } @@ -142,11 +138,12 @@ void SimRadio::onNotify(uint32_t notification) switch (notification) { case ISR_TX: handleTransmitInterrupt(); - LOG_DEBUG("tx complete - starting timer\n"); + // LOG_DEBUG("tx complete - starting timer\n"); startTransmitTimer(); break; case ISR_RX: - LOG_DEBUG("rx complete - starting timer\n"); + // LOG_DEBUG("rx complete - starting timer\n"); + startTransmitTimer(); break; case TRANSMIT_DELAY_COMPLETED: LOG_DEBUG("delay done\n"); @@ -170,8 +167,7 @@ void SimRadio::onNotify(uint32_t notification) uint32_t xmitMsec = getPacketTime(txp); airTime->logAirtime(TX_LOG, xmitMsec); - delay(xmitMsec); // Model the time it is busy sending - completeSending(); + notifyLater(xmitMsec, ISR_TX, false); // Model the time it is busy sending } } } else { @@ -242,8 +238,7 @@ void SimRadio::handleReceiveInterrupt(meshtastic_MeshPacket *p) xmitMsec = getPacketTime(length); // LOG_DEBUG("Payload size %d vs length (includes header) %d\n", p->decoded.payload.size, length); - meshtastic_MeshPacket *mp = packetPool.allocCopy(*p); // keep a copy in packtPool - mp->which_payload_variant = meshtastic_MeshPacket_decoded_tag; // Mark that the payload is already decoded + meshtastic_MeshPacket *mp = packetPool.allocCopy(*p); // keep a copy in packetPool printPacket("Lora RX", mp); @@ -268,4 +263,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 b78beb70a..1edb4963b 100644 --- a/src/platform/portduino/SimRadio.h +++ b/src/platform/portduino/SimRadio.h @@ -3,10 +3,11 @@ #include "MeshPacketQueue.h" #include "RadioInterface.h" #include "api/WiFiServerAPI.h" +#include "concurrency/NotifiedWorkerThread.h" #include -class SimRadio : public RadioInterface +class SimRadio : public RadioInterface, protected concurrency::NotifiedWorkerThread { enum PendingISR { ISR_NONE = 0, ISR_RX, ISR_TX, TRANSMIT_DELAY_COMPLETED }; From 7063acdda6fea4a9f5874082ed88d559d00a8c21 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 11:32:10 +0100 Subject: [PATCH 09/25] Ignore syslog on portduino Breaks when running since mesh/http is not compiled --- src/RedirectablePrint.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp index 04dbcdd49..39ea76c00 100644 --- a/src/RedirectablePrint.cpp +++ b/src/RedirectablePrint.cpp @@ -103,7 +103,7 @@ size_t RedirectablePrint::log(const char *logLevel, const char *format, ...) } r += vprintf(format, arg); -#if HAS_WIFI || HAS_ETHERNET +#if (HAS_WIFI || HAS_ETHERNET) && !defined(ARCH_PORTDUINO) // if syslog is in use, collect the log messages and send them to syslog if (syslog.isEnabled()) { int ll = 0; From abf3a5840b179c9f741a3cbe014f34dcb47ca8fe Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 11:46:54 +0100 Subject: [PATCH 10/25] trunk fmt --- src/modules/Modules.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 4119cdc77..3247d02c1 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -17,8 +17,8 @@ #include "modules/Telemetry/DeviceTelemetry.h" #endif #if HAS_SENSOR -#include "modules/Telemetry/EnvironmentTelemetry.h" #include "modules/Telemetry/AirQualityTelemetry.h" +#include "modules/Telemetry/EnvironmentTelemetry.h" #endif #ifdef ARCH_ESP32 #include "modules/esp32/AudioModule.h" From 406187084155f715cc591d58e96cc663aab45d07 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 12:04:53 +0100 Subject: [PATCH 11/25] Don't need a Portduino guard clause here as it will not be compiled --- src/modules/Telemetry/AirQualityTelemetry.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/modules/Telemetry/AirQualityTelemetry.cpp b/src/modules/Telemetry/AirQualityTelemetry.cpp index 2b744c489..966e2d0ff 100644 --- a/src/modules/Telemetry/AirQualityTelemetry.cpp +++ b/src/modules/Telemetry/AirQualityTelemetry.cpp @@ -10,7 +10,6 @@ int32_t AirQualityTelemetryModule::runOnce() { -#ifndef ARCH_PORTDUINO int32_t result = INT32_MAX; /* Uncomment the preferences below if you want to use the module @@ -55,7 +54,6 @@ int32_t AirQualityTelemetryModule::runOnce() } } return sendToPhoneIntervalMs; -#endif } bool AirQualityTelemetryModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Telemetry *t) From 5cadcd355f540928f55336ce43c490d1290c6935 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 13:56:52 +0100 Subject: [PATCH 12/25] Send DeviceTelemetry only after NodeInfo is sent --- src/modules/Telemetry/DeviceTelemetry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/Telemetry/DeviceTelemetry.h b/src/modules/Telemetry/DeviceTelemetry.h index ba16e095a..bd2a69da5 100644 --- a/src/modules/Telemetry/DeviceTelemetry.h +++ b/src/modules/Telemetry/DeviceTelemetry.h @@ -12,7 +12,7 @@ class DeviceTelemetryModule : private concurrency::OSThread, public ProtobufModu : concurrency::OSThread("DeviceTelemetryModule"), ProtobufModule("DeviceTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg) { - setIntervalFromNow(10 * 1000); + setIntervalFromNow(45 * 1000); // Wait until NodeInfo is sent } virtual bool wantUIFrame() { return false; } From 5f28ef68146464dae05ec41cbade8d8eb1c2fea8 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 13:57:51 +0100 Subject: [PATCH 13/25] When hearing a node we don't know, send NodeInfo and ask for response --- src/mesh/MeshService.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index a4d4114b6..85dbc039b 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -75,9 +75,13 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp) { powerFSM.trigger(EVENT_PACKET_FOR_PHONE); // Possibly keep the node from sleeping - printPacket("Forwarding to phone", mp); nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio + if (!nodeDB.getNode(mp->from)->has_user) { + LOG_INFO("Heard a node we don't know, sending NodeInfo and asking for a response.\n"); + nodeInfoModule->sendOurNodeInfo(mp->from, true); + } + printPacket("Forwarding to phone", mp); sendToPhone((meshtastic_MeshPacket *)mp); return 0; From 2d2633d4cff5faaa3c3dcb4485d2f19711a4b2cf Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 13:58:12 +0100 Subject: [PATCH 14/25] Increase default NodeInfo broadcast to 3 hours --- src/mesh/NodeDB.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index a6fbd9cb0..9971bd462 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -194,7 +194,7 @@ extern NodeDB nodeDB; #define default_gps_attempt_time IF_ROUTER(5 * 60, 15 * 60) #define default_gps_update_interval IF_ROUTER(ONE_DAY, 2 * 60) -#define default_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 15 * 60) +#define default_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 3 * 60 * 60) #define default_wait_bluetooth_secs IF_ROUTER(1, 60) #define default_mesh_sds_timeout_secs IF_ROUTER(NODE_DELAY_FOREVER, 2 * 60 * 60) #define default_sds_secs IF_ROUTER(ONE_DAY, UINT32_MAX) // Default to forever super deep sleep From 16852da8d477b7301fd9a6604a94992c583d1bea Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 14:26:01 +0100 Subject: [PATCH 15/25] Set node_info_broadcast_secs to 3 hours instead of default_broadcast_interval --- src/mesh/NodeDB.cpp | 1 + src/mesh/NodeDB.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 89063f550..f8cdaf547 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -170,6 +170,7 @@ void NodeDB::installDefaultConfig() config.lora.hop_limit = HOP_RELIABLE; config.position.gps_enabled = true; config.position.position_broadcast_smart_enabled = true; + config.device.node_info_broadcast_secs = 3 * 60 * 60; config.device.serial_enabled = true; resetRadioConfig(); strncpy(config.network.ntp_server, "0.pool.ntp.org", 32); diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 9971bd462..a6fbd9cb0 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -194,7 +194,7 @@ extern NodeDB nodeDB; #define default_gps_attempt_time IF_ROUTER(5 * 60, 15 * 60) #define default_gps_update_interval IF_ROUTER(ONE_DAY, 2 * 60) -#define default_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 3 * 60 * 60) +#define default_broadcast_interval_secs IF_ROUTER(ONE_DAY / 2, 15 * 60) #define default_wait_bluetooth_secs IF_ROUTER(1, 60) #define default_mesh_sds_timeout_secs IF_ROUTER(NODE_DELAY_FOREVER, 2 * 60 * 60) #define default_sds_secs IF_ROUTER(ONE_DAY, UINT32_MAX) // Default to forever super deep sleep From c834252f1cd5646721ad9b08894f6247c9b8810d Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 17:16:48 +0100 Subject: [PATCH 16/25] Check if nodeInfoModule exists (e.g. for Repeater) --- src/mesh/MeshService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 85dbc039b..80fea011b 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -76,7 +76,7 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp) powerFSM.trigger(EVENT_PACKET_FOR_PHONE); // Possibly keep the node from sleeping nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio - if (!nodeDB.getNode(mp->from)->has_user) { + if (!nodeDB.getNode(mp->from)->has_user && nodeInfoModule) { LOG_INFO("Heard a node we don't know, sending NodeInfo and asking for a response.\n"); nodeInfoModule->sendOurNodeInfo(mp->from, true); } From 5ca3d9169a1d0c2767d9311d2d2bb7dba14de18f Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sat, 11 Feb 2023 17:17:11 +0100 Subject: [PATCH 17/25] Only set node_info_broadcast_secs when not a Router --- src/mesh/NodeDB.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index f8cdaf547..5c28f5261 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -170,7 +170,8 @@ void NodeDB::installDefaultConfig() config.lora.hop_limit = HOP_RELIABLE; config.position.gps_enabled = true; config.position.position_broadcast_smart_enabled = true; - config.device.node_info_broadcast_secs = 3 * 60 * 60; + if (config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER) + config.device.node_info_broadcast_secs = 3 * 60 * 60; config.device.serial_enabled = true; resetRadioConfig(); strncpy(config.network.ntp_server, "0.pool.ntp.org", 32); From b7895f70386563e8c67e951dd86e4c5838ec7464 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Wed, 15 Feb 2023 19:31:09 +0100 Subject: [PATCH 18/25] Sanity check for sending NodeInfo Don't send it if we've done so less than 1 min. ago --- src/mesh/MeshModule.cpp | 10 +++++++--- src/mesh/MeshModule.h | 3 +++ src/modules/NodeInfoModule.cpp | 28 ++++++++++++++++++++-------- src/modules/NodeInfoModule.h | 3 +++ 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/mesh/MeshModule.cpp b/src/mesh/MeshModule.cpp index cc54e78c2..d8dbf8a3a 100644 --- a/src/mesh/MeshModule.cpp +++ b/src/mesh/MeshModule.cpp @@ -77,6 +77,8 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src) currentReply = NULL; // No reply yet + bool ignoreRequest = false; // No module asked to ignore the request yet + // Was this message directed to us specifically? Will be false if we are sniffing someone elses packets auto ourNodeNum = nodeDB.getNodeNum(); bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum; @@ -135,7 +137,8 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src) // any other node. if (mp.decoded.want_response && toUs && (getFrom(&mp) != ourNodeNum || mp.to == ourNodeNum) && !currentReply) { pi.sendResponse(mp); - LOG_INFO("Module '%s' sent a response\n", pi.name); + ignoreRequest = ignoreRequest || pi.ignoreRequest; // If at least one module asks it, we may ignore a request + LOG_INFO("Asked module '%s' to send a response\n", pi.name); } else { LOG_DEBUG("Module '%s' considered\n", pi.name); } @@ -162,8 +165,9 @@ void MeshModule::callPlugins(const meshtastic_MeshPacket &mp, RxSource src) printPacket("Sending response", currentReply); service.sendToMesh(currentReply); currentReply = NULL; - } else if (mp.from != ourNodeNum) { - // Note: if the message started with the local node we don't want to send a no response reply + } else if (mp.from != ourNodeNum && !ignoreRequest) { + // Note: if the message started with the local node or a module asked to ignore the request, we don't want to send a + // no response reply // No one wanted to reply to this requst, tell the requster that happened LOG_DEBUG("No one responded, send a nak\n"); diff --git a/src/mesh/MeshModule.h b/src/mesh/MeshModule.h index c6550f3d9..2eee04f5d 100644 --- a/src/mesh/MeshModule.h +++ b/src/mesh/MeshModule.h @@ -94,6 +94,9 @@ class MeshModule * flag */ bool encryptedOk = false; + /* We allow modules to ignore a request without sending an error if they have a specific reason for it. */ + bool ignoreRequest = false; + /** If a bound channel name is set, we will only accept received packets that come in on that channel. * A special exception (FIXME, not sure if this is a good idea) - packets that arrive on the local interface * are allowed on any channel (this lets the local user do anything). diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp index 15661e837..004ad75f0 100644 --- a/src/modules/NodeInfoModule.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -34,20 +34,32 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies) service.cancelSending(prevPacketId); meshtastic_MeshPacket *p = allocReply(); - p->to = dest; - p->decoded.want_response = wantReplies; - p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; - prevPacketId = p->id; + if (p) { // Check whether we didn't ignore it + p->to = dest; + p->decoded.want_response = wantReplies; + p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; + prevPacketId = p->id; - service.sendToMesh(p); + service.sendToMesh(p); + } } meshtastic_MeshPacket *NodeInfoModule::allocReply() { - meshtastic_User &u = owner; + uint32_t now = millis(); + // If we sent our NodeInfo less than 1 min. ago, don't send it again as it may be still underway. + if (lastSentToMesh && (now - lastSentToMesh) < 60 * 1000) { + LOG_DEBUG("Sending NodeInfo will be ignored since we just sent it.\n"); + ignoreRequest = true; // Mark it as ignored for MeshModule + return NULL; + } else { + ignoreRequest = false; // Don't ignore requests anymore + meshtastic_User &u = owner; - LOG_INFO("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name); - return allocDataProtobuf(u); + LOG_INFO("sending owner %s/%s/%s\n", u.id, u.long_name, u.short_name); + lastSentToMesh = now; + return allocDataProtobuf(u); + } } NodeInfoModule::NodeInfoModule() diff --git a/src/modules/NodeInfoModule.h b/src/modules/NodeInfoModule.h index 4645b06b4..900d5983d 100644 --- a/src/modules/NodeInfoModule.h +++ b/src/modules/NodeInfoModule.h @@ -35,6 +35,9 @@ class NodeInfoModule : public ProtobufModule, private concurren /** Does our periodic broadcast */ virtual int32_t runOnce() override; + + private: + uint32_t lastSentToMesh = 0; // Last time we sent our NodeInfo to the mesh }; extern NodeInfoModule *nodeInfoModule; From 3ae1fdf66152a1f720ba5b401442f54abec3765b Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Feb 2023 10:21:03 -0600 Subject: [PATCH 19/25] Add metadata to phone api want config messages --- protobufs | 2 +- src/mesh/NodeDB.cpp | 1 - src/mesh/NodeDB.h | 16 +++ src/mesh/PhoneAPI.cpp | 8 +- src/mesh/PhoneAPI.h | 1 + src/mesh/generated/meshtastic/admin.pb.h | 1 - src/mesh/generated/meshtastic/mesh.pb.c | 3 + src/mesh/generated/meshtastic/mesh.pb.h | 139 ++++++++++++++++------- src/modules/AdminModule.cpp | 14 +-- 9 files changed, 127 insertions(+), 58 deletions(-) diff --git a/protobufs b/protobufs index 1d0b4dd24..ff26da703 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 1d0b4dd242ae38b844510d4517cfdceeed294cce +Subproject commit ff26da70385fc067af3c0d2950e97f90d632f142 diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 5c28f5261..e03f9bb17 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -11,7 +11,6 @@ #include "RTC.h" #include "Router.h" #include "error.h" -#include "main.h" #include "mesh-pb-constants.h" #include #include diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index a6fbd9cb0..7d95062a2 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -1,6 +1,7 @@ #pragma once #include "Observer.h" +#include "main.h" #include #include @@ -229,3 +230,18 @@ extern uint32_t radioGeneration; (ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \ ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \ ModuleConfig_TelemetryConfig_size + ModuleConfig_size) + +inline meshtastic_DeviceMetadata getDeviceMetadata() +{ + meshtastic_DeviceMetadata deviceMetadata; + strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18); + deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; + deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN; + deviceMetadata.hasBluetooth = HAS_BLUETOOTH; + deviceMetadata.hasWifi = HAS_WIFI; + deviceMetadata.hasEthernet = HAS_ETHERNET; + deviceMetadata.role = config.device.role; + deviceMetadata.position_flags = config.position.position_flags; + deviceMetadata.hw_model = HW_VENDOR; + return deviceMetadata; +} \ No newline at end of file diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 0c430ea5c..c91863bdc 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -277,11 +277,15 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) config_state++; // Advance when we have sent all of our ModuleConfig objects if (config_state > (_meshtastic_AdminMessage_ModuleConfigType_MAX + 1)) { - state = STATE_SEND_COMPLETE_ID; + state = STATE_SEND_METADATA; config_state = 0; } break; - + case STATE_SEND_METADATA: + fromRadioScratch.which_payload_variant = meshtastic_FromRadio_metadata_tag; + fromRadioScratch.metadata = getDeviceMetadata(); + state = STATE_SEND_COMPLETE_ID; + break; case STATE_SEND_COMPLETE_ID: LOG_INFO("getFromRadio=STATE_SEND_COMPLETE_ID\n"); fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_complete_id_tag; diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index 5a73f5874..cc219b690 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -27,6 +27,7 @@ class PhoneAPI STATE_SEND_CONFIG, // Replacement for the old Radioconfig STATE_SEND_MODULECONFIG, // Send Module specific config STATE_SEND_COMPLETE_ID, + STATE_SEND_METADATA, STATE_SEND_PACKETS // send packets or debug strings }; diff --git a/src/mesh/generated/meshtastic/admin.pb.h b/src/mesh/generated/meshtastic/admin.pb.h index 5995d70f7..a9c415992 100644 --- a/src/mesh/generated/meshtastic/admin.pb.h +++ b/src/mesh/generated/meshtastic/admin.pb.h @@ -6,7 +6,6 @@ #include #include "meshtastic/channel.pb.h" #include "meshtastic/config.pb.h" -#include "meshtastic/device_metadata.pb.h" #include "meshtastic/mesh.pb.h" #include "meshtastic/module_config.pb.h" #include "meshtastic/connection_status.pb.h" diff --git a/src/mesh/generated/meshtastic/mesh.pb.c b/src/mesh/generated/meshtastic/mesh.pb.c index 977e3916f..0c3c155f6 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.c +++ b/src/mesh/generated/meshtastic/mesh.pb.c @@ -48,6 +48,9 @@ PB_BIND(meshtastic_ToRadio, meshtastic_ToRadio, 2) PB_BIND(meshtastic_Compressed, meshtastic_Compressed, AUTO) +PB_BIND(meshtastic_DeviceMetadata, meshtastic_DeviceMetadata, AUTO) + + diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 0a8cf5cfe..f22294a2e 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -87,6 +87,8 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_HELTEC_WSL_V3 = 44, /* New BETAFPV ELRS Micro TX Module 2.4G with ESP32 CPU */ meshtastic_HardwareModel_BETAFPV_2400_TX = 45, + /* BetaFPV ExpressLRS "Nano" TX Module 900MHz with ESP32 CPU */ + meshtastic_HardwareModel_BETAFPV_900_NANO_TX = 46, /* 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. */ meshtastic_HardwareModel_PRIVATE_HW = 255 } meshtastic_HardwareModel; @@ -637,6 +639,61 @@ typedef struct _meshtastic_QueueStatus { uint32_t mesh_packet_id; } meshtastic_QueueStatus; +/* Packets/commands to the radio will be written (reliably) to the toRadio characteristic. + Once the write completes the phone can assume it is handled. */ +typedef struct _meshtastic_ToRadio { + pb_size_t which_payload_variant; + union { + /* Send this packet on the mesh */ + meshtastic_MeshPacket packet; + /* Phone wants radio to send full node db to the phone, This is + typically the first packet sent to the radio when the phone gets a + bluetooth connection. The radio will respond by sending back a + MyNodeInfo, a owner, a radio config and a series of + FromRadio.node_infos, and config_complete + the integer you write into this field will be reported back in the + config_complete_id response this allows clients to never be confused by + a stale old partially sent config. */ + uint32_t want_config_id; + /* Tell API server we are disconnecting now. + This is useful for serial links where there is no hardware/protocol based notification that the client has dropped the link. + (Sending this message is optional for clients) */ + bool disconnect; + meshtastic_XModem xmodemPacket; + }; +} meshtastic_ToRadio; + +typedef PB_BYTES_ARRAY_T(237) meshtastic_Compressed_data_t; +/* Compressed message payload */ +typedef struct _meshtastic_Compressed { + /* PortNum to determine the how to handle the compressed payload. */ + meshtastic_PortNum portnum; + /* Compressed data. */ + meshtastic_Compressed_data_t data; +} meshtastic_Compressed; + +/* Device metadata response */ +typedef struct _meshtastic_DeviceMetadata { + /* Device firmware version string */ + char firmware_version[18]; + /* Device state version */ + uint32_t device_state_version; + /* Indicates whether the device can shutdown CPU natively or via power management chip */ + bool canShutdown; + /* Indicates that the device has native wifi capability */ + bool hasWifi; + /* Indicates that the device has native bluetooth capability */ + bool hasBluetooth; + /* Indicates that the device has an ethernet peripheral */ + bool hasEthernet; + /* Indicates that the device's role in the mesh */ + meshtastic_Config_DeviceConfig_Role role; + /* Indicates the device's current enabled position flags */ + uint32_t position_flags; + /* Device hardware model */ + meshtastic_HardwareModel hw_model; +} meshtastic_DeviceMetadata; + /* Packets from the radio to the phone will appear on the fromRadio characteristic. It will support READ and NOTIFY. When a new packet arrives the device will BLE notify? It will sit in that descriptor until consumed by the phone, @@ -677,42 +734,11 @@ typedef struct _meshtastic_FromRadio { meshtastic_QueueStatus queueStatus; /* File Transfer Chunk */ meshtastic_XModem xmodemPacket; + /* Device metadata message */ + meshtastic_DeviceMetadata metadata; }; } meshtastic_FromRadio; -/* Packets/commands to the radio will be written (reliably) to the toRadio characteristic. - Once the write completes the phone can assume it is handled. */ -typedef struct _meshtastic_ToRadio { - pb_size_t which_payload_variant; - union { - /* Send this packet on the mesh */ - meshtastic_MeshPacket packet; - /* Phone wants radio to send full node db to the phone, This is - typically the first packet sent to the radio when the phone gets a - bluetooth connection. The radio will respond by sending back a - MyNodeInfo, a owner, a radio config and a series of - FromRadio.node_infos, and config_complete - the integer you write into this field will be reported back in the - config_complete_id response this allows clients to never be confused by - a stale old partially sent config. */ - uint32_t want_config_id; - /* Tell API server we are disconnecting now. - This is useful for serial links where there is no hardware/protocol based notification that the client has dropped the link. - (Sending this message is optional for clients) */ - bool disconnect; - meshtastic_XModem xmodemPacket; - }; -} meshtastic_ToRadio; - -typedef PB_BYTES_ARRAY_T(237) meshtastic_Compressed_data_t; -/* Compressed message payload */ -typedef struct _meshtastic_Compressed { - /* PortNum to determine the how to handle the compressed payload. */ - meshtastic_PortNum portnum; - /* Compressed data. */ - meshtastic_Compressed_data_t data; -} meshtastic_Compressed; - #ifdef __cplusplus extern "C" { @@ -779,6 +805,9 @@ extern "C" { #define meshtastic_Compressed_portnum_ENUMTYPE meshtastic_PortNum +#define meshtastic_DeviceMetadata_role_ENUMTYPE meshtastic_Config_DeviceConfig_Role +#define meshtastic_DeviceMetadata_hw_model_ENUMTYPE meshtastic_HardwareModel + /* Initializer values for message structs */ #define meshtastic_Position_init_default {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} @@ -795,6 +824,7 @@ extern "C" { #define meshtastic_FromRadio_init_default {0, 0, {meshtastic_MeshPacket_init_default}} #define meshtastic_ToRadio_init_default {0, {meshtastic_MeshPacket_init_default}} #define meshtastic_Compressed_init_default {_meshtastic_PortNum_MIN, {0, {0}}} +#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN} #define meshtastic_Position_init_zero {0, 0, 0, 0, _meshtastic_Position_LocSource_MIN, _meshtastic_Position_AltSource_MIN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_User_init_zero {"", "", "", {0}, _meshtastic_HardwareModel_MIN, 0} #define meshtastic_RouteDiscovery_init_zero {0, {0, 0, 0, 0, 0, 0, 0, 0}} @@ -809,6 +839,7 @@ extern "C" { #define meshtastic_FromRadio_init_zero {0, 0, {meshtastic_MeshPacket_init_zero}} #define meshtastic_ToRadio_init_zero {0, {meshtastic_MeshPacket_init_zero}} #define meshtastic_Compressed_init_zero {_meshtastic_PortNum_MIN, {0, {0}}} +#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN} /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_Position_latitude_i_tag 1 @@ -902,6 +933,21 @@ extern "C" { #define meshtastic_QueueStatus_free_tag 2 #define meshtastic_QueueStatus_maxlen_tag 3 #define meshtastic_QueueStatus_mesh_packet_id_tag 4 +#define meshtastic_ToRadio_packet_tag 1 +#define meshtastic_ToRadio_want_config_id_tag 3 +#define meshtastic_ToRadio_disconnect_tag 4 +#define meshtastic_ToRadio_xmodemPacket_tag 5 +#define meshtastic_Compressed_portnum_tag 1 +#define meshtastic_Compressed_data_tag 2 +#define meshtastic_DeviceMetadata_firmware_version_tag 1 +#define meshtastic_DeviceMetadata_device_state_version_tag 2 +#define meshtastic_DeviceMetadata_canShutdown_tag 3 +#define meshtastic_DeviceMetadata_hasWifi_tag 4 +#define meshtastic_DeviceMetadata_hasBluetooth_tag 5 +#define meshtastic_DeviceMetadata_hasEthernet_tag 6 +#define meshtastic_DeviceMetadata_role_tag 7 +#define meshtastic_DeviceMetadata_position_flags_tag 8 +#define meshtastic_DeviceMetadata_hw_model_tag 9 #define meshtastic_FromRadio_id_tag 1 #define meshtastic_FromRadio_packet_tag 2 #define meshtastic_FromRadio_my_info_tag 3 @@ -914,12 +960,7 @@ extern "C" { #define meshtastic_FromRadio_channel_tag 10 #define meshtastic_FromRadio_queueStatus_tag 11 #define meshtastic_FromRadio_xmodemPacket_tag 12 -#define meshtastic_ToRadio_packet_tag 1 -#define meshtastic_ToRadio_want_config_id_tag 3 -#define meshtastic_ToRadio_disconnect_tag 4 -#define meshtastic_ToRadio_xmodemPacket_tag 5 -#define meshtastic_Compressed_portnum_tag 1 -#define meshtastic_Compressed_data_tag 2 +#define meshtastic_FromRadio_metadata_tag 13 /* Struct field encoding specification for nanopb */ #define meshtastic_Position_FIELDLIST(X, a) \ @@ -1075,7 +1116,8 @@ X(a, STATIC, ONEOF, BOOL, (payload_variant,rebooted,rebooted), 8) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,moduleConfig,moduleConfig), 9) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,channel,channel), 10) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,queueStatus,queueStatus), 11) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket), 12) +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket), 12) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,metadata,metadata), 13) #define meshtastic_FromRadio_CALLBACK NULL #define meshtastic_FromRadio_DEFAULT NULL #define meshtastic_FromRadio_payload_variant_packet_MSGTYPE meshtastic_MeshPacket @@ -1087,6 +1129,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket), #define meshtastic_FromRadio_payload_variant_channel_MSGTYPE meshtastic_Channel #define meshtastic_FromRadio_payload_variant_queueStatus_MSGTYPE meshtastic_QueueStatus #define meshtastic_FromRadio_payload_variant_xmodemPacket_MSGTYPE meshtastic_XModem +#define meshtastic_FromRadio_payload_variant_metadata_MSGTYPE meshtastic_DeviceMetadata #define meshtastic_ToRadio_FIELDLIST(X, a) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,packet,packet), 1) \ @@ -1104,6 +1147,19 @@ X(a, STATIC, SINGULAR, BYTES, data, 2) #define meshtastic_Compressed_CALLBACK NULL #define meshtastic_Compressed_DEFAULT NULL +#define meshtastic_DeviceMetadata_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, STRING, firmware_version, 1) \ +X(a, STATIC, SINGULAR, UINT32, device_state_version, 2) \ +X(a, STATIC, SINGULAR, BOOL, canShutdown, 3) \ +X(a, STATIC, SINGULAR, BOOL, hasWifi, 4) \ +X(a, STATIC, SINGULAR, BOOL, hasBluetooth, 5) \ +X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) \ +X(a, STATIC, SINGULAR, UENUM, role, 7) \ +X(a, STATIC, SINGULAR, UINT32, position_flags, 8) \ +X(a, STATIC, SINGULAR, UENUM, hw_model, 9) +#define meshtastic_DeviceMetadata_CALLBACK NULL +#define meshtastic_DeviceMetadata_DEFAULT NULL + extern const pb_msgdesc_t meshtastic_Position_msg; extern const pb_msgdesc_t meshtastic_User_msg; extern const pb_msgdesc_t meshtastic_RouteDiscovery_msg; @@ -1118,6 +1174,7 @@ extern const pb_msgdesc_t meshtastic_QueueStatus_msg; extern const pb_msgdesc_t meshtastic_FromRadio_msg; extern const pb_msgdesc_t meshtastic_ToRadio_msg; extern const pb_msgdesc_t meshtastic_Compressed_msg; +extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg; /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ #define meshtastic_Position_fields &meshtastic_Position_msg @@ -1134,10 +1191,12 @@ extern const pb_msgdesc_t meshtastic_Compressed_msg; #define meshtastic_FromRadio_fields &meshtastic_FromRadio_msg #define meshtastic_ToRadio_fields &meshtastic_ToRadio_msg #define meshtastic_Compressed_fields &meshtastic_Compressed_msg +#define meshtastic_DeviceMetadata_fields &meshtastic_DeviceMetadata_msg /* Maximum encoded size of messages (where known) */ #define meshtastic_Compressed_size 243 #define meshtastic_Data_size 270 +#define meshtastic_DeviceMetadata_size 44 #define meshtastic_FromRadio_size 330 #define meshtastic_LogRecord_size 81 #define meshtastic_MeshPacket_size 321 diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index fd1b84bd2..4c50d7059 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -490,19 +490,7 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const void AdminModule::handleGetDeviceMetadata(const meshtastic_MeshPacket &req) { meshtastic_AdminMessage r = meshtastic_AdminMessage_init_default; - - meshtastic_DeviceMetadata deviceMetadata; - strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18); - deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; - deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN; - deviceMetadata.hasBluetooth = HAS_BLUETOOTH; - deviceMetadata.hasWifi = HAS_WIFI; - deviceMetadata.hasEthernet = HAS_ETHERNET; - deviceMetadata.role = config.device.role; - deviceMetadata.position_flags = config.position.position_flags; - deviceMetadata.hw_model = HW_VENDOR; - - r.get_device_metadata_response = deviceMetadata; + r.get_device_metadata_response = getDeviceMetadata(); r.which_payload_variant = meshtastic_AdminMessage_get_device_metadata_response_tag; myReply = allocDataProtobuf(r); } From 2e6e0644d4a71a9e8cf574064f8f32575d31d1fe Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Feb 2023 12:18:27 -0600 Subject: [PATCH 20/25] Move it around and kill old device metadata gen --- src/main.cpp | 15 ++++ src/main.h | 2 + src/mesh/NodeDB.cpp | 1 + src/mesh/NodeDB.h | 16 ---- src/mesh/PhoneAPI.cpp | 1 + .../generated/meshtastic/device_metadata.pb.c | 12 --- .../generated/meshtastic/device_metadata.pb.h | 83 ------------------- 7 files changed, 19 insertions(+), 111 deletions(-) delete mode 100644 src/mesh/generated/meshtastic/device_metadata.pb.c delete mode 100644 src/mesh/generated/meshtastic/device_metadata.pb.h diff --git a/src/main.cpp b/src/main.cpp index f2681bc19..24b1767dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -537,6 +537,21 @@ uint32_t shutdownAtMsec; // If not zero we will shutdown at this time (used to s // This will supress the current delay and instead try to run ASAP. bool runASAP; +extern meshtastic_DeviceMetadata getDeviceMetadata() +{ + meshtastic_DeviceMetadata deviceMetadata; + strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18); + deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; + deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN; + deviceMetadata.hasBluetooth = HAS_BLUETOOTH; + deviceMetadata.hasWifi = HAS_WIFI; + deviceMetadata.hasEthernet = HAS_ETHERNET; + deviceMetadata.role = config.device.role; + deviceMetadata.position_flags = config.position.position_flags; + deviceMetadata.hw_model = HW_VENDOR; + return deviceMetadata; +} + void loop() { runASAP = false; diff --git a/src/main.h b/src/main.h index b1bee1b06..62c022b2b 100644 --- a/src/main.h +++ b/src/main.h @@ -61,3 +61,5 @@ extern uint32_t serialSinceMsec; extern bool runASAP; void nrf52Setup(), esp32Setup(), nrf52Loop(), esp32Loop(), clearBonds(); + +meshtastic_DeviceMetadata getDeviceMetadata(); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index e03f9bb17..5c28f5261 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -11,6 +11,7 @@ #include "RTC.h" #include "Router.h" #include "error.h" +#include "main.h" #include "mesh-pb-constants.h" #include #include diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 7d95062a2..a6fbd9cb0 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -1,7 +1,6 @@ #pragma once #include "Observer.h" -#include "main.h" #include #include @@ -230,18 +229,3 @@ extern uint32_t radioGeneration; (ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \ ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \ ModuleConfig_TelemetryConfig_size + ModuleConfig_size) - -inline meshtastic_DeviceMetadata getDeviceMetadata() -{ - meshtastic_DeviceMetadata deviceMetadata; - strncpy(deviceMetadata.firmware_version, myNodeInfo.firmware_version, 18); - deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; - deviceMetadata.canShutdown = pmu_found || HAS_CPU_SHUTDOWN; - deviceMetadata.hasBluetooth = HAS_BLUETOOTH; - deviceMetadata.hasWifi = HAS_WIFI; - deviceMetadata.hasEthernet = HAS_ETHERNET; - deviceMetadata.role = config.device.role; - deviceMetadata.position_flags = config.position.position_flags; - deviceMetadata.hw_model = HW_VENDOR; - return deviceMetadata; -} \ No newline at end of file diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index c91863bdc..c69694196 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -6,6 +6,7 @@ #include "PowerFSM.h" #include "RadioInterface.h" #include "configuration.h" +#include "main.h" #include "xmodem.h" #if FromRadio_size > MAX_TO_FROM_RADIO_SIZE diff --git a/src/mesh/generated/meshtastic/device_metadata.pb.c b/src/mesh/generated/meshtastic/device_metadata.pb.c deleted file mode 100644 index 627ce3244..000000000 --- a/src/mesh/generated/meshtastic/device_metadata.pb.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.4.7 */ - -#include "meshtastic/device_metadata.pb.h" -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -PB_BIND(meshtastic_DeviceMetadata, meshtastic_DeviceMetadata, AUTO) - - - diff --git a/src/mesh/generated/meshtastic/device_metadata.pb.h b/src/mesh/generated/meshtastic/device_metadata.pb.h deleted file mode 100644 index 44cf29079..000000000 --- a/src/mesh/generated/meshtastic/device_metadata.pb.h +++ /dev/null @@ -1,83 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.4.7 */ - -#ifndef PB_MESHTASTIC_MESHTASTIC_DEVICE_METADATA_PB_H_INCLUDED -#define PB_MESHTASTIC_MESHTASTIC_DEVICE_METADATA_PB_H_INCLUDED -#include -#include "meshtastic/config.pb.h" -#include "meshtastic/mesh.pb.h" - -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -/* Struct definitions */ -/* Device metadata response */ -typedef struct _meshtastic_DeviceMetadata { - /* Device firmware version string */ - char firmware_version[18]; - /* Device state version */ - uint32_t device_state_version; - /* Indicates whether the device can shutdown CPU natively or via power management chip */ - bool canShutdown; - /* Indicates that the device has native wifi capability */ - bool hasWifi; - /* Indicates that the device has native bluetooth capability */ - bool hasBluetooth; - /* Indicates that the device has an ethernet peripheral */ - bool hasEthernet; - /* Indicates that the device's role in the mesh */ - meshtastic_Config_DeviceConfig_Role role; - /* Indicates the device's current enabled position flags */ - uint32_t position_flags; - /* Device hardware model */ - meshtastic_HardwareModel hw_model; -} meshtastic_DeviceMetadata; - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Initializer values for message structs */ -#define meshtastic_DeviceMetadata_init_default {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN} -#define meshtastic_DeviceMetadata_init_zero {"", 0, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_Role_MIN, 0, _meshtastic_HardwareModel_MIN} - -/* Field tags (for use in manual encoding/decoding) */ -#define meshtastic_DeviceMetadata_firmware_version_tag 1 -#define meshtastic_DeviceMetadata_device_state_version_tag 2 -#define meshtastic_DeviceMetadata_canShutdown_tag 3 -#define meshtastic_DeviceMetadata_hasWifi_tag 4 -#define meshtastic_DeviceMetadata_hasBluetooth_tag 5 -#define meshtastic_DeviceMetadata_hasEthernet_tag 6 -#define meshtastic_DeviceMetadata_role_tag 7 -#define meshtastic_DeviceMetadata_position_flags_tag 8 -#define meshtastic_DeviceMetadata_hw_model_tag 9 - -/* Struct field encoding specification for nanopb */ -#define meshtastic_DeviceMetadata_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, STRING, firmware_version, 1) \ -X(a, STATIC, SINGULAR, UINT32, device_state_version, 2) \ -X(a, STATIC, SINGULAR, BOOL, canShutdown, 3) \ -X(a, STATIC, SINGULAR, BOOL, hasWifi, 4) \ -X(a, STATIC, SINGULAR, BOOL, hasBluetooth, 5) \ -X(a, STATIC, SINGULAR, BOOL, hasEthernet, 6) \ -X(a, STATIC, SINGULAR, UENUM, role, 7) \ -X(a, STATIC, SINGULAR, UINT32, position_flags, 8) \ -X(a, STATIC, SINGULAR, UENUM, hw_model, 9) -#define meshtastic_DeviceMetadata_CALLBACK NULL -#define meshtastic_DeviceMetadata_DEFAULT NULL - -extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg; - -/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ -#define meshtastic_DeviceMetadata_fields &meshtastic_DeviceMetadata_msg - -/* Maximum encoded size of messages (where known) */ -#define meshtastic_DeviceMetadata_size 44 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif From b3fac71a8d60422a99cb7068ae9b1c505383ced3 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Feb 2023 12:52:03 -0600 Subject: [PATCH 21/25] Missed some stuff --- src/mesh/PhoneAPI.cpp | 2 ++ src/mesh/PhoneAPI.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index c69694196..cdda05913 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -121,6 +121,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength) * STATE_SEND_NODEINFO, // states progress in this order as the device sends to the client STATE_SEND_CONFIG, STATE_SEND_MODULE_CONFIG, + STATE_SEND_METADATA, STATE_SEND_COMPLETE_ID, STATE_SEND_PACKETS // send packets or debug strings */ @@ -366,6 +367,7 @@ bool PhoneAPI::available() case STATE_SEND_CHANNELS: case STATE_SEND_CONFIG: case STATE_SEND_MODULECONFIG: + case STATE_SEND_METADATA: case STATE_SEND_COMPLETE_ID: return true; diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index cc219b690..de7f3532d 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -26,6 +26,7 @@ class PhoneAPI STATE_SEND_CHANNELS, // Send all channels STATE_SEND_CONFIG, // Replacement for the old Radioconfig STATE_SEND_MODULECONFIG, // Send Module specific config + STATE_SEND_METADATA, STATE_SEND_COMPLETE_ID, STATE_SEND_METADATA, STATE_SEND_PACKETS // send packets or debug strings From 221a145d2d643eb50856095f5c6556d1fada8a05 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Feb 2023 12:58:54 -0600 Subject: [PATCH 22/25] Whoops --- src/mesh/PhoneAPI.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/PhoneAPI.h b/src/mesh/PhoneAPI.h index de7f3532d..af8f1be26 100644 --- a/src/mesh/PhoneAPI.h +++ b/src/mesh/PhoneAPI.h @@ -28,7 +28,6 @@ class PhoneAPI STATE_SEND_MODULECONFIG, // Send Module specific config STATE_SEND_METADATA, STATE_SEND_COMPLETE_ID, - STATE_SEND_METADATA, STATE_SEND_PACKETS // send packets or debug strings }; From 07b90a61e18d4b5e8e6388d32865539102ff2e6c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Feb 2023 13:51:20 -0600 Subject: [PATCH 23/25] For science --- src/mesh/RadioInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/RadioInterface.h b/src/mesh/RadioInterface.h index 1a84c87f9..b9511fd5d 100644 --- a/src/mesh/RadioInterface.h +++ b/src/mesh/RadioInterface.h @@ -63,7 +63,7 @@ class RadioInterface - Tx/Rx turnaround time (maximum of SX126x and SX127x); - MAC processing time (measured on T-beam) */ uint32_t slotTimeMsec = 8.5 * pow(2, sf) / bw + 0.2 + 0.4 + 7; - uint16_t preambleLength = 32; // 8 is default, but we use longer to increase the amount of sleep time when receiving + uint16_t preambleLength = 16; // 8 is default, but we use longer to increase the amount of sleep time when receiving const uint32_t PROCESSING_TIME_MSEC = 4500; // time to construct, process and construct a packet again (empirically determined) const uint8_t CWmin = 2; // minimum CWsize From 8aede61adb2fc6e92553352b9c9fc2cc3a898ff1 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Thu, 16 Feb 2023 20:58:10 +0100 Subject: [PATCH 24/25] Fix setting preambleLength for SX127x Don't set currentLimit, it is set automatically in begin() --- src/mesh/RF95Interface.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/mesh/RF95Interface.cpp b/src/mesh/RF95Interface.cpp index f4344941d..2e378aacb 100644 --- a/src/mesh/RF95Interface.cpp +++ b/src/mesh/RF95Interface.cpp @@ -67,19 +67,12 @@ bool RF95Interface::init() #endif setTransmitEnable(false); - int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, currentLimit, preambleLength); + int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength); LOG_INFO("RF95 init result %d\n", res); - LOG_INFO("Frequency set to %f\n", getFreq()); LOG_INFO("Bandwidth set to %f\n", bw); LOG_INFO("Power output set to %d\n", power); - // current limit was removed from module' ctor - // override default value (60 mA) - res = lora->setCurrentLimit(currentLimit); - LOG_DEBUG("Current limit set to %f\n", currentLimit); - LOG_DEBUG("Current limit set result %d\n", res); - if (res == RADIOLIB_ERR_NONE) res = lora->setCRC(RADIOLIB_SX126X_LORA_CRC_ON); From 643237162e6ab2285bb263422757f52aa1bacafd Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 16 Feb 2023 19:26:21 -0600 Subject: [PATCH 25/25] Regen protos --- protobufs | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/protobufs b/protobufs index ff26da703..cb01d7472 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit ff26da70385fc067af3c0d2950e97f90d632f142 +Subproject commit cb01d7472fc22321652a5471155dfc6c04a612ab diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index f22294a2e..25e5fbf05 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -89,6 +89,8 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_BETAFPV_2400_TX = 45, /* BetaFPV ExpressLRS "Nano" TX Module 900MHz with ESP32 CPU */ meshtastic_HardwareModel_BETAFPV_900_NANO_TX = 46, + /* B&Q Consulting Nano G1 Explorer: https://wiki.uniteng.com/en/meshtastic/nano-g1-explorer */ + meshtastic_HardwareModel_NANO_G1_EXPLORER = 47, /* 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. */ meshtastic_HardwareModel_PRIVATE_HW = 255 } meshtastic_HardwareModel;