Skip to content

Commit 18334b9

Browse files
committed
Internal ESP12 clock must be set in order to allow verification of certificate. This function just tasks the ESP framework with performing the NTP time sync, the time is not synched when this function returns. It may take a little while.
1 parent 01f5a35 commit 18334b9

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/Arduino_ConnectionHandler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,12 @@ class ConnectionHandler {
116116
#if defined(ARDUINO_ESP8266_ESP12) || defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
117117
#ifdef ARDUINO_ESP8266_ESP12
118118
#include <ESP8266WiFi.h>
119-
120119
#else
121120
#include <WiFi.h>
122121
#endif
123122

124123
#include <WiFiUdp.h>
125124
#define BOARD_HAS_WIFI
126-
#define GETTIME_MISSING
127125
#define NETWORK_HARDWARE_ERROR WL_NO_SHIELD
128126
#define NETWORK_IDLE_STATUS WL_IDLE_STATUS
129127
#define NETWORK_CONNECTED WL_CONNECTED

src/Arduino_WiFiConnectionHandler.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ void WiFiConnectionHandler::execNetworkEventCallback(OnNetworkEventCallback & ca
9191
}
9292

9393
unsigned long WiFiConnectionHandler::getTime() {
94-
#ifdef GETTIME_MISSING
95-
return 0;
96-
#else
94+
#if !defined(ARDUINO_ESP8266_ESP12) && !defined(ARDUINO_ARCH_ESP32) && !defined(ESP8266)
9795
return WiFi.getTime();
98-
#endif
96+
#else
97+
return 0;
98+
#endif
9999
}
100100

101101
void WiFiConnectionHandler::update() {
@@ -158,7 +158,7 @@ void WiFiConnectionHandler::update() {
158158
return;
159159
} else {
160160
Debug.print(DBG_INFO, "Connected to \"%s\"", ssid);
161-
changeConnectionState(NetworkConnectionState::CONNECTED);
161+
changeConnectionState(NetworkConnectionState::GETTIME);
162162
return;
163163
}
164164
}
@@ -175,7 +175,11 @@ void WiFiConnectionHandler::update() {
175175
}
176176
break;
177177
case NetworkConnectionState::GETTIME: {
178-
178+
#if defined(ARDUINO_ESP8266_ESP12) || defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
179+
configTime(0, 0, "pool.ntp.org", "time.nist.gov");
180+
changeConnectionState(NetworkConnectionState::CONNECTED);
181+
Debug.print(DBG_VERBOSE, "NetworkConnectionState::GETTIME");
182+
#endif
179183
}
180184
break;
181185
case NetworkConnectionState::DISCONNECTING: {

0 commit comments

Comments
 (0)