Skip to content

Commit bd5f96d

Browse files
committed
Fix server name are not in fixed location
Update esp8266 time code for consistency with esp32
1 parent ea07b30 commit bd5f96d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

esp3d/src/modules/time/time_service.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ bool TimeService::isInternetTime(bool readfromsettings) {
7878
bool TimeService::begin() {
7979
esp3d_log("Starting TimeService");
8080
end();
81-
String s1, s2, s3, t1;
8281
updateTimeZone(true);
8382
#if defined(WIFI_FEATURE)
8483
// no time server in AP mode
@@ -110,14 +109,14 @@ bool TimeService::begin() {
110109
if (!isInternetTime(true)) {
111110
return true;
112111
}
113-
s1 = ESP3DSettings::readString(ESP_TIME_SERVER1);
114-
s2 = ESP3DSettings::readString(ESP_TIME_SERVER2);
115-
s3 = ESP3DSettings::readString(ESP_TIME_SERVER3);
112+
_server[0] = ESP3DSettings::readString(ESP_TIME_SERVER1);
113+
_server[1] = ESP3DSettings::readString(ESP_TIME_SERVER2);
114+
_server[2] = ESP3DSettings::readString(ESP_TIME_SERVER3);
116115
#if defined(ARDUINO_ARCH_ESP32)
117-
configTzTime(_time_zone_config.c_str(), s1.c_str(), s2.c_str(), s3.c_str());
116+
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);
118117
#endif // ARDUINO_ARCH_ESP32
119118
#if defined(ARDUINO_ARCH_ESP8266)
120-
configTime(t1.c_str(), s1.c_str(), s2.c_str(), s3.c_str());
119+
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);
121120
#endif // ARDUINO_ARCH_ESP8266
122121

123122
time_t now = time(nullptr);

esp3d/src/modules/time/time_service.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class TimeService {
4444
int _get_time_zone_offset_min();
4545
bool _started;
4646
bool _isInternetTime;
47+
String _server[3];
4748
String _time_zone;
4849
String _time_zone_config;
4950
};

0 commit comments

Comments
 (0)