Comments (4)
That function is used for internal work only.
The TZ-related data are stored in WM_config and you have to accessed from there
typedef struct
{
WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS];
char TZ_Name[TZNAME_MAX_LEN]; // "America/Toronto"
char TZ[TIMEZONE_MAX_LEN]; // "EST5EDT,M3.2.0,M11.1.0"
uint16_t checksum;
} WM_Config;
WM_Config WM_config;
...
#if USE_ESP_WIFIMANAGER_NTP
if ( strlen(WM_config.TZ_Name) > 0 )
{
LOGERROR3(F("Current TZ_Name ="), WM_config.TZ_Name, F(", TZ = "), WM_config.TZ);
#if ESP8266
configTime(WM_config.TZ, "pool.ntp.org");
#else
//configTzTime(WM_config.TZ, "pool.ntp.org" );
configTzTime(WM_config.TZ, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org");
#endif
}
else
{
Serial.println(F("Current Timezone is not set. Enter Config Portal to set."));
}
#endif
from espasync_wifimanager.
What is the recommended way to get the WM_Config structure loaded with the persisted config? I see about 300 lines of code in setup() copy/pasted into most of the samples that includes a call to loadConfigData() but when I tried to extract the ~100 lines that seemed needed to load the config structure - I get an error:
.pio\libdeps\node32s\LittleFS_esp32\src\lfs.c:1076:error: Corrupted dir pair at {0x0, 0x1}
E (9060) esp_littlefs: mount failed, (-84)
E (9064) esp_littlefs: Failed to initialize LittleFS
[E][LITTLEFS.cpp:90] begin(): Mounting LITTLEFS failed! Error: -1
This setup code is also the same code that contains the call to getTimezoneName() that you said is internal only so I'm unsure how much of it I should be copy/pasting into my application.
@khoih-prog Is there a public function that is intended for people to use to load the WM_Config structure?
from espasync_wifimanager.
In case someone comes across this later. The simple solution I came up with was that after the standard logic to connect:
// connect to wifi or enter AP mode so it can be configured
DB_PRINT("\nStarting Kaleidoscope on " + String(ARDUINO_BOARD));
DB_PRINTLN(ESP_ASYNC_WIFIMANAGER_VERSION);
ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, "Kaleidoscope");
//ESPAsync_wifiManager.resetSettings(); //reset saved settings
ESPAsync_wifiManager.setAPStaticIPConfig(IPAddress(192, 168, 132, 1), IPAddress(192, 168, 132, 1), IPAddress(255, 255, 255, 0));
ESPAsync_wifiManager.autoConnect("KaleidoscopeAP");
if (WiFi.status() == WL_CONNECTED)
{
DB_PRINT(F("Connected. Local IP: "));
DB_PRINTLN(WiFi.localIP());
}
else
{
DB_PRINTLN(ESPAsync_wifiManager.getStatus(WiFi.status()));
}
I added a little code to save the timezone information in the standard preferences:
// this only returns a value during the initial config step (call resetSettings() to test)
// store the string in persistant storage for later use
String timezoneName = ESPAsync_wifiManager.getTimezoneName();
if (timezoneName.length())
{
// write the timezone string into persistant memory
DB_PRINTF("Saving timezone '%s'\r\n", timezoneName.c_str());
const char * tz = ESPAsync_wifiManager.getTZ(timezoneName);
Preferences preferences;
preferences.begin("kaleidoscope", false);
preferences.putString("tz", tz);
preferences.end();
}
Then on regular boots, I can just read the timezone from the preferences:
// read the timezone from persistant memory
Preferences preferences;
preferences.begin("kaleidoscope", true);
String tz = preferences.getString("tz", "");
preferences.end();
if (tz.length())
{
configTzTime(tz.c_str(), "us.pool.ntp.org", "time.nist.gov");
DB_PRINTF("Current timezone is %s\r\n", tz.c_str());
}
else
{
// hard code EST because I can :)
configTime(-5 * SECS_PER_HOUR, SECS_PER_HOUR, "us.pool.ntp.org", "time.nist.gov");
DB_PRINTLN(F("Current Timezone is not set. Enter Config Portal to set."));
}
from espasync_wifimanager.
Hi Ben,
I'm glad that you've found the way out, even not the good solution.
There is much better way to do it, but I intentionally delay responding, so that you have to spend time to understand more how the library process is working.
It's better to start with the more complex examples, such as Async_AutoConnect, then trimming down than to start with minimal example, because you don't have the necessary functions to support your complex case (LittleFS, WM_Config, etc.).
Anyway, it's still better than nothing is working.
Good Luck,
from espasync_wifimanager.
Related Issues (20)
- Captive Portal hanging depending on active core for AsyncTCP HOT 6
- Configuration not saved on azdelivery devkit v2 HOT 2
- Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled. HOT 1
- ESPAsyncDNSServer depends on faulty and not maintained library ESPAsyncUDP HOT 17
- ESP32C3 doesnt show any SSID scan results. HOT 5
- "no protocol" error HOT 2
- Possible dependency Error HOT 1
- Where to put #define when using classes
- Default all parameters as part of the library
- Compilation error: WiFiMulti.h: No such file or director HOT 1
- Frequent run time error "Connecting MultiWifi..." HOT 1
- Query: some dependencies (eg ESP_DoubleResetDetector) have been archived- safe to keep using?
- how to close the AP after successfully connecting to the configured WiFi? HOT 1
- is there a way to run it "non blocking" ? HOT 1
- FS.h isn't found HOT 1
- Platformio Build Error - no matching function for call to 'LITTLEFSImpl::open HOT 3
- SPIFFS failed!. Please use LittleFS or EEPROM. Stay forever HOT 6
- Device reboot when webServer.begin(); is called HOT 2
- no matching function for call to 'LITTLEFSImpl::open(const char*&, const char [2])' HOT 1
- webServer.addHandler(&events) crashes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espasync_wifimanager.