From 0bccf29f64ad744fe3de23478d7f8d032c74e3f3 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 5 May 2025 11:21:31 +1200 Subject: [PATCH 1/2] use hex of first 4 bytes of identity public key as default node name --- examples/companion_radio/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 7ab94619..efd6ba63 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -847,6 +847,13 @@ public: loadMainIdentity(); + // use hex of first 4 bytes of identity public key as default node name + if(strcmp(_prefs.node_name, "NONAME") == 0){ + char pub_key_hex[10]; + mesh::Utils::toHex(pub_key_hex, self_id.pub_key, 4); + strcpy(_prefs.node_name, pub_key_hex); + } + // load persisted prefs if (_fs->exists("/new_prefs")) { loadPrefsInt("/new_prefs"); // new filename From 8f32ee61ce3f9ab60b8334f90ca2466479be9f54 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 5 May 2025 11:34:02 +1200 Subject: [PATCH 2/2] no need for prefs check before prefs are loaded --- examples/companion_radio/main.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index efd6ba63..569a7f30 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -848,11 +848,9 @@ public: loadMainIdentity(); // use hex of first 4 bytes of identity public key as default node name - if(strcmp(_prefs.node_name, "NONAME") == 0){ - char pub_key_hex[10]; - mesh::Utils::toHex(pub_key_hex, self_id.pub_key, 4); - strcpy(_prefs.node_name, pub_key_hex); - } + char pub_key_hex[10]; + mesh::Utils::toHex(pub_key_hex, self_id.pub_key, 4); + strcpy(_prefs.node_name, pub_key_hex); // load persisted prefs if (_fs->exists("/new_prefs")) {