From 0b4915001eb15e232b4cdf8ed747bc82c1a39a5d Mon Sep 17 00:00:00 2001 From: Marco Veneziano Date: Thu, 9 Oct 2025 22:49:08 +0200 Subject: [PATCH] Fix for using short and long names starting with char "0" from userPrefs.jsonc --- src/mesh/NodeDB.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index dec8411fe..78f22d35b 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1060,12 +1060,14 @@ void NodeDB::installDefaultDeviceState() // Set default owner name pickNewNodeNum(); // based on macaddr now #ifdef USERPREFS_CONFIG_OWNER_LONG_NAME - snprintf(owner.long_name, sizeof(owner.long_name), (const char *)USERPREFS_CONFIG_OWNER_LONG_NAME); + #define STR(x) #x + snprintf(owner.long_name, sizeof(owner.long_name), "%s", STR(USERPREFS_CONFIG_OWNER_LONG_NAME)); #else snprintf(owner.long_name, sizeof(owner.long_name), "Meshtastic %04x", getNodeNum() & 0x0ffff); #endif -#ifdef USERPREFS_CONFIG_OWNER_SHORT_NAME - snprintf(owner.short_name, sizeof(owner.short_name), (const char *)USERPREFS_CONFIG_OWNER_SHORT_NAME); + #ifdef USERPREFS_CONFIG_OWNER_SHORT_NAME + #define STR(x) #x + snprintf(owner.short_name, sizeof(owner.short_name), "%s", STR(USERPREFS_CONFIG_OWNER_SHORT_NAME)); #else snprintf(owner.short_name, sizeof(owner.short_name), "%04x", getNodeNum() & 0x0ffff); #endif