From befc2ece6f06f6002e5ce3128df3c4c82aa538fe Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 3 Oct 2024 20:51:22 -0500 Subject: [PATCH] Add a Userprefs Timezone String, to be replaced in the web flasher (#4938) * Add a Userprefs Timezone String, to be replaced in the web flasher * Use a volatile char buffer for slipstreamed strings. * More refinement --- src/main.cpp | 11 +++++++++-- userPrefs.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c11995837..a8ea69111 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ +#include "../userPrefs.h" #include "configuration.h" #if !MESHTASTIC_EXCLUDE_GPS #include "GPS.h" @@ -706,10 +707,16 @@ void setup() // setup TZ prior to time actions. #if !MESHTASTIC_EXCLUDE_TZ - if (*config.device.tzdef) { + LOG_DEBUG("Using compiled/slipstreamed %s\n", USERPREFS_TZ_STRING); // important, removing this clobbers our magic string + if (*config.device.tzdef && config.device.tzdef[0] != 0) { + LOG_DEBUG("Saved TZ: %s \n", config.device.tzdef); setenv("TZ", config.device.tzdef, 1); } else { - setenv("TZ", "GMT0", 1); + if (strncmp((const char *)USERPREFS_TZ_STRING, "tzpl", 4) == 0) { + setenv("TZ", "GMT0", 1); + } else { + setenv("TZ", (const char *)USERPREFS_TZ_STRING, 1); + } } tzset(); LOG_DEBUG("Set Timezone to %s\n", getenv("TZ")); diff --git a/userPrefs.h b/userPrefs.h index 40f2cc6d2..337bd7976 100644 --- a/userPrefs.h +++ b/userPrefs.h @@ -1,6 +1,6 @@ #ifndef _USERPREFS_ #define _USERPREFS_ - +volatile static const char USERPREFS_TZ_STRING[] = "tzplaceholder "; // Uncomment and modify to set device defaults // #define USERPREFS_EVENT_MODE 1