From 0b48663cbcfb964ee8803f930e8152482a492d98 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 30 May 2024 08:49:01 -0500 Subject: [PATCH 1/4] Don't alloc NodeInfo replies when channel utilization is > 40% (#3991) * Don't alloc NodeInfo replies when channel utilization is > 40% * Commit * Logs --- src/modules/NodeInfoModule.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp index f77026708..78af7099a 100644 --- a/src/modules/NodeInfoModule.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -58,10 +58,15 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies, uint8_t cha meshtastic_MeshPacket *NodeInfoModule::allocReply() { + if (!airTime->isTxAllowedChannelUtil(false)) { + ignoreRequest = true; // Mark it as ignored for MeshModule + LOG_DEBUG("Skip sending NodeInfo due to > 40 percent channel util.\n"); + return NULL; + } uint32_t now = millis(); // If we sent our NodeInfo less than 5 min. ago, don't send it again as it may be still underway. if (lastSentToMesh && (now - lastSentToMesh) < (5 * 60 * 1000)) { - LOG_DEBUG("Sending NodeInfo will be ignored since we just sent it.\n"); + LOG_DEBUG("Skip sending NodeInfo since we just sent it less than 5 minutes ago.\n"); ignoreRequest = true; // Mark it as ignored for MeshModule return NULL; } else { From cd8a7e44a8cac6dac8c7d8ed0b6f993edc109ad6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 09:08:32 -0500 Subject: [PATCH 2/4] [create-pull-request] automated change (#3992) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/atak.pb.h | 15 ++++++++++----- src/mesh/generated/meshtastic/mesh.pb.h | 3 +++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/protobufs b/protobufs index b5dc871a1..9e61b8233 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit b5dc871a1bfa2cc932126a4f490d9ef078476e4c +Subproject commit 9e61b8233181715363aba2aa6c91e85a2d61fc73 diff --git a/src/mesh/generated/meshtastic/atak.pb.h b/src/mesh/generated/meshtastic/atak.pb.h index c094727ed..5fd18f963 100644 --- a/src/mesh/generated/meshtastic/atak.pb.h +++ b/src/mesh/generated/meshtastic/atak.pb.h @@ -73,6 +73,9 @@ typedef struct _meshtastic_GeoChat { /* Uid recipient of the message */ bool has_to; char to[120]; + /* Callsign of the recipient for the message */ + bool has_to_callsign; + char to_callsign[120]; } meshtastic_GeoChat; /* ATAK Group @@ -164,13 +167,13 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_TAKPacket_init_default {0, false, meshtastic_Contact_init_default, false, meshtastic_Group_init_default, false, meshtastic_Status_init_default, 0, {meshtastic_PLI_init_default}} -#define meshtastic_GeoChat_init_default {"", false, ""} +#define meshtastic_GeoChat_init_default {"", false, "", false, ""} #define meshtastic_Group_init_default {_meshtastic_MemberRole_MIN, _meshtastic_Team_MIN} #define meshtastic_Status_init_default {0} #define meshtastic_Contact_init_default {"", ""} #define meshtastic_PLI_init_default {0, 0, 0, 0, 0} #define meshtastic_TAKPacket_init_zero {0, false, meshtastic_Contact_init_zero, false, meshtastic_Group_init_zero, false, meshtastic_Status_init_zero, 0, {meshtastic_PLI_init_zero}} -#define meshtastic_GeoChat_init_zero {"", false, ""} +#define meshtastic_GeoChat_init_zero {"", false, "", false, ""} #define meshtastic_Group_init_zero {_meshtastic_MemberRole_MIN, _meshtastic_Team_MIN} #define meshtastic_Status_init_zero {0} #define meshtastic_Contact_init_zero {"", ""} @@ -179,6 +182,7 @@ extern "C" { /* Field tags (for use in manual encoding/decoding) */ #define meshtastic_GeoChat_message_tag 1 #define meshtastic_GeoChat_to_tag 2 +#define meshtastic_GeoChat_to_callsign_tag 3 #define meshtastic_Group_role_tag 1 #define meshtastic_Group_team_tag 2 #define meshtastic_Status_battery_tag 1 @@ -214,7 +218,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,chat,payload_variant.chat), #define meshtastic_GeoChat_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, STRING, message, 1) \ -X(a, STATIC, OPTIONAL, STRING, to, 2) +X(a, STATIC, OPTIONAL, STRING, to, 2) \ +X(a, STATIC, OPTIONAL, STRING, to_callsign, 3) #define meshtastic_GeoChat_CALLBACK NULL #define meshtastic_GeoChat_DEFAULT NULL @@ -262,11 +267,11 @@ extern const pb_msgdesc_t meshtastic_PLI_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_ATAK_PB_H_MAX_SIZE meshtastic_TAKPacket_size #define meshtastic_Contact_size 242 -#define meshtastic_GeoChat_size 323 +#define meshtastic_GeoChat_size 444 #define meshtastic_Group_size 4 #define meshtastic_PLI_size 31 #define meshtastic_Status_size 3 -#define meshtastic_TAKPacket_size 584 +#define meshtastic_TAKPacket_size 705 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index ffc18c30b..7b544d714 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -156,6 +156,9 @@ typedef enum _meshtastic_HardwareModel { /* NRF52_PROMICRO_DIY Promicro NRF52840 with SX1262/LLCC68, SSD1306 OLED and NEO6M GPS */ meshtastic_HardwareModel_NRF52_PROMICRO_DIY = 63, + /* RadioMaster 900 Bandit Nano, https://www.radiomasterrc.com/products/bandit-nano-expresslrs-rf-module + ESP32-D0WDQ6 With SX1276/SKY66122, SSD1306 OLED and No GPS */ + meshtastic_HardwareModel_RADIOMASTER_900_BANDIT_NANO = 64, /* ------------------------------------------------------------------------------------------------------------------------------------------ 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 f138eaa970339250dfff1b5608ce1463253312f9 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 30 May 2024 18:59:10 +0300 Subject: [PATCH 3/4] Fix original esp32 boot init panic (#3985) Co-authored-by: Ben Meadors --- arch/esp32/esp32.ini | 1 + arch/esp32/esp32c3.ini | 1 + arch/esp32/esp32s2.ini | 1 + arch/esp32/esp32s3.ini | 1 + bin/platformio-custom.py | 16 +++++++++++++++- src/platform/esp32/iram-quirk.c | 23 +++++++++++++++++++++++ 6 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/platform/esp32/iram-quirk.c diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini index 7e55f0934..f3eb0cbc0 100644 --- a/arch/esp32/esp32.ini +++ b/arch/esp32/esp32.ini @@ -1,6 +1,7 @@ ; Common settings for ESP targes, mixin with extends = esp32_base [esp32_base] extends = arduino_base +custom_esp32_kind = esp32 platform = platformio/espressif32@6.7.0 build_src_filter = diff --git a/arch/esp32/esp32c3.ini b/arch/esp32/esp32c3.ini index 619fdb28a..2ba3036d0 100644 --- a/arch/esp32/esp32c3.ini +++ b/arch/esp32/esp32c3.ini @@ -1,5 +1,6 @@ [esp32c3_base] extends = esp32_base +custom_esp32_kind = esp32c3 monitor_speed = 115200 monitor_filters = esp32_c3_exception_decoder diff --git a/arch/esp32/esp32s2.ini b/arch/esp32/esp32s2.ini index df66de2ed..40fdc461a 100644 --- a/arch/esp32/esp32s2.ini +++ b/arch/esp32/esp32s2.ini @@ -1,5 +1,6 @@ [esp32s2_base] extends = esp32_base +custom_esp32_kind = esp32s2 build_src_filter = ${esp32_base.build_src_filter} - - - diff --git a/arch/esp32/esp32s3.ini b/arch/esp32/esp32s3.ini index 6a1bdd3fd..1cd0e2033 100644 --- a/arch/esp32/esp32s3.ini +++ b/arch/esp32/esp32s3.ini @@ -1,5 +1,6 @@ [esp32s3_base] extends = esp32_base +custom_esp32_kind = esp32s3 monitor_speed = 115200 diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index 3382ff891..3202a1e7a 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -62,7 +62,21 @@ if platform.name == "espressif32": import esptool env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) - env.Append(LINKFLAGS=["--specs=nano.specs", "-u", "_printf_float"]) + + esp32_kind = env.GetProjectOption("custom_esp32_kind") + if esp32_kind == "esp32": + # Free up some IRAM by removing auxiliary SPI flash chip drivers. + # Wrapped stub symbols are defined in src/platform/esp32/iram-quirk.c. + env.Append( + LINKFLAGS=[ + "-Wl,--wrap=esp_flash_chip_gd", + "-Wl,--wrap=esp_flash_chip_issi", + "-Wl,--wrap=esp_flash_chip_winbond", + ] + ) + else: + # For newer ESP32 targets, using newlib nano works better. + env.Append(LINKFLAGS=["--specs=nano.specs", "-u", "_printf_float"]) Import("projenv") diff --git a/src/platform/esp32/iram-quirk.c b/src/platform/esp32/iram-quirk.c new file mode 100644 index 000000000..813842138 --- /dev/null +++ b/src/platform/esp32/iram-quirk.c @@ -0,0 +1,23 @@ +// Free up some precious space in the iram0_0_seg memory segment + +#include + +#include +#include +#include + +#define IRAM_SECTION section(".iram1.stub") + +IRAM_ATTR esp_err_t stub_probe(esp_flash_t *chip, uint32_t flash_id) +{ + return ESP_ERR_NOT_FOUND; +} + +const spi_flash_chip_t stub_flash_chip __attribute__((IRAM_SECTION)) = { + .name = "stub", + .probe = stub_probe, +}; + +extern const spi_flash_chip_t __wrap_esp_flash_chip_gd __attribute__((IRAM_SECTION, alias("stub_flash_chip"))); +extern const spi_flash_chip_t __wrap_esp_flash_chip_issi __attribute__((IRAM_SECTION, alias("stub_flash_chip"))); +extern const spi_flash_chip_t __wrap_esp_flash_chip_winbond __attribute__((IRAM_SECTION, alias("stub_flash_chip"))); From 10e3040494bc50abce8c32f96aee2e2a71d3479b Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 30 May 2024 18:49:08 -0500 Subject: [PATCH 4/4] Add support for to_callsign on GeoChats for ATAK (#3996) --- src/modules/AtakPluginModule.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/modules/AtakPluginModule.cpp b/src/modules/AtakPluginModule.cpp index b460602ef..59263415c 100644 --- a/src/modules/AtakPluginModule.cpp +++ b/src/modules/AtakPluginModule.cpp @@ -87,6 +87,14 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast compressed.payload_variant.chat.to); LOG_DEBUG("Compressed chat to: %d bytes\n", length); } + + if (t->payload_variant.chat.has_to_callsign) { + compressed.payload_variant.chat.has_to_callsign = true; + length = + unishox2_compress_simple(t->payload_variant.chat.to_callsign, strlen(t->payload_variant.chat.to_callsign), + compressed.payload_variant.chat.to_callsign); + LOG_DEBUG("Compressed chat to_callsign: %d bytes\n", length); + } } mp.decoded.payload.size = pb_encode_to_bytes(mp.decoded.payload.bytes, sizeof(mp.decoded.payload.bytes), meshtastic_TAKPacket_fields, &compressed); @@ -124,6 +132,14 @@ void AtakPluginModule::alterReceivedProtobuf(meshtastic_MeshPacket &mp, meshtast uncompressed.payload_variant.chat.to); LOG_DEBUG("Decompressed chat to: %d bytes\n", length); } + + if (t->payload_variant.chat.has_to_callsign) { + uncompressed.payload_variant.chat.has_to_callsign = true; + length = + unishox2_decompress_simple(t->payload_variant.chat.to_callsign, strlen(t->payload_variant.chat.to_callsign), + uncompressed.payload_variant.chat.to_callsign); + LOG_DEBUG("Decompressed chat to_callsign: %d bytes\n", length); + } } decompressedCopy->decoded.payload.size = pb_encode_to_bytes(decompressedCopy->decoded.payload.bytes, sizeof(decompressedCopy->decoded.payload),