From dc9aa6aff78a88097e0215e27044eb25cc9e85aa Mon Sep 17 00:00:00 2001 From: thebentern <9000580+thebentern@users.noreply.github.com> Date: Wed, 9 Oct 2024 23:48:31 +0000 Subject: [PATCH 01/15] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index df7ba70c7..be97dacb5 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 5 -build = 6 +build = 7 From 411834afba05debd071577d45ecd4f2c602954b7 Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Thu, 10 Oct 2024 17:19:52 +0800 Subject: [PATCH 02/15] Fix bug sending wrong sleep command to U-Blox chips The "U-Blox readable" patch introduced a bug where sleep commands for the 10 and other versions were reversed. --- src/gps/GPS.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 33c21c5bb..74d0a6cce 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -849,7 +849,7 @@ void GPS::setPowerUBLOX(bool on, uint32_t sleepMs) } // Determine hardware version - if (gnssModel == GNSS_MODEL_UBLOX10) { + if (gnssModel != GNSS_MODEL_UBLOX10) { // Encode the sleep time in millis into the packet for (int i = 0; i < 4; i++) gps->_message_PMREQ[0 + i] = sleepMs >> (i * 8); @@ -1714,4 +1714,4 @@ void GPS::toggleGpsMode() enable(); } } -#endif // Exclude GPS \ No newline at end of file +#endif // Exclude GPS From 0cbade989e65e95df5af88228de84f044e27a640 Mon Sep 17 00:00:00 2001 From: todd-herbert Date: Thu, 10 Oct 2024 22:37:25 +1300 Subject: [PATCH 03/15] Check whether NimBLE is instantiated before using (#5015) --- src/graphics/Screen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index ad42fa979..3c0230330 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -497,7 +497,7 @@ void Screen::drawDigitalClockFrame(OLEDDisplay *display, OLEDDisplayUiState *sta display->drawString(x + 20, y + 2, batteryPercent); } - if (nimbleBluetooth->isConnected()) { + if (nimbleBluetooth && nimbleBluetooth->isConnected()) { drawBluetoothConnectedIcon(display, display->getWidth() - 18, y + 2); } @@ -729,7 +729,7 @@ void Screen::drawAnalogClockFrame(OLEDDisplay *display, OLEDDisplayUiState *stat display->drawString(x + 20, y + 2, batteryPercent); } - if (nimbleBluetooth->isConnected()) { + if (nimbleBluetooth && nimbleBluetooth->isConnected()) { drawBluetoothConnectedIcon(display, display->getWidth() - 18, y + 2); } From 149620f071474485144dfa5cc4b6d1fd2fd0f19b Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Thu, 10 Oct 2024 17:56:32 +0800 Subject: [PATCH 04/15] Enable QZSS on UC6580 @allanmac noted we were not enabling QZSS on the UC6580. QZSS is an augmentation service that runs on the same frequency as GPS, so turning it on should not have any impact on usage other than improving performance for users in the Asia Pacific. Fixes https://github.com/meshtastic/firmware/issues/5009 --- src/gps/GPS.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 33c21c5bb..f52016ec8 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -496,10 +496,10 @@ bool GPS::setup() } } else if (gnssModel == GNSS_MODEL_UC6580) { // The Unicore UC6580 can use a lot of sat systems, enable it to - // use GPS L1 & L5 + BDS B1I & B2a + GLONASS L1 + GALILEO E1 & E5a + SBAS + // use GPS L1 & L5 + BDS B1I & B2a + GLONASS L1 + GALILEO E1 & E5a + SBAS + QZSS // This will reset the receiver, so wait a bit afterwards // The paranoid will wait for the OK*04 confirmation response after each command. - _serial_gps->write("$CFGSYS,h25155\r\n"); + _serial_gps->write("$CFGSYS,h35155\r\n"); delay(750); // Must be done after the CFGSYS command // Turn off GSV messages, we don't really care about which and where the sats are, maybe someday. From 7ff4bafe226f1344f858313b12d25d11faea3dfb Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 10 Oct 2024 05:14:11 -0500 Subject: [PATCH 05/15] Disentangle NodeDB from the CryptoEngine (#5013) --- src/mesh/CryptoEngine.cpp | 58 +++++++--------------------------- src/mesh/CryptoEngine.h | 8 ++--- src/mesh/Router.cpp | 5 +-- test/test_crypto/test_main.cpp | 11 ++++--- 4 files changed, 25 insertions(+), 57 deletions(-) diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp index a875eb8b2..484114802 100644 --- a/src/mesh/CryptoEngine.cpp +++ b/src/mesh/CryptoEngine.cpp @@ -1,8 +1,6 @@ #include "CryptoEngine.h" -#include "NodeDB.h" -#include "RadioInterface.h" +// #include "NodeDB.h" #include "architecture.h" -#include "configuration.h" #if !(MESHTASTIC_EXCLUDE_PKI) #include "aes-ccm.h" @@ -62,8 +60,8 @@ void CryptoEngine::clearKeys() * * @param bytes is updated in place */ -bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes, - uint8_t *bytesOut) +bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, meshtastic_UserLite_public_key_t remotePublic, + uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut) { uint8_t *auth; long extraNonceTmp = random(); @@ -71,14 +69,14 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_ memcpy((uint8_t *)(auth + 8), &extraNonceTmp, sizeof(uint32_t)); // do not use dereference on potential non aligned pointers : *extraNonce = extraNonceTmp; LOG_INFO("Random nonce value: %d\n", extraNonceTmp); - meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(toNode); - if (node->num < 1 || node->user.public_key.size == 0) { + if (remotePublic.size == 0) { LOG_DEBUG("Node %d or their public_key not found\n", toNode); return false; } - if (!crypto->setDHKey(toNode)) { + if (!crypto->setDHPublicKey(remotePublic.bytes)) { return false; } + crypto->hash(shared_key, 32); initNonce(fromNode, packetNum, extraNonceTmp); // Calculate the shared secret with the destination node and encrypt @@ -97,27 +95,27 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_ * * @param bytes is updated in place */ -bool CryptoEngine::decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut) +bool CryptoEngine::decryptCurve25519(uint32_t fromNode, meshtastic_UserLite_public_key_t remotePublic, uint64_t packetNum, + size_t numBytes, uint8_t *bytes, uint8_t *bytesOut) { uint8_t *auth; // set to last 8 bytes of text? uint32_t extraNonce; // pointer was not really used auth = bytes + numBytes - 12; memcpy(&extraNonce, auth + 8, sizeof(uint32_t)); // do not use dereference on potential non aligned pointers : (uint32_t *)(auth + 8); -#ifndef PIO_UNIT_TESTING LOG_INFO("Random nonce value: %d\n", extraNonce); - meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(fromNode); - if (node == nullptr || node->num < 1 || node->user.public_key.size == 0) { + if (remotePublic.size == 0) { LOG_DEBUG("Node or its public key not found in database\n"); return false; } // Calculate the shared secret with the sending node and decrypt - if (!crypto->setDHKey(fromNode)) { + if (!crypto->setDHPublicKey(remotePublic.bytes)) { return false; } -#endif + crypto->hash(shared_key, 32); + initNonce(fromNode, packetNum, extraNonce); printBytes("Attempting decrypt using nonce: ", nonce, 13); printBytes("Attempting decrypt using shared_key starting with: ", shared_key, 8); @@ -128,38 +126,6 @@ void CryptoEngine::setDHPrivateKey(uint8_t *_private_key) { memcpy(private_key, _private_key, 32); } -/** - * Set the PKI key used for encrypt, decrypt. - * - * @param nodeNum the node number of the node who's public key we want to use - */ -bool CryptoEngine::setDHKey(uint32_t nodeNum) -{ - meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeNum); - if (node->num < 1 || node->user.public_key.size == 0) { - LOG_DEBUG("Node %d or their public_key not found\n", nodeNum); - return false; - } - printBytes("Generating DH with remote pubkey: ", node->user.public_key.bytes, 32); - printBytes("And local pubkey: ", config.security.public_key.bytes, 32); - if (!setDHPublicKey(node->user.public_key.bytes)) - return false; - - // printBytes("DH Output: ", shared_key, 32); - - /** - * D.J. Bernstein reccomends hashing the shared key. We want to do this because there are - * at least 128 bits of entropy in the 256-bit output of the DH key exchange, but we don't - * really know where. If you extract, for instance, the first 128 bits with basic truncation, - * then you don't know if you got all of your 128 entropy bits, or less, possibly much less. - * - * No exploitable bias is really known at that point, but we know enough to be wary. - * Hashing the DH output is a simple and safe way to gather all the entropy and spread - * it around as needed. - */ - crypto->hash(shared_key, 32); - return true; -} /** * Hash arbitrary data using SHA256. diff --git a/src/mesh/CryptoEngine.h b/src/mesh/CryptoEngine.h index 4c2fc19d9..32862d95c 100644 --- a/src/mesh/CryptoEngine.h +++ b/src/mesh/CryptoEngine.h @@ -39,10 +39,10 @@ class CryptoEngine #endif void clearKeys(); void setDHPrivateKey(uint8_t *_private_key); - virtual bool encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes, - uint8_t *bytesOut); - virtual bool decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut); - bool setDHKey(uint32_t nodeNum); + virtual bool encryptCurve25519(uint32_t toNode, uint32_t fromNode, meshtastic_UserLite_public_key_t remotePublic, + uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut); + virtual bool decryptCurve25519(uint32_t fromNode, meshtastic_UserLite_public_key_t remotePublic, uint64_t packetNum, + size_t numBytes, uint8_t *bytes, uint8_t *bytesOut); virtual bool setDHPublicKey(uint8_t *publicKey); virtual void hash(uint8_t *bytes, size_t numBytes); diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index a2e684a90..43ac19607 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -333,7 +333,8 @@ bool perhapsDecode(meshtastic_MeshPacket *p) rawSize > MESHTASTIC_PKC_OVERHEAD) { LOG_DEBUG("Attempting PKI decryption\n"); - if (crypto->decryptCurve25519(p->from, p->id, rawSize, ScratchEncrypted, bytes)) { + if (crypto->decryptCurve25519(p->from, nodeDB->getMeshNode(p->from)->user.public_key, p->id, rawSize, ScratchEncrypted, + bytes)) { LOG_INFO("PKI Decryption worked!\n"); memset(&p->decoded, 0, sizeof(p->decoded)); rawSize -= MESHTASTIC_PKC_OVERHEAD; @@ -507,7 +508,7 @@ meshtastic_Routing_Error perhapsEncode(meshtastic_MeshPacket *p) *node->user.public_key.bytes); return meshtastic_Routing_Error_PKI_FAILED; } - crypto->encryptCurve25519(p->to, getFrom(p), p->id, numbytes, bytes, ScratchEncrypted); + crypto->encryptCurve25519(p->to, getFrom(p), node->user.public_key, p->id, numbytes, bytes, ScratchEncrypted); numbytes += MESHTASTIC_PKC_OVERHEAD; memcpy(p->encrypted.bytes, ScratchEncrypted, numbytes); p->channel = 0; diff --git a/test/test_crypto/test_main.cpp b/test/test_crypto/test_main.cpp index cbe366048..652d5dbcb 100644 --- a/test/test_crypto/test_main.cpp +++ b/test/test_crypto/test_main.cpp @@ -111,7 +111,7 @@ void test_DH25519(void) void test_PKC_Decrypt(void) { uint8_t private_key[32]; - uint8_t public_key[32]; + meshtastic_UserLite_public_key_t public_key; uint8_t expected_shared[32]; uint8_t expected_decrypted[32]; uint8_t radioBytes[128] __attribute__((__aligned__)); @@ -119,7 +119,8 @@ void test_PKC_Decrypt(void) uint8_t expected_nonce[16]; uint32_t fromNode; - HexToBytes(public_key, "db18fc50eea47f00251cb784819a3cf5fc361882597f589f0d7ff820e8064457"); + HexToBytes(public_key.bytes, "db18fc50eea47f00251cb784819a3cf5fc361882597f589f0d7ff820e8064457"); + public_key.size = 32; HexToBytes(private_key, "a00330633e63522f8a4d81ec6d9d1e6617f6c8ffd3a4c698229537d44e522277"); HexToBytes(expected_shared, "777b1545c9d6f9a2"); HexToBytes(expected_decrypted, "08011204746573744800"); @@ -127,9 +128,9 @@ void test_PKC_Decrypt(void) HexToBytes(expected_nonce, "62d6b213036a792b2909000000"); fromNode = 0x0929; crypto->setDHPrivateKey(private_key); - TEST_ASSERT(crypto->setDHPublicKey(public_key)); - crypto->hash(crypto->shared_key, 32); - crypto->decryptCurve25519(fromNode, 0x13b2d662, 22, radioBytes + 16, decrypted); + // TEST_ASSERT(crypto->setDHPublicKey(public_key)); + // crypto->hash(crypto->shared_key, 32); + crypto->decryptCurve25519(fromNode, public_key, 0x13b2d662, 22, radioBytes + 16, decrypted); TEST_ASSERT_EQUAL_MEMORY(expected_shared, crypto->shared_key, 8); TEST_ASSERT_EQUAL_MEMORY(expected_nonce, crypto->nonce, 13); From 3b21856a769bc84288b8c00d4feb8aa468da3b5d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 06:45:22 -0500 Subject: [PATCH 06/15] [create-pull-request] automated change (#5019) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/admin.pb.h | 23 ++- .../generated/meshtastic/device_ui.pb.cpp | 22 ++ src/mesh/generated/meshtastic/device_ui.pb.h | 190 ++++++++++++++++++ src/mesh/generated/meshtastic/mesh.pb.h | 8 +- src/mesh/generated/meshtastic/telemetry.pb.h | 23 ++- 6 files changed, 255 insertions(+), 13 deletions(-) create mode 100644 src/mesh/generated/meshtastic/device_ui.pb.cpp create mode 100644 src/mesh/generated/meshtastic/device_ui.pb.h diff --git a/protobufs b/protobufs index c9ae7fd47..647081c7f 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit c9ae7fd478bffe5f954b30de6cb140821fe9ff52 +Subproject commit 647081c7fafcb048f537c6443c799602c36708b5 diff --git a/src/mesh/generated/meshtastic/admin.pb.h b/src/mesh/generated/meshtastic/admin.pb.h index bf81269b4..d802eb3da 100644 --- a/src/mesh/generated/meshtastic/admin.pb.h +++ b/src/mesh/generated/meshtastic/admin.pb.h @@ -9,6 +9,7 @@ #include "meshtastic/connection_status.pb.h" #include "meshtastic/mesh.pb.h" #include "meshtastic/module_config.pb.h" +#include "meshtastic/device_ui.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -34,7 +35,9 @@ typedef enum _meshtastic_AdminMessage_ConfigType { /* TODO: REPLACE */ meshtastic_AdminMessage_ConfigType_SECURITY_CONFIG = 7, /* */ - meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG = 8 + meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG = 8, + /* device-ui config */ + meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG = 9 } meshtastic_AdminMessage_ConfigType; /* TODO: REPLACE */ @@ -171,6 +174,12 @@ typedef struct _meshtastic_AdminMessage { /* Set time only on the node Convenience method to set the time on the node (as Net quality) without any other position data */ uint32_t set_time_only; + /* Tell the node to send the stored ui data. */ + bool get_ui_config_request; + /* Reply stored device ui data. */ + meshtastic_DeviceUIConfig get_ui_config_response; + /* Tell the node to store UI data persistently. */ + meshtastic_DeviceUIConfig store_ui_config; /* Begins an edit transaction for config, module config, owner, and channel settings changes This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) */ bool begin_edit_settings; @@ -206,8 +215,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_AdminMessage_ConfigType_MIN meshtastic_AdminMessage_ConfigType_DEVICE_CONFIG -#define _meshtastic_AdminMessage_ConfigType_MAX meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG -#define _meshtastic_AdminMessage_ConfigType_ARRAYSIZE ((meshtastic_AdminMessage_ConfigType)(meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG+1)) +#define _meshtastic_AdminMessage_ConfigType_MAX meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG +#define _meshtastic_AdminMessage_ConfigType_ARRAYSIZE ((meshtastic_AdminMessage_ConfigType)(meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG+1)) #define _meshtastic_AdminMessage_ModuleConfigType_MIN meshtastic_AdminMessage_ModuleConfigType_MQTT_CONFIG #define _meshtastic_AdminMessage_ModuleConfigType_MAX meshtastic_AdminMessage_ModuleConfigType_PAXCOUNTER_CONFIG @@ -267,6 +276,9 @@ extern "C" { #define meshtastic_AdminMessage_set_fixed_position_tag 41 #define meshtastic_AdminMessage_remove_fixed_position_tag 42 #define meshtastic_AdminMessage_set_time_only_tag 43 +#define meshtastic_AdminMessage_get_ui_config_request_tag 44 +#define meshtastic_AdminMessage_get_ui_config_response_tag 45 +#define meshtastic_AdminMessage_store_ui_config_tag 46 #define meshtastic_AdminMessage_begin_edit_settings_tag 64 #define meshtastic_AdminMessage_commit_edit_settings_tag 65 #define meshtastic_AdminMessage_factory_reset_device_tag 94 @@ -314,6 +326,9 @@ X(a, STATIC, ONEOF, UINT32, (payload_variant,remove_favorite_node,remove_ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_fixed_position,set_fixed_position), 41) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,remove_fixed_position,remove_fixed_position), 42) \ X(a, STATIC, ONEOF, FIXED32, (payload_variant,set_time_only,set_time_only), 43) \ +X(a, STATIC, ONEOF, BOOL, (payload_variant,get_ui_config_request,get_ui_config_request), 44) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_ui_config_response,get_ui_config_response), 45) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,store_ui_config,store_ui_config), 46) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,begin_edit_settings,begin_edit_settings), 64) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,commit_edit_settings,commit_edit_settings), 65) \ X(a, STATIC, ONEOF, INT32, (payload_variant,factory_reset_device,factory_reset_device), 94) \ @@ -339,6 +354,8 @@ X(a, STATIC, SINGULAR, BYTES, session_passkey, 101) #define meshtastic_AdminMessage_payload_variant_set_config_MSGTYPE meshtastic_Config #define meshtastic_AdminMessage_payload_variant_set_module_config_MSGTYPE meshtastic_ModuleConfig #define meshtastic_AdminMessage_payload_variant_set_fixed_position_MSGTYPE meshtastic_Position +#define meshtastic_AdminMessage_payload_variant_get_ui_config_response_MSGTYPE meshtastic_DeviceUIConfig +#define meshtastic_AdminMessage_payload_variant_store_ui_config_MSGTYPE meshtastic_DeviceUIConfig #define meshtastic_HamParameters_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, STRING, call_sign, 1) \ diff --git a/src/mesh/generated/meshtastic/device_ui.pb.cpp b/src/mesh/generated/meshtastic/device_ui.pb.cpp new file mode 100644 index 000000000..6e0cf0cc8 --- /dev/null +++ b/src/mesh/generated/meshtastic/device_ui.pb.cpp @@ -0,0 +1,22 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.9 */ + +#include "meshtastic/device_ui.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(meshtastic_DeviceUIConfig, meshtastic_DeviceUIConfig, AUTO) + + +PB_BIND(meshtastic_NodeFilter, meshtastic_NodeFilter, AUTO) + + +PB_BIND(meshtastic_NodeHighlight, meshtastic_NodeHighlight, AUTO) + + + + + + + diff --git a/src/mesh/generated/meshtastic/device_ui.pb.h b/src/mesh/generated/meshtastic/device_ui.pb.h new file mode 100644 index 000000000..014be465d --- /dev/null +++ b/src/mesh/generated/meshtastic/device_ui.pb.h @@ -0,0 +1,190 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.9 */ + +#ifndef PB_MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Enum definitions */ +typedef enum _meshtastic_Theme { + /* Dark */ + meshtastic_Theme_DARK = 0, + /* Light */ + meshtastic_Theme_LIGHT = 1, + /* Red */ + meshtastic_Theme_RED = 2 +} meshtastic_Theme; + +/* Localization */ +typedef enum _meshtastic_Language { + /* English */ + meshtastic_Language_ENGLISH = 0, + /* French */ + meshtastic_Language_FRENCH = 1, + /* German */ + meshtastic_Language_GERMAN = 2, + /* Italian */ + meshtastic_Language_ITALIAN = 3, + /* Portuguese */ + meshtastic_Language_PORTUGUESE = 4, + /* Spanish */ + meshtastic_Language_SPANISH = 5 +} meshtastic_Language; + +/* Struct definitions */ +typedef struct _meshtastic_NodeFilter { + /* Filter unknown nodes */ + bool unknown_switch; + /* Filter offline nodes */ + bool offline_switch; + /* Filter nodes w/o public key */ + bool public_key_switch; + /* Filter based on hops away */ + int8_t hops_away; + /* Filter nodes w/o position */ + bool position_switch; + /* Filter nodes by matching name string */ + char node_name[16]; +} meshtastic_NodeFilter; + +typedef struct _meshtastic_NodeHighlight { + /* Hightlight nodes w/ active chat */ + bool chat_switch; + /* Highlight nodes w/ position */ + bool position_switch; + /* Highlight nodes w/ telemetry data */ + bool telemetry_switch; + /* Highlight nodes w/ iaq data */ + bool iaq_switch; + /* Highlight nodes by matching name string */ + char node_name[16]; +} meshtastic_NodeHighlight; + +typedef struct _meshtastic_DeviceUIConfig { + /* TFT display brightness 1..255 */ + uint8_t screen_brightness; + /* Screen timeout 0..900 */ + uint16_t screen_timeout; + /* Screen lock enabled */ + bool screen_lock; + /* Color theme */ + meshtastic_Theme theme; + /* Audible message alert enabled */ + bool alert_enabled; + /* Localization */ + meshtastic_Language language; + /* Node list filter */ + bool has_node_filter; + meshtastic_NodeFilter node_filter; + /* Node list highlightening */ + bool has_node_highlight; + meshtastic_NodeHighlight node_highlight; +} meshtastic_DeviceUIConfig; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Helper constants for enums */ +#define _meshtastic_Theme_MIN meshtastic_Theme_DARK +#define _meshtastic_Theme_MAX meshtastic_Theme_RED +#define _meshtastic_Theme_ARRAYSIZE ((meshtastic_Theme)(meshtastic_Theme_RED+1)) + +#define _meshtastic_Language_MIN meshtastic_Language_ENGLISH +#define _meshtastic_Language_MAX meshtastic_Language_SPANISH +#define _meshtastic_Language_ARRAYSIZE ((meshtastic_Language)(meshtastic_Language_SPANISH+1)) + +#define meshtastic_DeviceUIConfig_theme_ENUMTYPE meshtastic_Theme +#define meshtastic_DeviceUIConfig_language_ENUMTYPE meshtastic_Language + + + + +/* Initializer values for message structs */ +#define meshtastic_DeviceUIConfig_init_default {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_default, false, meshtastic_NodeHighlight_init_default} +#define meshtastic_NodeFilter_init_default {0, 0, 0, 0, 0, ""} +#define meshtastic_NodeHighlight_init_default {0, 0, 0, 0, ""} +#define meshtastic_DeviceUIConfig_init_zero {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_zero, false, meshtastic_NodeHighlight_init_zero} +#define meshtastic_NodeFilter_init_zero {0, 0, 0, 0, 0, ""} +#define meshtastic_NodeHighlight_init_zero {0, 0, 0, 0, ""} + +/* Field tags (for use in manual encoding/decoding) */ +#define meshtastic_NodeFilter_unknown_switch_tag 1 +#define meshtastic_NodeFilter_offline_switch_tag 2 +#define meshtastic_NodeFilter_public_key_switch_tag 3 +#define meshtastic_NodeFilter_hops_away_tag 4 +#define meshtastic_NodeFilter_position_switch_tag 5 +#define meshtastic_NodeFilter_node_name_tag 6 +#define meshtastic_NodeHighlight_chat_switch_tag 1 +#define meshtastic_NodeHighlight_position_switch_tag 2 +#define meshtastic_NodeHighlight_telemetry_switch_tag 3 +#define meshtastic_NodeHighlight_iaq_switch_tag 4 +#define meshtastic_NodeHighlight_node_name_tag 5 +#define meshtastic_DeviceUIConfig_screen_brightness_tag 1 +#define meshtastic_DeviceUIConfig_screen_timeout_tag 2 +#define meshtastic_DeviceUIConfig_screen_lock_tag 3 +#define meshtastic_DeviceUIConfig_theme_tag 4 +#define meshtastic_DeviceUIConfig_alert_enabled_tag 5 +#define meshtastic_DeviceUIConfig_language_tag 6 +#define meshtastic_DeviceUIConfig_node_filter_tag 7 +#define meshtastic_DeviceUIConfig_node_highlight_tag 8 + +/* Struct field encoding specification for nanopb */ +#define meshtastic_DeviceUIConfig_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, screen_brightness, 1) \ +X(a, STATIC, SINGULAR, UINT32, screen_timeout, 2) \ +X(a, STATIC, SINGULAR, BOOL, screen_lock, 3) \ +X(a, STATIC, SINGULAR, UENUM, theme, 4) \ +X(a, STATIC, SINGULAR, BOOL, alert_enabled, 5) \ +X(a, STATIC, SINGULAR, UENUM, language, 6) \ +X(a, STATIC, OPTIONAL, MESSAGE, node_filter, 7) \ +X(a, STATIC, OPTIONAL, MESSAGE, node_highlight, 8) +#define meshtastic_DeviceUIConfig_CALLBACK NULL +#define meshtastic_DeviceUIConfig_DEFAULT NULL +#define meshtastic_DeviceUIConfig_node_filter_MSGTYPE meshtastic_NodeFilter +#define meshtastic_DeviceUIConfig_node_highlight_MSGTYPE meshtastic_NodeHighlight + +#define meshtastic_NodeFilter_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, unknown_switch, 1) \ +X(a, STATIC, SINGULAR, BOOL, offline_switch, 2) \ +X(a, STATIC, SINGULAR, BOOL, public_key_switch, 3) \ +X(a, STATIC, SINGULAR, INT32, hops_away, 4) \ +X(a, STATIC, SINGULAR, BOOL, position_switch, 5) \ +X(a, STATIC, SINGULAR, STRING, node_name, 6) +#define meshtastic_NodeFilter_CALLBACK NULL +#define meshtastic_NodeFilter_DEFAULT NULL + +#define meshtastic_NodeHighlight_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, chat_switch, 1) \ +X(a, STATIC, SINGULAR, BOOL, position_switch, 2) \ +X(a, STATIC, SINGULAR, BOOL, telemetry_switch, 3) \ +X(a, STATIC, SINGULAR, BOOL, iaq_switch, 4) \ +X(a, STATIC, SINGULAR, STRING, node_name, 5) +#define meshtastic_NodeHighlight_CALLBACK NULL +#define meshtastic_NodeHighlight_DEFAULT NULL + +extern const pb_msgdesc_t meshtastic_DeviceUIConfig_msg; +extern const pb_msgdesc_t meshtastic_NodeFilter_msg; +extern const pb_msgdesc_t meshtastic_NodeHighlight_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define meshtastic_DeviceUIConfig_fields &meshtastic_DeviceUIConfig_msg +#define meshtastic_NodeFilter_fields &meshtastic_NodeFilter_msg +#define meshtastic_NodeHighlight_fields &meshtastic_NodeHighlight_msg + +/* Maximum encoded size of messages (where known) */ +#define MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_MAX_SIZE meshtastic_DeviceUIConfig_size +#define meshtastic_DeviceUIConfig_size 80 +#define meshtastic_NodeFilter_size 36 +#define meshtastic_NodeHighlight_size 25 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index fb154e9d5..313719d9b 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -10,6 +10,7 @@ #include "meshtastic/portnums.pb.h" #include "meshtastic/telemetry.pb.h" #include "meshtastic/xmodem.pb.h" +#include "meshtastic/device_ui.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -940,6 +941,8 @@ typedef struct _meshtastic_FromRadio { meshtastic_FileInfo fileInfo; /* Notification message to the client */ meshtastic_ClientNotification clientNotification; + /* Persistent data for device-ui */ + meshtastic_DeviceUIConfig deviceuiConfig; }; } meshtastic_FromRadio; @@ -1292,6 +1295,7 @@ extern "C" { #define meshtastic_FromRadio_mqttClientProxyMessage_tag 14 #define meshtastic_FromRadio_fileInfo_tag 15 #define meshtastic_FromRadio_clientNotification_tag 16 +#define meshtastic_FromRadio_deviceuiConfig_tag 17 #define meshtastic_ToRadio_packet_tag 1 #define meshtastic_ToRadio_want_config_id_tag 3 #define meshtastic_ToRadio_disconnect_tag 4 @@ -1478,7 +1482,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket), X(a, STATIC, ONEOF, MESSAGE, (payload_variant,metadata,metadata), 13) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,mqttClientProxyMessage,mqttClientProxyMessage), 14) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,fileInfo,fileInfo), 15) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNotification), 16) +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNotification), 16) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,deviceuiConfig,deviceuiConfig), 17) #define meshtastic_FromRadio_CALLBACK NULL #define meshtastic_FromRadio_DEFAULT NULL #define meshtastic_FromRadio_payload_variant_packet_MSGTYPE meshtastic_MeshPacket @@ -1494,6 +1499,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNot #define meshtastic_FromRadio_payload_variant_mqttClientProxyMessage_MSGTYPE meshtastic_MqttClientProxyMessage #define meshtastic_FromRadio_payload_variant_fileInfo_MSGTYPE meshtastic_FileInfo #define meshtastic_FromRadio_payload_variant_clientNotification_MSGTYPE meshtastic_ClientNotification +#define meshtastic_FromRadio_payload_variant_deviceuiConfig_MSGTYPE meshtastic_DeviceUIConfig #define meshtastic_ClientNotification_FIELDLIST(X, a) \ X(a, STATIC, OPTIONAL, UINT32, reply_id, 1) \ diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index a33988129..309c01dc7 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -74,8 +74,10 @@ typedef enum _meshtastic_TelemetrySensorType { meshtastic_TelemetrySensorType_CUSTOM_SENSOR = 29, /* MAX30102 Pulse Oximeter and Heart-Rate Sensor */ meshtastic_TelemetrySensorType_MAX30102 = 30, - /* MLX90614 non-contact IR temperature sensor. */ - meshtastic_TelemetrySensorType_MLX90614 = 31 + /* MLX90614 non-contact IR temperature sensor */ + meshtastic_TelemetrySensorType_MLX90614 = 31, + /* SCD40/SCD41 CO2, humidity, temperature sensor */ + meshtastic_TelemetrySensorType_SCD4X = 32 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -215,6 +217,9 @@ typedef struct _meshtastic_AirQualityMetrics { /* 10.0um Particle Count */ bool has_particles_100um; uint32_t particles_100um; + /* 10.0um Particle Count */ + bool has_co2; + uint32_t co2; } meshtastic_AirQualityMetrics; /* Local device mesh statistics */ @@ -294,8 +299,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_MLX90614 -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_MLX90614+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SCD4X +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SCD4X+1)) @@ -310,7 +315,7 @@ extern "C" { #define meshtastic_DeviceMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_PowerMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_HealthMetrics_init_default {false, 0, false, 0, false, 0} #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} @@ -318,7 +323,7 @@ extern "C" { #define meshtastic_DeviceMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_PowerMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_HealthMetrics_init_zero {false, 0, false, 0, false, 0} #define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}} @@ -365,6 +370,7 @@ extern "C" { #define meshtastic_AirQualityMetrics_particles_25um_tag 10 #define meshtastic_AirQualityMetrics_particles_50um_tag 11 #define meshtastic_AirQualityMetrics_particles_100um_tag 12 +#define meshtastic_AirQualityMetrics_co2_tag 13 #define meshtastic_LocalStats_uptime_seconds_tag 1 #define meshtastic_LocalStats_channel_utilization_tag 2 #define meshtastic_LocalStats_air_util_tx_tag 3 @@ -442,7 +448,8 @@ X(a, STATIC, OPTIONAL, UINT32, particles_05um, 8) \ X(a, STATIC, OPTIONAL, UINT32, particles_10um, 9) \ X(a, STATIC, OPTIONAL, UINT32, particles_25um, 10) \ X(a, STATIC, OPTIONAL, UINT32, particles_50um, 11) \ -X(a, STATIC, OPTIONAL, UINT32, particles_100um, 12) +X(a, STATIC, OPTIONAL, UINT32, particles_100um, 12) \ +X(a, STATIC, OPTIONAL, UINT32, co2, 13) #define meshtastic_AirQualityMetrics_CALLBACK NULL #define meshtastic_AirQualityMetrics_DEFAULT NULL @@ -512,7 +519,7 @@ extern const pb_msgdesc_t meshtastic_Nau7802Config_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size -#define meshtastic_AirQualityMetrics_size 72 +#define meshtastic_AirQualityMetrics_size 78 #define meshtastic_DeviceMetrics_size 27 #define meshtastic_EnvironmentMetrics_size 85 #define meshtastic_HealthMetrics_size 11 From 1b04d41b9a7039ee441d9bd552e203db0a1d78cf Mon Sep 17 00:00:00 2001 From: Tom Fifield Date: Thu, 10 Oct 2024 19:45:40 +0800 Subject: [PATCH 07/15] Fix U-Blox detection code. (#5014) Recently there have been reports of intermittent difficulties detecting U-Blox chips. This patch proposes a new approach that should be more reliable. Previously we were fighting with NMEA messages to try and send binary commands. We unusually also tried changing the Baud rate of U-Blox chips, something we don't do with any other GPS. It turns out U-Blox has another method to disable NMEA messages. PUBX,40 is a text-based command, supported on all the U-Blox versions we care about that can set the rate of NMEA messages to zero. This is what we attempt to do with all other GPS and it works quite well. So this patch alters the probe code to: 1. Remove UBX binary code to stop NMEA messages 2. Remove code that tries to reset UBX chips to 9600 baud 3. Add UBX proprietary text commands messages to stop the NMEA flood 4. Improve log strings sent to the user. Tested on Ublox 6, Ublox 9, and Ublox 10 on multiple devices. Also tested on several devices with non-Ublox GPS to ensure it does not interfere with their detection (heltec-wireless-tracker, wio-tracker-wm11110) --- src/gps/GPS.cpp | 47 +++++++++++++---------------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 54a55c867..41061bee8 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1106,6 +1106,11 @@ GnssModel_t GPS::probe(int serialSpeed) // Close all NMEA sentences, valid for L76K, ATGM336H (and likely other AT6558 devices) _serial_gps->write("$PCAS03,0,0,0,0,0,0,0,0,0,0,,,0,0*02\r\n"); delay(20); + // Close NMEA sequences on Ublox + _serial_gps->write("$PUBX,40,GLL,0,0,0,0,0,0*5C\r\n"); + _serial_gps->write("$PUBX,40,GSV,0,0,0,0,0,0*59\r\n"); + _serial_gps->write("$PUBX,40,VTG,0,0,0,0,0,0*5E\r\n"); + delay(20); // Unicore UFirebirdII Series: UC6580, UM620, UM621, UM670A, UM680A, or UM681A PROBE_SIMPLE("UC6580", "$PDTINFO", "UC6580", GNSS_MODEL_UC6580, 500); @@ -1138,35 +1143,10 @@ GnssModel_t GPS::probe(int serialSpeed) // Check that the returned response class and message ID are correct GPS_RESPONSE response = getACK(0x06, 0x08, 750); if (response == GNSS_RESPONSE_NONE) { - LOG_WARN("Failed to find UBlox & MTK GNSS Module using baudrate %d\n", serialSpeed); + LOG_WARN("Failed to find GNSS Module (baudrate %d)\n", serialSpeed); return GNSS_MODEL_UNKNOWN; } else if (response == GNSS_RESPONSE_FRAME_ERRORS) { - LOG_INFO("UBlox Frame Errors using baudrate %d\n", serialSpeed); - } else if (response == GNSS_RESPONSE_OK) { - LOG_INFO("Found a UBlox Module using baudrate %d\n", serialSpeed); - } - - // tips: NMEA Only should not be set here, otherwise initializing Ublox gnss module again after - // setting will not output command messages in UART1, resulting in unrecognized module information - if (serialSpeed != 9600) { - // Set the UART port to 9600 - uint8_t _message_prt[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, - 0x80, 0x25, 0x00, 0x00, 0x07, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - UBXChecksum(_message_prt, sizeof(_message_prt)); - _serial_gps->write(_message_prt, sizeof(_message_prt)); - delay(500); - serialSpeed = 9600; -#if defined(ARCH_NRF52) || defined(ARCH_PORTDUINO) || defined(ARCH_STM32WL) - _serial_gps->end(); - _serial_gps->begin(serialSpeed); -#elif defined(ARCH_RP2040) - _serial_gps->end(); - _serial_gps->setFIFOSize(256); - _serial_gps->begin(serialSpeed); -#else - _serial_gps->updateBaudRate(serialSpeed); -#endif - delay(200); + LOG_INFO("UBlox Frame Errors (baudrate %d)\n", serialSpeed); } memset(buffer, 0, sizeof(buffer)); @@ -1218,12 +1198,6 @@ GnssModel_t GPS::probe(int serialSpeed) for (int i = 0; i < info.extensionNo; ++i) { if (!strncmp(info.extension[i], "MOD=", 4)) { strncpy((char *)buffer, &(info.extension[i][4]), sizeof(buffer)); - // LOG_DEBUG("GetModel:%s\n", (char *)buffer); - if (strlen((char *)buffer)) { - LOG_INFO("%s detected, using GNSS_MODEL_UBLOX\n", (char *)buffer); - } else { - LOG_INFO("Generic Ublox detected, using GNSS_MODEL_UBLOX\n"); - } } else if (!strncmp(info.extension[i], "PROTVER", 7)) { char *ptr = nullptr; memset(buffer, 0, sizeof(buffer)); @@ -1238,18 +1212,23 @@ GnssModel_t GPS::probe(int serialSpeed) } } if (strncmp(info.hwVersion, "00040007", 8) == 0) { + LOG_INFO(DETECTED_MESSAGE, "U-blox 6", GNSS_MODEL_UBLOX6); return GNSS_MODEL_UBLOX6; } else if (strncmp(info.hwVersion, "00070000", 8) == 0) { + LOG_INFO(DETECTED_MESSAGE, "U-blox 7", GNSS_MODEL_UBLOX7); return GNSS_MODEL_UBLOX7; } else if (strncmp(info.hwVersion, "00080000", 8) == 0) { + LOG_INFO(DETECTED_MESSAGE, "U-blox 8", GNSS_MODEL_UBLOX8); return GNSS_MODEL_UBLOX8; } else if (strncmp(info.hwVersion, "00190000", 8) == 0) { + LOG_INFO(DETECTED_MESSAGE, "U-blox 9", GNSS_MODEL_UBLOX9); return GNSS_MODEL_UBLOX9; } else if (strncmp(info.hwVersion, "000A0000", 8) == 0) { + LOG_INFO(DETECTED_MESSAGE, "U-blox 10", GNSS_MODEL_UBLOX10); return GNSS_MODEL_UBLOX10; } } - + LOG_WARN("Failed to find GNSS Module (baudrate %d)\n", serialSpeed); return GNSS_MODEL_UNKNOWN; } From f82585d9b07e4467b74790d1e292a85a4343840e Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 10 Oct 2024 14:06:47 -0500 Subject: [PATCH 08/15] Add localhost exception for dontMqttMeBro (#5023) --- src/mqtt/MQTT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index c0399af38..264c68563 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -544,7 +544,7 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket & } // check for the lowest bit of the data bitfield set false, and the use of one of the default keys. - if (!isFromUs(&mp_decoded) && mp_decoded.decoded.has_bitfield && + if (!isFromUs(&mp_decoded) && strcmp(moduleConfig.mqtt.address, "127.0.0.1") != 0 && mp_decoded.decoded.has_bitfield && !(mp_decoded.decoded.bitfield & BITFIELD_OK_TO_MQTT_MASK) && (ch.settings.psk.size < 2 || (ch.settings.psk.size == 16 && memcmp(ch.settings.psk.bytes, defaultpsk, 16)) || (ch.settings.psk.size == 32 && memcmp(ch.settings.psk.bytes, eventpsk, 32)))) { From f5f9fd54a14548c9ebc32be6229c89a20907bd0e Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 10 Oct 2024 14:58:06 -0500 Subject: [PATCH 09/15] Revert "[create-pull-request] automated change (#5019)" (#5026) This reverts commit 3b21856a769bc84288b8c00d4feb8aa468da3b5d. --- protobufs | 2 +- src/mesh/generated/meshtastic/admin.pb.h | 23 +-- .../generated/meshtastic/device_ui.pb.cpp | 22 -- src/mesh/generated/meshtastic/device_ui.pb.h | 190 ------------------ src/mesh/generated/meshtastic/mesh.pb.h | 8 +- src/mesh/generated/meshtastic/telemetry.pb.h | 23 +-- 6 files changed, 13 insertions(+), 255 deletions(-) delete mode 100644 src/mesh/generated/meshtastic/device_ui.pb.cpp delete mode 100644 src/mesh/generated/meshtastic/device_ui.pb.h diff --git a/protobufs b/protobufs index 647081c7f..c9ae7fd47 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 647081c7fafcb048f537c6443c799602c36708b5 +Subproject commit c9ae7fd478bffe5f954b30de6cb140821fe9ff52 diff --git a/src/mesh/generated/meshtastic/admin.pb.h b/src/mesh/generated/meshtastic/admin.pb.h index d802eb3da..bf81269b4 100644 --- a/src/mesh/generated/meshtastic/admin.pb.h +++ b/src/mesh/generated/meshtastic/admin.pb.h @@ -9,7 +9,6 @@ #include "meshtastic/connection_status.pb.h" #include "meshtastic/mesh.pb.h" #include "meshtastic/module_config.pb.h" -#include "meshtastic/device_ui.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -35,9 +34,7 @@ typedef enum _meshtastic_AdminMessage_ConfigType { /* TODO: REPLACE */ meshtastic_AdminMessage_ConfigType_SECURITY_CONFIG = 7, /* */ - meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG = 8, - /* device-ui config */ - meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG = 9 + meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG = 8 } meshtastic_AdminMessage_ConfigType; /* TODO: REPLACE */ @@ -174,12 +171,6 @@ typedef struct _meshtastic_AdminMessage { /* Set time only on the node Convenience method to set the time on the node (as Net quality) without any other position data */ uint32_t set_time_only; - /* Tell the node to send the stored ui data. */ - bool get_ui_config_request; - /* Reply stored device ui data. */ - meshtastic_DeviceUIConfig get_ui_config_response; - /* Tell the node to store UI data persistently. */ - meshtastic_DeviceUIConfig store_ui_config; /* Begins an edit transaction for config, module config, owner, and channel settings changes This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) */ bool begin_edit_settings; @@ -215,8 +206,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_AdminMessage_ConfigType_MIN meshtastic_AdminMessage_ConfigType_DEVICE_CONFIG -#define _meshtastic_AdminMessage_ConfigType_MAX meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG -#define _meshtastic_AdminMessage_ConfigType_ARRAYSIZE ((meshtastic_AdminMessage_ConfigType)(meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG+1)) +#define _meshtastic_AdminMessage_ConfigType_MAX meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG +#define _meshtastic_AdminMessage_ConfigType_ARRAYSIZE ((meshtastic_AdminMessage_ConfigType)(meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG+1)) #define _meshtastic_AdminMessage_ModuleConfigType_MIN meshtastic_AdminMessage_ModuleConfigType_MQTT_CONFIG #define _meshtastic_AdminMessage_ModuleConfigType_MAX meshtastic_AdminMessage_ModuleConfigType_PAXCOUNTER_CONFIG @@ -276,9 +267,6 @@ extern "C" { #define meshtastic_AdminMessage_set_fixed_position_tag 41 #define meshtastic_AdminMessage_remove_fixed_position_tag 42 #define meshtastic_AdminMessage_set_time_only_tag 43 -#define meshtastic_AdminMessage_get_ui_config_request_tag 44 -#define meshtastic_AdminMessage_get_ui_config_response_tag 45 -#define meshtastic_AdminMessage_store_ui_config_tag 46 #define meshtastic_AdminMessage_begin_edit_settings_tag 64 #define meshtastic_AdminMessage_commit_edit_settings_tag 65 #define meshtastic_AdminMessage_factory_reset_device_tag 94 @@ -326,9 +314,6 @@ X(a, STATIC, ONEOF, UINT32, (payload_variant,remove_favorite_node,remove_ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_fixed_position,set_fixed_position), 41) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,remove_fixed_position,remove_fixed_position), 42) \ X(a, STATIC, ONEOF, FIXED32, (payload_variant,set_time_only,set_time_only), 43) \ -X(a, STATIC, ONEOF, BOOL, (payload_variant,get_ui_config_request,get_ui_config_request), 44) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_ui_config_response,get_ui_config_response), 45) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,store_ui_config,store_ui_config), 46) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,begin_edit_settings,begin_edit_settings), 64) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,commit_edit_settings,commit_edit_settings), 65) \ X(a, STATIC, ONEOF, INT32, (payload_variant,factory_reset_device,factory_reset_device), 94) \ @@ -354,8 +339,6 @@ X(a, STATIC, SINGULAR, BYTES, session_passkey, 101) #define meshtastic_AdminMessage_payload_variant_set_config_MSGTYPE meshtastic_Config #define meshtastic_AdminMessage_payload_variant_set_module_config_MSGTYPE meshtastic_ModuleConfig #define meshtastic_AdminMessage_payload_variant_set_fixed_position_MSGTYPE meshtastic_Position -#define meshtastic_AdminMessage_payload_variant_get_ui_config_response_MSGTYPE meshtastic_DeviceUIConfig -#define meshtastic_AdminMessage_payload_variant_store_ui_config_MSGTYPE meshtastic_DeviceUIConfig #define meshtastic_HamParameters_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, STRING, call_sign, 1) \ diff --git a/src/mesh/generated/meshtastic/device_ui.pb.cpp b/src/mesh/generated/meshtastic/device_ui.pb.cpp deleted file mode 100644 index 6e0cf0cc8..000000000 --- a/src/mesh/generated/meshtastic/device_ui.pb.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.4.9 */ - -#include "meshtastic/device_ui.pb.h" -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -PB_BIND(meshtastic_DeviceUIConfig, meshtastic_DeviceUIConfig, AUTO) - - -PB_BIND(meshtastic_NodeFilter, meshtastic_NodeFilter, AUTO) - - -PB_BIND(meshtastic_NodeHighlight, meshtastic_NodeHighlight, AUTO) - - - - - - - diff --git a/src/mesh/generated/meshtastic/device_ui.pb.h b/src/mesh/generated/meshtastic/device_ui.pb.h deleted file mode 100644 index 014be465d..000000000 --- a/src/mesh/generated/meshtastic/device_ui.pb.h +++ /dev/null @@ -1,190 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.4.9 */ - -#ifndef PB_MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_INCLUDED -#define PB_MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_INCLUDED -#include - -#if PB_PROTO_HEADER_VERSION != 40 -#error Regenerate this file with the current version of nanopb generator. -#endif - -/* Enum definitions */ -typedef enum _meshtastic_Theme { - /* Dark */ - meshtastic_Theme_DARK = 0, - /* Light */ - meshtastic_Theme_LIGHT = 1, - /* Red */ - meshtastic_Theme_RED = 2 -} meshtastic_Theme; - -/* Localization */ -typedef enum _meshtastic_Language { - /* English */ - meshtastic_Language_ENGLISH = 0, - /* French */ - meshtastic_Language_FRENCH = 1, - /* German */ - meshtastic_Language_GERMAN = 2, - /* Italian */ - meshtastic_Language_ITALIAN = 3, - /* Portuguese */ - meshtastic_Language_PORTUGUESE = 4, - /* Spanish */ - meshtastic_Language_SPANISH = 5 -} meshtastic_Language; - -/* Struct definitions */ -typedef struct _meshtastic_NodeFilter { - /* Filter unknown nodes */ - bool unknown_switch; - /* Filter offline nodes */ - bool offline_switch; - /* Filter nodes w/o public key */ - bool public_key_switch; - /* Filter based on hops away */ - int8_t hops_away; - /* Filter nodes w/o position */ - bool position_switch; - /* Filter nodes by matching name string */ - char node_name[16]; -} meshtastic_NodeFilter; - -typedef struct _meshtastic_NodeHighlight { - /* Hightlight nodes w/ active chat */ - bool chat_switch; - /* Highlight nodes w/ position */ - bool position_switch; - /* Highlight nodes w/ telemetry data */ - bool telemetry_switch; - /* Highlight nodes w/ iaq data */ - bool iaq_switch; - /* Highlight nodes by matching name string */ - char node_name[16]; -} meshtastic_NodeHighlight; - -typedef struct _meshtastic_DeviceUIConfig { - /* TFT display brightness 1..255 */ - uint8_t screen_brightness; - /* Screen timeout 0..900 */ - uint16_t screen_timeout; - /* Screen lock enabled */ - bool screen_lock; - /* Color theme */ - meshtastic_Theme theme; - /* Audible message alert enabled */ - bool alert_enabled; - /* Localization */ - meshtastic_Language language; - /* Node list filter */ - bool has_node_filter; - meshtastic_NodeFilter node_filter; - /* Node list highlightening */ - bool has_node_highlight; - meshtastic_NodeHighlight node_highlight; -} meshtastic_DeviceUIConfig; - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Helper constants for enums */ -#define _meshtastic_Theme_MIN meshtastic_Theme_DARK -#define _meshtastic_Theme_MAX meshtastic_Theme_RED -#define _meshtastic_Theme_ARRAYSIZE ((meshtastic_Theme)(meshtastic_Theme_RED+1)) - -#define _meshtastic_Language_MIN meshtastic_Language_ENGLISH -#define _meshtastic_Language_MAX meshtastic_Language_SPANISH -#define _meshtastic_Language_ARRAYSIZE ((meshtastic_Language)(meshtastic_Language_SPANISH+1)) - -#define meshtastic_DeviceUIConfig_theme_ENUMTYPE meshtastic_Theme -#define meshtastic_DeviceUIConfig_language_ENUMTYPE meshtastic_Language - - - - -/* Initializer values for message structs */ -#define meshtastic_DeviceUIConfig_init_default {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_default, false, meshtastic_NodeHighlight_init_default} -#define meshtastic_NodeFilter_init_default {0, 0, 0, 0, 0, ""} -#define meshtastic_NodeHighlight_init_default {0, 0, 0, 0, ""} -#define meshtastic_DeviceUIConfig_init_zero {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_zero, false, meshtastic_NodeHighlight_init_zero} -#define meshtastic_NodeFilter_init_zero {0, 0, 0, 0, 0, ""} -#define meshtastic_NodeHighlight_init_zero {0, 0, 0, 0, ""} - -/* Field tags (for use in manual encoding/decoding) */ -#define meshtastic_NodeFilter_unknown_switch_tag 1 -#define meshtastic_NodeFilter_offline_switch_tag 2 -#define meshtastic_NodeFilter_public_key_switch_tag 3 -#define meshtastic_NodeFilter_hops_away_tag 4 -#define meshtastic_NodeFilter_position_switch_tag 5 -#define meshtastic_NodeFilter_node_name_tag 6 -#define meshtastic_NodeHighlight_chat_switch_tag 1 -#define meshtastic_NodeHighlight_position_switch_tag 2 -#define meshtastic_NodeHighlight_telemetry_switch_tag 3 -#define meshtastic_NodeHighlight_iaq_switch_tag 4 -#define meshtastic_NodeHighlight_node_name_tag 5 -#define meshtastic_DeviceUIConfig_screen_brightness_tag 1 -#define meshtastic_DeviceUIConfig_screen_timeout_tag 2 -#define meshtastic_DeviceUIConfig_screen_lock_tag 3 -#define meshtastic_DeviceUIConfig_theme_tag 4 -#define meshtastic_DeviceUIConfig_alert_enabled_tag 5 -#define meshtastic_DeviceUIConfig_language_tag 6 -#define meshtastic_DeviceUIConfig_node_filter_tag 7 -#define meshtastic_DeviceUIConfig_node_highlight_tag 8 - -/* Struct field encoding specification for nanopb */ -#define meshtastic_DeviceUIConfig_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, UINT32, screen_brightness, 1) \ -X(a, STATIC, SINGULAR, UINT32, screen_timeout, 2) \ -X(a, STATIC, SINGULAR, BOOL, screen_lock, 3) \ -X(a, STATIC, SINGULAR, UENUM, theme, 4) \ -X(a, STATIC, SINGULAR, BOOL, alert_enabled, 5) \ -X(a, STATIC, SINGULAR, UENUM, language, 6) \ -X(a, STATIC, OPTIONAL, MESSAGE, node_filter, 7) \ -X(a, STATIC, OPTIONAL, MESSAGE, node_highlight, 8) -#define meshtastic_DeviceUIConfig_CALLBACK NULL -#define meshtastic_DeviceUIConfig_DEFAULT NULL -#define meshtastic_DeviceUIConfig_node_filter_MSGTYPE meshtastic_NodeFilter -#define meshtastic_DeviceUIConfig_node_highlight_MSGTYPE meshtastic_NodeHighlight - -#define meshtastic_NodeFilter_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, BOOL, unknown_switch, 1) \ -X(a, STATIC, SINGULAR, BOOL, offline_switch, 2) \ -X(a, STATIC, SINGULAR, BOOL, public_key_switch, 3) \ -X(a, STATIC, SINGULAR, INT32, hops_away, 4) \ -X(a, STATIC, SINGULAR, BOOL, position_switch, 5) \ -X(a, STATIC, SINGULAR, STRING, node_name, 6) -#define meshtastic_NodeFilter_CALLBACK NULL -#define meshtastic_NodeFilter_DEFAULT NULL - -#define meshtastic_NodeHighlight_FIELDLIST(X, a) \ -X(a, STATIC, SINGULAR, BOOL, chat_switch, 1) \ -X(a, STATIC, SINGULAR, BOOL, position_switch, 2) \ -X(a, STATIC, SINGULAR, BOOL, telemetry_switch, 3) \ -X(a, STATIC, SINGULAR, BOOL, iaq_switch, 4) \ -X(a, STATIC, SINGULAR, STRING, node_name, 5) -#define meshtastic_NodeHighlight_CALLBACK NULL -#define meshtastic_NodeHighlight_DEFAULT NULL - -extern const pb_msgdesc_t meshtastic_DeviceUIConfig_msg; -extern const pb_msgdesc_t meshtastic_NodeFilter_msg; -extern const pb_msgdesc_t meshtastic_NodeHighlight_msg; - -/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ -#define meshtastic_DeviceUIConfig_fields &meshtastic_DeviceUIConfig_msg -#define meshtastic_NodeFilter_fields &meshtastic_NodeFilter_msg -#define meshtastic_NodeHighlight_fields &meshtastic_NodeHighlight_msg - -/* Maximum encoded size of messages (where known) */ -#define MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_MAX_SIZE meshtastic_DeviceUIConfig_size -#define meshtastic_DeviceUIConfig_size 80 -#define meshtastic_NodeFilter_size 36 -#define meshtastic_NodeHighlight_size 25 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 313719d9b..fb154e9d5 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -10,7 +10,6 @@ #include "meshtastic/portnums.pb.h" #include "meshtastic/telemetry.pb.h" #include "meshtastic/xmodem.pb.h" -#include "meshtastic/device_ui.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -941,8 +940,6 @@ typedef struct _meshtastic_FromRadio { meshtastic_FileInfo fileInfo; /* Notification message to the client */ meshtastic_ClientNotification clientNotification; - /* Persistent data for device-ui */ - meshtastic_DeviceUIConfig deviceuiConfig; }; } meshtastic_FromRadio; @@ -1295,7 +1292,6 @@ extern "C" { #define meshtastic_FromRadio_mqttClientProxyMessage_tag 14 #define meshtastic_FromRadio_fileInfo_tag 15 #define meshtastic_FromRadio_clientNotification_tag 16 -#define meshtastic_FromRadio_deviceuiConfig_tag 17 #define meshtastic_ToRadio_packet_tag 1 #define meshtastic_ToRadio_want_config_id_tag 3 #define meshtastic_ToRadio_disconnect_tag 4 @@ -1482,8 +1478,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket), X(a, STATIC, ONEOF, MESSAGE, (payload_variant,metadata,metadata), 13) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,mqttClientProxyMessage,mqttClientProxyMessage), 14) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,fileInfo,fileInfo), 15) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNotification), 16) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,deviceuiConfig,deviceuiConfig), 17) +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNotification), 16) #define meshtastic_FromRadio_CALLBACK NULL #define meshtastic_FromRadio_DEFAULT NULL #define meshtastic_FromRadio_payload_variant_packet_MSGTYPE meshtastic_MeshPacket @@ -1499,7 +1494,6 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,deviceuiConfig,deviceuiConfi #define meshtastic_FromRadio_payload_variant_mqttClientProxyMessage_MSGTYPE meshtastic_MqttClientProxyMessage #define meshtastic_FromRadio_payload_variant_fileInfo_MSGTYPE meshtastic_FileInfo #define meshtastic_FromRadio_payload_variant_clientNotification_MSGTYPE meshtastic_ClientNotification -#define meshtastic_FromRadio_payload_variant_deviceuiConfig_MSGTYPE meshtastic_DeviceUIConfig #define meshtastic_ClientNotification_FIELDLIST(X, a) \ X(a, STATIC, OPTIONAL, UINT32, reply_id, 1) \ diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index 309c01dc7..a33988129 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -74,10 +74,8 @@ typedef enum _meshtastic_TelemetrySensorType { meshtastic_TelemetrySensorType_CUSTOM_SENSOR = 29, /* MAX30102 Pulse Oximeter and Heart-Rate Sensor */ meshtastic_TelemetrySensorType_MAX30102 = 30, - /* MLX90614 non-contact IR temperature sensor */ - meshtastic_TelemetrySensorType_MLX90614 = 31, - /* SCD40/SCD41 CO2, humidity, temperature sensor */ - meshtastic_TelemetrySensorType_SCD4X = 32 + /* MLX90614 non-contact IR temperature sensor. */ + meshtastic_TelemetrySensorType_MLX90614 = 31 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -217,9 +215,6 @@ typedef struct _meshtastic_AirQualityMetrics { /* 10.0um Particle Count */ bool has_particles_100um; uint32_t particles_100um; - /* 10.0um Particle Count */ - bool has_co2; - uint32_t co2; } meshtastic_AirQualityMetrics; /* Local device mesh statistics */ @@ -299,8 +294,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SCD4X -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SCD4X+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_MLX90614 +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_MLX90614+1)) @@ -315,7 +310,7 @@ extern "C" { #define meshtastic_DeviceMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_PowerMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_HealthMetrics_init_default {false, 0, false, 0, false, 0} #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} @@ -323,7 +318,7 @@ extern "C" { #define meshtastic_DeviceMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_PowerMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_HealthMetrics_init_zero {false, 0, false, 0, false, 0} #define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}} @@ -370,7 +365,6 @@ extern "C" { #define meshtastic_AirQualityMetrics_particles_25um_tag 10 #define meshtastic_AirQualityMetrics_particles_50um_tag 11 #define meshtastic_AirQualityMetrics_particles_100um_tag 12 -#define meshtastic_AirQualityMetrics_co2_tag 13 #define meshtastic_LocalStats_uptime_seconds_tag 1 #define meshtastic_LocalStats_channel_utilization_tag 2 #define meshtastic_LocalStats_air_util_tx_tag 3 @@ -448,8 +442,7 @@ X(a, STATIC, OPTIONAL, UINT32, particles_05um, 8) \ X(a, STATIC, OPTIONAL, UINT32, particles_10um, 9) \ X(a, STATIC, OPTIONAL, UINT32, particles_25um, 10) \ X(a, STATIC, OPTIONAL, UINT32, particles_50um, 11) \ -X(a, STATIC, OPTIONAL, UINT32, particles_100um, 12) \ -X(a, STATIC, OPTIONAL, UINT32, co2, 13) +X(a, STATIC, OPTIONAL, UINT32, particles_100um, 12) #define meshtastic_AirQualityMetrics_CALLBACK NULL #define meshtastic_AirQualityMetrics_DEFAULT NULL @@ -519,7 +512,7 @@ extern const pb_msgdesc_t meshtastic_Nau7802Config_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size -#define meshtastic_AirQualityMetrics_size 78 +#define meshtastic_AirQualityMetrics_size 72 #define meshtastic_DeviceMetrics_size 27 #define meshtastic_EnvironmentMetrics_size 85 #define meshtastic_HealthMetrics_size 11 From b76979941045b8fa312600ec2d72dd126bd02798 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 10 Oct 2024 14:58:30 -0500 Subject: [PATCH 10/15] Update version.properties --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index be97dacb5..df7ba70c7 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 5 -build = 7 +build = 6 From e8f287a36f5dc3b817d940036f1b931176628348 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 10 Oct 2024 14:58:42 -0500 Subject: [PATCH 11/15] Fixes critical error rendering before screen thread is running (#5024) * Fixes critical error rendering before screen thread is running * Fix GPS thread crashing on probe code attempting to %s print an enum * 10 --- src/gps/GPS.cpp | 12 ++++++------ src/mesh/NodeDB.cpp | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 41061bee8..5863fc343 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1212,19 +1212,19 @@ GnssModel_t GPS::probe(int serialSpeed) } } if (strncmp(info.hwVersion, "00040007", 8) == 0) { - LOG_INFO(DETECTED_MESSAGE, "U-blox 6", GNSS_MODEL_UBLOX6); + LOG_INFO(DETECTED_MESSAGE, "U-blox 6", "6"); return GNSS_MODEL_UBLOX6; } else if (strncmp(info.hwVersion, "00070000", 8) == 0) { - LOG_INFO(DETECTED_MESSAGE, "U-blox 7", GNSS_MODEL_UBLOX7); + LOG_INFO(DETECTED_MESSAGE, "U-blox 7", "7"); return GNSS_MODEL_UBLOX7; } else if (strncmp(info.hwVersion, "00080000", 8) == 0) { - LOG_INFO(DETECTED_MESSAGE, "U-blox 8", GNSS_MODEL_UBLOX8); + LOG_INFO(DETECTED_MESSAGE, "U-blox 8", "8"); return GNSS_MODEL_UBLOX8; } else if (strncmp(info.hwVersion, "00190000", 8) == 0) { - LOG_INFO(DETECTED_MESSAGE, "U-blox 9", GNSS_MODEL_UBLOX9); + LOG_INFO(DETECTED_MESSAGE, "U-blox 9", "9"); return GNSS_MODEL_UBLOX9; } else if (strncmp(info.hwVersion, "000A0000", 8) == 0) { - LOG_INFO(DETECTED_MESSAGE, "U-blox 10", GNSS_MODEL_UBLOX10); + LOG_INFO(DETECTED_MESSAGE, "U-blox 10", "10"); return GNSS_MODEL_UBLOX10; } } @@ -1693,4 +1693,4 @@ void GPS::toggleGpsMode() enable(); } } -#endif // Exclude GPS +#endif // Exclude GPS \ No newline at end of file diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 0d9605161..c52dda19d 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1206,7 +1206,8 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co { // Print error to screen and serial port String lcd = String("Critical error ") + code + "!\n"; - screen->print(lcd.c_str()); + if (screen) + screen->print(lcd.c_str()); if (filename) { LOG_ERROR("NOTE! Recording critical error %d at %s:%lu\n", code, filename, address); } else { @@ -1222,4 +1223,4 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co LOG_ERROR("A critical failure occurred, portduino is exiting..."); exit(2); #endif -} +} \ No newline at end of file From d55c08d5cdfd2b3e98b250abd156945fd5e3e8d3 Mon Sep 17 00:00:00 2001 From: GUVWAF <78759985+GUVWAF@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:11:58 +0200 Subject: [PATCH 12/15] Uplink DMs not to us if MQTT encryption enabled (#5025) * Uplink DMs not to us if MQTT encryption enabled * Only really need to try uplinking encrypted packet if MQTT encryption is enabled * Add log about publishing nothing when packet is not decrypted and encryption_enabled is false * Improve comment --- src/mesh/Router.cpp | 6 +++++- src/mqtt/MQTT.cpp | 27 ++++++++++++++------------- src/mqtt/MQTT.h | 4 ++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 43ac19607..48d58ee3c 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -613,8 +613,12 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) MeshModule::callModules(*p, src); #if !MESHTASTIC_EXCLUDE_MQTT + // Mark as pki_encrypted if it is not yet decoded and MQTT encryption is also enabled, hash matches and it's a DM not to + // us (because we would be able to decrypt it) + if (!decoded && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && p->to != NODENUM_BROADCAST && !isToUs(p)) + p_encrypted->pki_encrypted = true; // After potentially altering it, publish received message to MQTT if we're not the original transmitter of the packet - if ((decoded || (p->channel == 0x00 && p->to != NODENUM_BROADCAST)) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt) + if ((decoded || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt) mqtt->onSend(*p_encrypted, *p, p->channel); #endif } diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 264c68563..dd00a336f 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -524,9 +524,9 @@ void MQTT::publishQueuedMessages() } } -void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket &mp_decoded, ChannelIndex chIndex) +void MQTT::onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_MeshPacket &mp_decoded, ChannelIndex chIndex) { - if (mp.via_mqtt) + if (mp_encrypted.via_mqtt) return; // Don't send messages that came from MQTT back into MQTT bool uplinkEnabled = false; for (int i = 0; i <= 7; i++) { @@ -537,12 +537,8 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket & return; // no channels have an uplink enabled auto &ch = channels.getByIndex(chIndex); - if (!mp.pki_encrypted) { - if (mp_decoded.which_payload_variant != meshtastic_MeshPacket_decoded_tag) { - LOG_CRIT("MQTT::onSend(): mp_decoded isn't actually decoded\n"); - return; - } - + // mp_decoded will not be decoded when it's PKI encrypted and not directed to us + if (mp_decoded.which_payload_variant == meshtastic_MeshPacket_decoded_tag) { // check for the lowest bit of the data bitfield set false, and the use of one of the default keys. if (!isFromUs(&mp_decoded) && strcmp(moduleConfig.mqtt.address, "127.0.0.1") != 0 && mp_decoded.decoded.has_bitfield && !(mp_decoded.decoded.bitfield & BITFIELD_OK_TO_MQTT_MASK) && @@ -559,8 +555,11 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket & return; } } - if (mp.pki_encrypted || ch.settings.uplink_enabled) { - const char *channelId = mp.pki_encrypted ? "PKI" : channels.getGlobalId(chIndex); + // Either encrypted packet (we couldn't decrypt) is marked as pki_encrypted, or we could decode the PKI encrypted packet + bool isPKIEncrypted = mp_encrypted.pki_encrypted || mp_decoded.pki_encrypted; + // If it was to a channel, check uplink enabled, else must be pki_encrypted + if ((ch.settings.uplink_enabled && !isPKIEncrypted) || isPKIEncrypted) { + const char *channelId = isPKIEncrypted ? "PKI" : channels.getGlobalId(chIndex); meshtastic_ServiceEnvelope *env = mqttPool.allocZeroed(); env->channel_id = (char *)channelId; @@ -568,12 +567,14 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket & LOG_DEBUG("MQTT onSend - Publishing "); if (moduleConfig.mqtt.encryption_enabled) { - env->packet = (meshtastic_MeshPacket *)∓ + env->packet = (meshtastic_MeshPacket *)&mp_encrypted; LOG_DEBUG("encrypted message\n"); - } else if (mp_decoded.which_payload_variant == - meshtastic_MeshPacket_decoded_tag) { // Don't upload a still-encrypted PKI packet + } else if (mp_decoded.which_payload_variant == meshtastic_MeshPacket_decoded_tag) { env->packet = (meshtastic_MeshPacket *)&mp_decoded; LOG_DEBUG("portnum %i message\n", env->packet->decoded.portnum); + } else { + LOG_DEBUG("nothing, pkt not decrypted\n"); + return; // Don't upload a still-encrypted PKI packet if not encryption_enabled } if (moduleConfig.mqtt.proxy_to_client_enabled || this->isConnectedDirectly()) { diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index c827e12ca..83adc8fd2 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -52,14 +52,14 @@ class MQTT : private concurrency::OSThread /** * Publish a packet on the global MQTT server. - * @param mp the encrypted packet to publish + * @param mp_encrypted the encrypted packet to publish * @param mp_decoded the decrypted packet to publish * @param chIndex the index of the channel for this message * * Note: for messages we are forwarding on the mesh that we can't find the channel for (because we don't have the keys), we * can not forward those messages to the cloud - because no way to find a global channel ID. */ - void onSend(const meshtastic_MeshPacket &mp, const meshtastic_MeshPacket &mp_decoded, ChannelIndex chIndex); + void onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_MeshPacket &mp_decoded, ChannelIndex chIndex); /** Attempt to connect to server if necessary */ From 8ab772221dd0a79cba1e0273ebfb26a461745a90 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:29:29 -0500 Subject: [PATCH 13/15] [create-pull-request] automated change (#5027) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index df7ba70c7..be97dacb5 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 5 -build = 6 +build = 7 From cc87002a8a95815c3b186a7515b4454b2a6d581c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 18:31:20 -0500 Subject: [PATCH 14/15] [create-pull-request] automated change (#5028) Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --- protobufs | 2 +- src/mesh/generated/meshtastic/admin.pb.h | 23 ++- .../generated/meshtastic/device_ui.pb.cpp | 22 ++ src/mesh/generated/meshtastic/device_ui.pb.h | 190 ++++++++++++++++++ src/mesh/generated/meshtastic/mesh.pb.h | 8 +- src/mesh/generated/meshtastic/telemetry.pb.h | 23 ++- 6 files changed, 255 insertions(+), 13 deletions(-) create mode 100644 src/mesh/generated/meshtastic/device_ui.pb.cpp create mode 100644 src/mesh/generated/meshtastic/device_ui.pb.h diff --git a/protobufs b/protobufs index c9ae7fd47..647081c7f 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit c9ae7fd478bffe5f954b30de6cb140821fe9ff52 +Subproject commit 647081c7fafcb048f537c6443c799602c36708b5 diff --git a/src/mesh/generated/meshtastic/admin.pb.h b/src/mesh/generated/meshtastic/admin.pb.h index bf81269b4..d802eb3da 100644 --- a/src/mesh/generated/meshtastic/admin.pb.h +++ b/src/mesh/generated/meshtastic/admin.pb.h @@ -9,6 +9,7 @@ #include "meshtastic/connection_status.pb.h" #include "meshtastic/mesh.pb.h" #include "meshtastic/module_config.pb.h" +#include "meshtastic/device_ui.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -34,7 +35,9 @@ typedef enum _meshtastic_AdminMessage_ConfigType { /* TODO: REPLACE */ meshtastic_AdminMessage_ConfigType_SECURITY_CONFIG = 7, /* */ - meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG = 8 + meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG = 8, + /* device-ui config */ + meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG = 9 } meshtastic_AdminMessage_ConfigType; /* TODO: REPLACE */ @@ -171,6 +174,12 @@ typedef struct _meshtastic_AdminMessage { /* Set time only on the node Convenience method to set the time on the node (as Net quality) without any other position data */ uint32_t set_time_only; + /* Tell the node to send the stored ui data. */ + bool get_ui_config_request; + /* Reply stored device ui data. */ + meshtastic_DeviceUIConfig get_ui_config_response; + /* Tell the node to store UI data persistently. */ + meshtastic_DeviceUIConfig store_ui_config; /* Begins an edit transaction for config, module config, owner, and channel settings changes This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) */ bool begin_edit_settings; @@ -206,8 +215,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_AdminMessage_ConfigType_MIN meshtastic_AdminMessage_ConfigType_DEVICE_CONFIG -#define _meshtastic_AdminMessage_ConfigType_MAX meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG -#define _meshtastic_AdminMessage_ConfigType_ARRAYSIZE ((meshtastic_AdminMessage_ConfigType)(meshtastic_AdminMessage_ConfigType_SESSIONKEY_CONFIG+1)) +#define _meshtastic_AdminMessage_ConfigType_MAX meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG +#define _meshtastic_AdminMessage_ConfigType_ARRAYSIZE ((meshtastic_AdminMessage_ConfigType)(meshtastic_AdminMessage_ConfigType_DEVICEUI_CONFIG+1)) #define _meshtastic_AdminMessage_ModuleConfigType_MIN meshtastic_AdminMessage_ModuleConfigType_MQTT_CONFIG #define _meshtastic_AdminMessage_ModuleConfigType_MAX meshtastic_AdminMessage_ModuleConfigType_PAXCOUNTER_CONFIG @@ -267,6 +276,9 @@ extern "C" { #define meshtastic_AdminMessage_set_fixed_position_tag 41 #define meshtastic_AdminMessage_remove_fixed_position_tag 42 #define meshtastic_AdminMessage_set_time_only_tag 43 +#define meshtastic_AdminMessage_get_ui_config_request_tag 44 +#define meshtastic_AdminMessage_get_ui_config_response_tag 45 +#define meshtastic_AdminMessage_store_ui_config_tag 46 #define meshtastic_AdminMessage_begin_edit_settings_tag 64 #define meshtastic_AdminMessage_commit_edit_settings_tag 65 #define meshtastic_AdminMessage_factory_reset_device_tag 94 @@ -314,6 +326,9 @@ X(a, STATIC, ONEOF, UINT32, (payload_variant,remove_favorite_node,remove_ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,set_fixed_position,set_fixed_position), 41) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,remove_fixed_position,remove_fixed_position), 42) \ X(a, STATIC, ONEOF, FIXED32, (payload_variant,set_time_only,set_time_only), 43) \ +X(a, STATIC, ONEOF, BOOL, (payload_variant,get_ui_config_request,get_ui_config_request), 44) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,get_ui_config_response,get_ui_config_response), 45) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,store_ui_config,store_ui_config), 46) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,begin_edit_settings,begin_edit_settings), 64) \ X(a, STATIC, ONEOF, BOOL, (payload_variant,commit_edit_settings,commit_edit_settings), 65) \ X(a, STATIC, ONEOF, INT32, (payload_variant,factory_reset_device,factory_reset_device), 94) \ @@ -339,6 +354,8 @@ X(a, STATIC, SINGULAR, BYTES, session_passkey, 101) #define meshtastic_AdminMessage_payload_variant_set_config_MSGTYPE meshtastic_Config #define meshtastic_AdminMessage_payload_variant_set_module_config_MSGTYPE meshtastic_ModuleConfig #define meshtastic_AdminMessage_payload_variant_set_fixed_position_MSGTYPE meshtastic_Position +#define meshtastic_AdminMessage_payload_variant_get_ui_config_response_MSGTYPE meshtastic_DeviceUIConfig +#define meshtastic_AdminMessage_payload_variant_store_ui_config_MSGTYPE meshtastic_DeviceUIConfig #define meshtastic_HamParameters_FIELDLIST(X, a) \ X(a, STATIC, SINGULAR, STRING, call_sign, 1) \ diff --git a/src/mesh/generated/meshtastic/device_ui.pb.cpp b/src/mesh/generated/meshtastic/device_ui.pb.cpp new file mode 100644 index 000000000..6e0cf0cc8 --- /dev/null +++ b/src/mesh/generated/meshtastic/device_ui.pb.cpp @@ -0,0 +1,22 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.9 */ + +#include "meshtastic/device_ui.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(meshtastic_DeviceUIConfig, meshtastic_DeviceUIConfig, AUTO) + + +PB_BIND(meshtastic_NodeFilter, meshtastic_NodeFilter, AUTO) + + +PB_BIND(meshtastic_NodeHighlight, meshtastic_NodeHighlight, AUTO) + + + + + + + diff --git a/src/mesh/generated/meshtastic/device_ui.pb.h b/src/mesh/generated/meshtastic/device_ui.pb.h new file mode 100644 index 000000000..014be465d --- /dev/null +++ b/src/mesh/generated/meshtastic/device_ui.pb.h @@ -0,0 +1,190 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.9 */ + +#ifndef PB_MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_INCLUDED +#define PB_MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Enum definitions */ +typedef enum _meshtastic_Theme { + /* Dark */ + meshtastic_Theme_DARK = 0, + /* Light */ + meshtastic_Theme_LIGHT = 1, + /* Red */ + meshtastic_Theme_RED = 2 +} meshtastic_Theme; + +/* Localization */ +typedef enum _meshtastic_Language { + /* English */ + meshtastic_Language_ENGLISH = 0, + /* French */ + meshtastic_Language_FRENCH = 1, + /* German */ + meshtastic_Language_GERMAN = 2, + /* Italian */ + meshtastic_Language_ITALIAN = 3, + /* Portuguese */ + meshtastic_Language_PORTUGUESE = 4, + /* Spanish */ + meshtastic_Language_SPANISH = 5 +} meshtastic_Language; + +/* Struct definitions */ +typedef struct _meshtastic_NodeFilter { + /* Filter unknown nodes */ + bool unknown_switch; + /* Filter offline nodes */ + bool offline_switch; + /* Filter nodes w/o public key */ + bool public_key_switch; + /* Filter based on hops away */ + int8_t hops_away; + /* Filter nodes w/o position */ + bool position_switch; + /* Filter nodes by matching name string */ + char node_name[16]; +} meshtastic_NodeFilter; + +typedef struct _meshtastic_NodeHighlight { + /* Hightlight nodes w/ active chat */ + bool chat_switch; + /* Highlight nodes w/ position */ + bool position_switch; + /* Highlight nodes w/ telemetry data */ + bool telemetry_switch; + /* Highlight nodes w/ iaq data */ + bool iaq_switch; + /* Highlight nodes by matching name string */ + char node_name[16]; +} meshtastic_NodeHighlight; + +typedef struct _meshtastic_DeviceUIConfig { + /* TFT display brightness 1..255 */ + uint8_t screen_brightness; + /* Screen timeout 0..900 */ + uint16_t screen_timeout; + /* Screen lock enabled */ + bool screen_lock; + /* Color theme */ + meshtastic_Theme theme; + /* Audible message alert enabled */ + bool alert_enabled; + /* Localization */ + meshtastic_Language language; + /* Node list filter */ + bool has_node_filter; + meshtastic_NodeFilter node_filter; + /* Node list highlightening */ + bool has_node_highlight; + meshtastic_NodeHighlight node_highlight; +} meshtastic_DeviceUIConfig; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Helper constants for enums */ +#define _meshtastic_Theme_MIN meshtastic_Theme_DARK +#define _meshtastic_Theme_MAX meshtastic_Theme_RED +#define _meshtastic_Theme_ARRAYSIZE ((meshtastic_Theme)(meshtastic_Theme_RED+1)) + +#define _meshtastic_Language_MIN meshtastic_Language_ENGLISH +#define _meshtastic_Language_MAX meshtastic_Language_SPANISH +#define _meshtastic_Language_ARRAYSIZE ((meshtastic_Language)(meshtastic_Language_SPANISH+1)) + +#define meshtastic_DeviceUIConfig_theme_ENUMTYPE meshtastic_Theme +#define meshtastic_DeviceUIConfig_language_ENUMTYPE meshtastic_Language + + + + +/* Initializer values for message structs */ +#define meshtastic_DeviceUIConfig_init_default {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_default, false, meshtastic_NodeHighlight_init_default} +#define meshtastic_NodeFilter_init_default {0, 0, 0, 0, 0, ""} +#define meshtastic_NodeHighlight_init_default {0, 0, 0, 0, ""} +#define meshtastic_DeviceUIConfig_init_zero {0, 0, 0, _meshtastic_Theme_MIN, 0, _meshtastic_Language_MIN, false, meshtastic_NodeFilter_init_zero, false, meshtastic_NodeHighlight_init_zero} +#define meshtastic_NodeFilter_init_zero {0, 0, 0, 0, 0, ""} +#define meshtastic_NodeHighlight_init_zero {0, 0, 0, 0, ""} + +/* Field tags (for use in manual encoding/decoding) */ +#define meshtastic_NodeFilter_unknown_switch_tag 1 +#define meshtastic_NodeFilter_offline_switch_tag 2 +#define meshtastic_NodeFilter_public_key_switch_tag 3 +#define meshtastic_NodeFilter_hops_away_tag 4 +#define meshtastic_NodeFilter_position_switch_tag 5 +#define meshtastic_NodeFilter_node_name_tag 6 +#define meshtastic_NodeHighlight_chat_switch_tag 1 +#define meshtastic_NodeHighlight_position_switch_tag 2 +#define meshtastic_NodeHighlight_telemetry_switch_tag 3 +#define meshtastic_NodeHighlight_iaq_switch_tag 4 +#define meshtastic_NodeHighlight_node_name_tag 5 +#define meshtastic_DeviceUIConfig_screen_brightness_tag 1 +#define meshtastic_DeviceUIConfig_screen_timeout_tag 2 +#define meshtastic_DeviceUIConfig_screen_lock_tag 3 +#define meshtastic_DeviceUIConfig_theme_tag 4 +#define meshtastic_DeviceUIConfig_alert_enabled_tag 5 +#define meshtastic_DeviceUIConfig_language_tag 6 +#define meshtastic_DeviceUIConfig_node_filter_tag 7 +#define meshtastic_DeviceUIConfig_node_highlight_tag 8 + +/* Struct field encoding specification for nanopb */ +#define meshtastic_DeviceUIConfig_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, UINT32, screen_brightness, 1) \ +X(a, STATIC, SINGULAR, UINT32, screen_timeout, 2) \ +X(a, STATIC, SINGULAR, BOOL, screen_lock, 3) \ +X(a, STATIC, SINGULAR, UENUM, theme, 4) \ +X(a, STATIC, SINGULAR, BOOL, alert_enabled, 5) \ +X(a, STATIC, SINGULAR, UENUM, language, 6) \ +X(a, STATIC, OPTIONAL, MESSAGE, node_filter, 7) \ +X(a, STATIC, OPTIONAL, MESSAGE, node_highlight, 8) +#define meshtastic_DeviceUIConfig_CALLBACK NULL +#define meshtastic_DeviceUIConfig_DEFAULT NULL +#define meshtastic_DeviceUIConfig_node_filter_MSGTYPE meshtastic_NodeFilter +#define meshtastic_DeviceUIConfig_node_highlight_MSGTYPE meshtastic_NodeHighlight + +#define meshtastic_NodeFilter_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, unknown_switch, 1) \ +X(a, STATIC, SINGULAR, BOOL, offline_switch, 2) \ +X(a, STATIC, SINGULAR, BOOL, public_key_switch, 3) \ +X(a, STATIC, SINGULAR, INT32, hops_away, 4) \ +X(a, STATIC, SINGULAR, BOOL, position_switch, 5) \ +X(a, STATIC, SINGULAR, STRING, node_name, 6) +#define meshtastic_NodeFilter_CALLBACK NULL +#define meshtastic_NodeFilter_DEFAULT NULL + +#define meshtastic_NodeHighlight_FIELDLIST(X, a) \ +X(a, STATIC, SINGULAR, BOOL, chat_switch, 1) \ +X(a, STATIC, SINGULAR, BOOL, position_switch, 2) \ +X(a, STATIC, SINGULAR, BOOL, telemetry_switch, 3) \ +X(a, STATIC, SINGULAR, BOOL, iaq_switch, 4) \ +X(a, STATIC, SINGULAR, STRING, node_name, 5) +#define meshtastic_NodeHighlight_CALLBACK NULL +#define meshtastic_NodeHighlight_DEFAULT NULL + +extern const pb_msgdesc_t meshtastic_DeviceUIConfig_msg; +extern const pb_msgdesc_t meshtastic_NodeFilter_msg; +extern const pb_msgdesc_t meshtastic_NodeHighlight_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define meshtastic_DeviceUIConfig_fields &meshtastic_DeviceUIConfig_msg +#define meshtastic_NodeFilter_fields &meshtastic_NodeFilter_msg +#define meshtastic_NodeHighlight_fields &meshtastic_NodeHighlight_msg + +/* Maximum encoded size of messages (where known) */ +#define MESHTASTIC_MESHTASTIC_DEVICE_UI_PB_H_MAX_SIZE meshtastic_DeviceUIConfig_size +#define meshtastic_DeviceUIConfig_size 80 +#define meshtastic_NodeFilter_size 36 +#define meshtastic_NodeHighlight_size 25 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index fb154e9d5..313719d9b 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -10,6 +10,7 @@ #include "meshtastic/portnums.pb.h" #include "meshtastic/telemetry.pb.h" #include "meshtastic/xmodem.pb.h" +#include "meshtastic/device_ui.pb.h" #if PB_PROTO_HEADER_VERSION != 40 #error Regenerate this file with the current version of nanopb generator. @@ -940,6 +941,8 @@ typedef struct _meshtastic_FromRadio { meshtastic_FileInfo fileInfo; /* Notification message to the client */ meshtastic_ClientNotification clientNotification; + /* Persistent data for device-ui */ + meshtastic_DeviceUIConfig deviceuiConfig; }; } meshtastic_FromRadio; @@ -1292,6 +1295,7 @@ extern "C" { #define meshtastic_FromRadio_mqttClientProxyMessage_tag 14 #define meshtastic_FromRadio_fileInfo_tag 15 #define meshtastic_FromRadio_clientNotification_tag 16 +#define meshtastic_FromRadio_deviceuiConfig_tag 17 #define meshtastic_ToRadio_packet_tag 1 #define meshtastic_ToRadio_want_config_id_tag 3 #define meshtastic_ToRadio_disconnect_tag 4 @@ -1478,7 +1482,8 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,xmodemPacket,xmodemPacket), X(a, STATIC, ONEOF, MESSAGE, (payload_variant,metadata,metadata), 13) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,mqttClientProxyMessage,mqttClientProxyMessage), 14) \ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,fileInfo,fileInfo), 15) \ -X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNotification), 16) +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNotification), 16) \ +X(a, STATIC, ONEOF, MESSAGE, (payload_variant,deviceuiConfig,deviceuiConfig), 17) #define meshtastic_FromRadio_CALLBACK NULL #define meshtastic_FromRadio_DEFAULT NULL #define meshtastic_FromRadio_payload_variant_packet_MSGTYPE meshtastic_MeshPacket @@ -1494,6 +1499,7 @@ X(a, STATIC, ONEOF, MESSAGE, (payload_variant,clientNotification,clientNot #define meshtastic_FromRadio_payload_variant_mqttClientProxyMessage_MSGTYPE meshtastic_MqttClientProxyMessage #define meshtastic_FromRadio_payload_variant_fileInfo_MSGTYPE meshtastic_FileInfo #define meshtastic_FromRadio_payload_variant_clientNotification_MSGTYPE meshtastic_ClientNotification +#define meshtastic_FromRadio_payload_variant_deviceuiConfig_MSGTYPE meshtastic_DeviceUIConfig #define meshtastic_ClientNotification_FIELDLIST(X, a) \ X(a, STATIC, OPTIONAL, UINT32, reply_id, 1) \ diff --git a/src/mesh/generated/meshtastic/telemetry.pb.h b/src/mesh/generated/meshtastic/telemetry.pb.h index a33988129..309c01dc7 100644 --- a/src/mesh/generated/meshtastic/telemetry.pb.h +++ b/src/mesh/generated/meshtastic/telemetry.pb.h @@ -74,8 +74,10 @@ typedef enum _meshtastic_TelemetrySensorType { meshtastic_TelemetrySensorType_CUSTOM_SENSOR = 29, /* MAX30102 Pulse Oximeter and Heart-Rate Sensor */ meshtastic_TelemetrySensorType_MAX30102 = 30, - /* MLX90614 non-contact IR temperature sensor. */ - meshtastic_TelemetrySensorType_MLX90614 = 31 + /* MLX90614 non-contact IR temperature sensor */ + meshtastic_TelemetrySensorType_MLX90614 = 31, + /* SCD40/SCD41 CO2, humidity, temperature sensor */ + meshtastic_TelemetrySensorType_SCD4X = 32 } meshtastic_TelemetrySensorType; /* Struct definitions */ @@ -215,6 +217,9 @@ typedef struct _meshtastic_AirQualityMetrics { /* 10.0um Particle Count */ bool has_particles_100um; uint32_t particles_100um; + /* 10.0um Particle Count */ + bool has_co2; + uint32_t co2; } meshtastic_AirQualityMetrics; /* Local device mesh statistics */ @@ -294,8 +299,8 @@ extern "C" { /* Helper constants for enums */ #define _meshtastic_TelemetrySensorType_MIN meshtastic_TelemetrySensorType_SENSOR_UNSET -#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_MLX90614 -#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_MLX90614+1)) +#define _meshtastic_TelemetrySensorType_MAX meshtastic_TelemetrySensorType_SCD4X +#define _meshtastic_TelemetrySensorType_ARRAYSIZE ((meshtastic_TelemetrySensorType)(meshtastic_TelemetrySensorType_SCD4X+1)) @@ -310,7 +315,7 @@ extern "C" { #define meshtastic_DeviceMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_EnvironmentMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_PowerMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_AirQualityMetrics_init_default {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_HealthMetrics_init_default {false, 0, false, 0, false, 0} #define meshtastic_Telemetry_init_default {0, 0, {meshtastic_DeviceMetrics_init_default}} @@ -318,7 +323,7 @@ extern "C" { #define meshtastic_DeviceMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_EnvironmentMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_PowerMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} -#define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} +#define meshtastic_AirQualityMetrics_init_zero {false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0, false, 0} #define meshtastic_LocalStats_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_HealthMetrics_init_zero {false, 0, false, 0, false, 0} #define meshtastic_Telemetry_init_zero {0, 0, {meshtastic_DeviceMetrics_init_zero}} @@ -365,6 +370,7 @@ extern "C" { #define meshtastic_AirQualityMetrics_particles_25um_tag 10 #define meshtastic_AirQualityMetrics_particles_50um_tag 11 #define meshtastic_AirQualityMetrics_particles_100um_tag 12 +#define meshtastic_AirQualityMetrics_co2_tag 13 #define meshtastic_LocalStats_uptime_seconds_tag 1 #define meshtastic_LocalStats_channel_utilization_tag 2 #define meshtastic_LocalStats_air_util_tx_tag 3 @@ -442,7 +448,8 @@ X(a, STATIC, OPTIONAL, UINT32, particles_05um, 8) \ X(a, STATIC, OPTIONAL, UINT32, particles_10um, 9) \ X(a, STATIC, OPTIONAL, UINT32, particles_25um, 10) \ X(a, STATIC, OPTIONAL, UINT32, particles_50um, 11) \ -X(a, STATIC, OPTIONAL, UINT32, particles_100um, 12) +X(a, STATIC, OPTIONAL, UINT32, particles_100um, 12) \ +X(a, STATIC, OPTIONAL, UINT32, co2, 13) #define meshtastic_AirQualityMetrics_CALLBACK NULL #define meshtastic_AirQualityMetrics_DEFAULT NULL @@ -512,7 +519,7 @@ extern const pb_msgdesc_t meshtastic_Nau7802Config_msg; /* Maximum encoded size of messages (where known) */ #define MESHTASTIC_MESHTASTIC_TELEMETRY_PB_H_MAX_SIZE meshtastic_Telemetry_size -#define meshtastic_AirQualityMetrics_size 72 +#define meshtastic_AirQualityMetrics_size 78 #define meshtastic_DeviceMetrics_size 27 #define meshtastic_EnvironmentMetrics_size 85 #define meshtastic_HealthMetrics_size 11 From 1f2d972e18d5d954342efb12da3c04d348a042ed Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 10 Oct 2024 19:24:37 -0500 Subject: [PATCH 15/15] Remove waypoint and text message frames on NodeDB reset as well (#5029) --- src/mesh/NodeDB.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index c52dda19d..71aea7002 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -561,6 +561,8 @@ void NodeDB::resetNodes() clearLocalPosition(); numMeshNodes = 1; std::fill(devicestate.node_db_lite.begin() + 1, devicestate.node_db_lite.end(), meshtastic_NodeInfoLite()); + devicestate.has_rx_text_message = false; + devicestate.has_rx_waypoint = false; saveDeviceStateToDisk(); if (neighborInfoModule && moduleConfig.neighbor_info.enabled) neighborInfoModule->resetNeighbors();