From e6b20bff771b5c72174cf8f04e6a8c31bd0726e3 Mon Sep 17 00:00:00 2001 From: Andre K Date: Sun, 15 Oct 2023 20:56:47 -0300 Subject: [PATCH 1/7] refactor: simplify MQTT defaults (#2893) Co-authored-by: Ben Meadors --- src/mesh/NodeDB.cpp | 2 ++ src/mesh/NodeDB.h | 1 + src/mesh/Router.cpp | 23 +++-------------------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 9ca7f2fb2..2046c2cea 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -254,6 +254,8 @@ void NodeDB::installDefaultModuleConfig() strncpy(moduleConfig.mqtt.address, default_mqtt_address, sizeof(moduleConfig.mqtt.address)); strncpy(moduleConfig.mqtt.username, default_mqtt_username, sizeof(moduleConfig.mqtt.username)); strncpy(moduleConfig.mqtt.password, default_mqtt_password, sizeof(moduleConfig.mqtt.password)); + strncpy(moduleConfig.mqtt.root, default_mqtt_root, sizeof(moduleConfig.mqtt.root)); + moduleConfig.mqtt.encryption_enabled = true; moduleConfig.has_neighbor_info = true; moduleConfig.neighbor_info.enabled = false; diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 22d5a7780..5fca0e440 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -204,6 +204,7 @@ extern NodeDB nodeDB; #define default_mqtt_address "mqtt.meshtastic.org" #define default_mqtt_username "meshdev" #define default_mqtt_password "large4cats" +#define default_mqtt_root "msh" inline uint32_t getConfiguredOrDefaultMs(uint32_t configuredInterval) { diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 03aa57351..b2d8d585d 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -249,29 +249,12 @@ ErrorCode Router::send(meshtastic_MeshPacket *p) if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) { ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it - bool shouldActuallyEncrypt = true; - if (moduleConfig.mqtt.enabled) { - // check if we should send decrypted packets to mqtt - // truth table: - /* mqtt_server mqtt_encryption_enabled should_encrypt - * not set 0 1 - * not set 1 1 - * set 0 0 - * set 1 1 - * - * => so we only decrypt mqtt if they have a custom mqtt server AND mqtt_encryption_enabled is FALSE - */ - - if (*moduleConfig.mqtt.address && !moduleConfig.mqtt.encryption_enabled) { - shouldActuallyEncrypt = false; - } - - LOG_INFO("Should encrypt MQTT?: %d\n", shouldActuallyEncrypt); + LOG_INFO("Should encrypt MQTT?: %d\n", moduleConfig.mqtt.encryption_enabled); // the packet is currently in a decrypted state. send it now if they want decrypted packets - if (mqtt && !shouldActuallyEncrypt) + if (mqtt && !moduleConfig.mqtt.encryption_enabled) mqtt->onSend(*p, chIndex); } @@ -284,7 +267,7 @@ ErrorCode Router::send(meshtastic_MeshPacket *p) if (moduleConfig.mqtt.enabled) { // the packet is now encrypted. // check if we should send encrypted packets to mqtt - if (mqtt && shouldActuallyEncrypt) + if (mqtt && moduleConfig.mqtt.encryption_enabled) mqtt->onSend(*p, chIndex); } } From 092e6f2424aac486267c15e1c94f18c36093017a Mon Sep 17 00:00:00 2001 From: Tavis Date: Tue, 17 Oct 2023 01:50:36 -1000 Subject: [PATCH 2/7] add rssi and snr to json output (#2894) * add rssi and snr to json output * explicitly cast to int and float --- src/mqtt/MQTT.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index cbaba45d6..a9e80c947 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -692,6 +692,10 @@ std::string MQTT::meshPacketToJson(meshtastic_MeshPacket *mp) jsonObj["channel"] = new JSONValue((uint)mp->channel); jsonObj["type"] = new JSONValue(msgType.c_str()); jsonObj["sender"] = new JSONValue(owner.id); + if (mp->rx_rssi != 0) + jsonObj["rssi"] = new JSONValue((int)mp->rx_rssi); + if (mp->rx_snr != 0) + jsonObj["snr"] = new JSONValue((float)mp->rx_snr); // serialize and write it to the stream JSONValue *value = new JSONValue(jsonObj); From 227467f638397ea42742f104816c60afdef6fac0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Oct 2023 09:52:56 -0500 Subject: [PATCH 3/7] [create-pull-request] automated change (#2897) Co-authored-by: thebentern --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 4bc25ac89..006a90013 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 2 -build = 12 +build = 13 From a60b4d08bfaf678006156e028fdc7caf52420f17 Mon Sep 17 00:00:00 2001 From: S5NC <145265251+S5NC@users.noreply.github.com> Date: Wed, 25 Oct 2023 00:47:36 +0100 Subject: [PATCH 4/7] Hydra variant rectification (#2903) * Update variant.h * Update variant.h * Update platformio.ini --- variants/diy/hydra/variant.h | 54 ++++++++++++++++-------------------- variants/diy/platformio.ini | 2 -- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/variants/diy/hydra/variant.h b/variants/diy/hydra/variant.h index 98c1c2ae1..601bca310 100644 --- a/variants/diy/hydra/variant.h +++ b/variants/diy/hydra/variant.h @@ -2,44 +2,38 @@ #define I2C_SDA 21 #define I2C_SCL 22 -// GPS -#undef GPS_RX_PIN -#undef GPS_TX_PIN -#define GPS_RX_PIN 12 +// For GPS, 'undef's not needed #define GPS_TX_PIN 15 -#define GPS_UBLOX +#define GPS_RX_PIN 12 #define PIN_GPS_EN 4 +#define GPS_POWER_TOGGLE // Moved definition from platformio.ini to here #define BUTTON_PIN 39 // The middle button GPIO on the T-Beam #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k) -#define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards -#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). -#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets) +#define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards +#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). +#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets) -#define LORA_DIO0 26 // a No connect on the SX1262/SX1268 module -#define LORA_RESET 23 // RST for SX1276, and for SX1262/SX1268 -#define LORA_DIO1 33 // IRQ for SX1262/SX1268 -#define LORA_DIO2 32 // BUSY for SX1262/SX1268 -#define LORA_DIO3 // Not connected on PCB, but internally on the TTGO SX1262/SX1268, if DIO3 is high the TXCO is enabled +// Radio +#define USE_SX1262 // E22-900M30S uses SX1262 +#define SX126X_MAX_POWER 22 // Outputting 22dBm from SX1262 results in ~30dBm E22-900M30S output (module only uses last stage of the YP2233W PA) +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 // E22 series TCXO reference voltage is 1.8V -#define RF95_SCK 5 -#define RF95_MISO 19 -#define RF95_MOSI 27 -#define RF95_NSS 18 +#define SX126X_CS 18 // EBYTE module's NSS pin +#define SX126X_SCK 5 // EBYTE module's SCK pin +#define SX126X_MOSI 27 // EBYTE module's MOSI pin +#define SX126X_MISO 19 // EBYTE module's MISO pin +#define SX126X_RESET 23 // EBYTE module's NRST pin +#define SX126X_BUSY 32 // EBYTE module's BUSY pin +#define SX126X_DIO1 33 // EBYTE module's DIO1 pin -#define USE_SX1262 +#define SX126X_TXEN 13 // Schematic connects EBYTE module's TXEN pin to MCU +#define SX126X_RXEN 14 // Schematic connects EBYTE module's RXEN pin to MCU -#define SX126X_CS 18 // NSS for SX126X -#define SX126X_DIO1 LORA_DIO1 -#define SX126X_BUSY LORA_DIO2 -#define SX126X_RESET LORA_RESET -#define SX126X_RXEN 14 -#define SX126X_TXEN RADIOLIB_NC -#define SX126X_DIO2_AS_RF_SWITCH - -// Set lora.tx_power to 13 for Hydra or other E22 900M30S target due to PA -#define SX126X_MAX_POWER 13 - -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 +#define RF95_NSS SX126X_CS // Compatibility with variant file configuration structure +#define RF95_SCK SX126X_SCK // Compatibility with variant file configuration structure +#define RF95_MOSI SX126X_MOSI // Compatibility with variant file configuration structure +#define RF95_MISO SX126X_MISO // Compatibility with variant file configuration structure +#define LORA_DIO1 SX126X_DIO1 // Compatibility with variant file configuration structure diff --git a/variants/diy/platformio.ini b/variants/diy/platformio.ini index cb031f266..e7d72d13f 100644 --- a/variants/diy/platformio.ini +++ b/variants/diy/platformio.ini @@ -43,6 +43,4 @@ board_level = extra build_flags = ${esp32_base.build_flags} -D DIY_V1 - -D EBYTE_E22 - -D GPS_POWER_TOGGLE -I variants/diy/hydra From b36ffe520048bf1079a7af30cc2d354628cd0355 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Tue, 24 Oct 2023 18:52:46 -0500 Subject: [PATCH 5/7] Trunk fmt fix --- variants/diy/hydra/variant.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/variants/diy/hydra/variant.h b/variants/diy/hydra/variant.h index 601bca310..64bdd73f7 100644 --- a/variants/diy/hydra/variant.h +++ b/variants/diy/hydra/variant.h @@ -12,14 +12,15 @@ #define BATTERY_PIN 35 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage #define ADC_CHANNEL ADC1_GPIO35_CHANNEL #define ADC_MULTIPLIER 1.85 // (R1 = 470k, R2 = 680k) -#define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards -#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). -#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets) +#define EXT_PWR_DETECT 4 // Pin to detect connected external power source for LILYGO® TTGO T-Energy T18 and other DIY boards +#define EXT_NOTIFY_OUT 12 // Overridden default pin to use for Ext Notify Module (#975). +#define LED_PIN 2 // add status LED (compatible with core-pcb and DIY targets) // Radio #define USE_SX1262 // E22-900M30S uses SX1262 -#define SX126X_MAX_POWER 22 // Outputting 22dBm from SX1262 results in ~30dBm E22-900M30S output (module only uses last stage of the YP2233W PA) -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 // E22 series TCXO reference voltage is 1.8V +#define SX126X_MAX_POWER \ + 22 // Outputting 22dBm from SX1262 results in ~30dBm E22-900M30S output (module only uses last stage of the YP2233W PA) +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 // E22 series TCXO reference voltage is 1.8V #define SX126X_CS 18 // EBYTE module's NSS pin #define SX126X_SCK 5 // EBYTE module's SCK pin @@ -32,8 +33,8 @@ #define SX126X_TXEN 13 // Schematic connects EBYTE module's TXEN pin to MCU #define SX126X_RXEN 14 // Schematic connects EBYTE module's RXEN pin to MCU -#define RF95_NSS SX126X_CS // Compatibility with variant file configuration structure -#define RF95_SCK SX126X_SCK // Compatibility with variant file configuration structure +#define RF95_NSS SX126X_CS // Compatibility with variant file configuration structure +#define RF95_SCK SX126X_SCK // Compatibility with variant file configuration structure #define RF95_MOSI SX126X_MOSI // Compatibility with variant file configuration structure #define RF95_MISO SX126X_MISO // Compatibility with variant file configuration structure #define LORA_DIO1 SX126X_DIO1 // Compatibility with variant file configuration structure From 4052194dfefd3eed88b313128606488636e9ea80 Mon Sep 17 00:00:00 2001 From: Ric In New Mexico <78682404+RicInNewMexico@users.noreply.github.com> Date: Thu, 26 Oct 2023 05:25:06 -0600 Subject: [PATCH 6/7] Fix for is_licensed save / reboot (#2911) * Fix is_licensed save / reboot * Revert "Fix is_licensed save / reboot" This reverts commit 634151b8ec6f4063dc95966102234ef7aba8cefd. * Changed reloadConfig to saveChanges /w reboot --- src/modules/AdminModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 27b539f38..f25e8db33 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -676,7 +676,7 @@ void AdminModule::handleSetHamMode(const meshtastic_HamParameters &p) channels.onConfigChanged(); service.reloadOwner(false); - service.reloadConfig(SEGMENT_CONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS); + saveChanges(SEGMENT_CONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS); } AdminModule::AdminModule() : ProtobufModule("Admin", meshtastic_PortNum_ADMIN_APP, &meshtastic_AdminMessage_msg) From 8b8fffda81ef1dc1211955c9d0ff66225ef8abb9 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:12:22 +0100 Subject: [PATCH 7/7] Drop packets if `toPhoneQueue` is full, unless it's text/RangeTest (#2918) --- src/mesh/MeshService.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 038861937..44094f1bb 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -267,14 +267,22 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) void MeshService::sendToPhone(meshtastic_MeshPacket *p) { + perhapsDecode(p); + if (toPhoneQueue.numFree() == 0) { - LOG_WARN("ToPhone queue is full, discarding oldest\n"); - meshtastic_MeshPacket *d = toPhoneQueue.dequeuePtr(0); - if (d) - releaseToPool(d); + if (p->decoded.portnum == meshtastic_PortNum_TEXT_MESSAGE_APP || + p->decoded.portnum == meshtastic_PortNum_RANGE_TEST_APP) { + LOG_WARN("ToPhone queue is full, discarding oldest\n"); + meshtastic_MeshPacket *d = toPhoneQueue.dequeuePtr(0); + if (d) + releaseToPool(d); + } else { + LOG_WARN("ToPhone queue is full, dropping packet.\n"); + releaseToPool(p); + return; + } } - perhapsDecode(p); assert(toPhoneQueue.enqueue(p, 0)); fromNum++; }