mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-12 10:29:04 +08:00
Fix server name are not in fixed location
Update esp8266 time code for consistency with esp32
This commit is contained in:
parent
ea07b30b04
commit
bd5f96d1b0
@ -78,7 +78,6 @@ bool TimeService::isInternetTime(bool readfromsettings) {
|
|||||||
bool TimeService::begin() {
|
bool TimeService::begin() {
|
||||||
esp3d_log("Starting TimeService");
|
esp3d_log("Starting TimeService");
|
||||||
end();
|
end();
|
||||||
String s1, s2, s3, t1;
|
|
||||||
updateTimeZone(true);
|
updateTimeZone(true);
|
||||||
#if defined(WIFI_FEATURE)
|
#if defined(WIFI_FEATURE)
|
||||||
// no time server in AP mode
|
// no time server in AP mode
|
||||||
@ -110,14 +109,14 @@ bool TimeService::begin() {
|
|||||||
if (!isInternetTime(true)) {
|
if (!isInternetTime(true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
s1 = ESP3DSettings::readString(ESP_TIME_SERVER1);
|
_server[0] = ESP3DSettings::readString(ESP_TIME_SERVER1);
|
||||||
s2 = ESP3DSettings::readString(ESP_TIME_SERVER2);
|
_server[1] = ESP3DSettings::readString(ESP_TIME_SERVER2);
|
||||||
s3 = ESP3DSettings::readString(ESP_TIME_SERVER3);
|
_server[2] = ESP3DSettings::readString(ESP_TIME_SERVER3);
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
configTzTime(_time_zone_config.c_str(), s1.c_str(), s2.c_str(), s3.c_str());
|
configTzTime(_time_zone_config.c_str(), _server[0].c_str(), _server[1].length() > 0 ? _server[1].c_str() : nullptr, _server[2].length() > 0 ? _server[2].c_str() : nullptr);
|
||||||
#endif // ARDUINO_ARCH_ESP32
|
#endif // ARDUINO_ARCH_ESP32
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
configTime(t1.c_str(), s1.c_str(), s2.c_str(), s3.c_str());
|
configTime(_time_zone_config.c_str(), _server[0].c_str(), _server[1].length() > 0 ? _server[1].c_str() : nullptr, _server[2].length() > 0 ? _server[2].c_str() : nullptr);
|
||||||
#endif // ARDUINO_ARCH_ESP8266
|
#endif // ARDUINO_ARCH_ESP8266
|
||||||
|
|
||||||
time_t now = time(nullptr);
|
time_t now = time(nullptr);
|
||||||
|
@ -44,6 +44,7 @@ class TimeService {
|
|||||||
int _get_time_zone_offset_min();
|
int _get_time_zone_offset_min();
|
||||||
bool _started;
|
bool _started;
|
||||||
bool _isInternetTime;
|
bool _isInternetTime;
|
||||||
|
String _server[3];
|
||||||
String _time_zone;
|
String _time_zone;
|
||||||
String _time_zone_config;
|
String _time_zone_config;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user