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
This commit is contained in:
Jonathan Bennett 2024-10-03 20:51:22 -05:00 committed by GitHub
parent b2b60eccdb
commit befc2ece6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View File

@ -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"));

View File

@ -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