|
2 | 2 |
|
3 | 3 | NTPSettingsService::NTPSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) :
|
4 | 4 | AdminSettingsService(server, fs, securityManager, NTP_SETTINGS_SERVICE_PATH, NTP_SETTINGS_FILE) {
|
5 |
| -#if defined(ESP8266) |
6 |
| - _onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected( |
7 |
| - std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1)); |
8 |
| - _onStationModeGotIPHandler = |
9 |
| - WiFi.onStationModeGotIP(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1)); |
10 |
| -#elif defined(ESP_PLATFORM) |
| 5 | +#ifdef ESP32 |
11 | 6 | WiFi.onEvent(
|
12 | 7 | std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1, std::placeholders::_2),
|
13 | 8 | WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED);
|
14 | 9 | WiFi.onEvent(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1, std::placeholders::_2),
|
15 | 10 | WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP);
|
| 11 | +#elif defined(ESP8266) |
| 12 | + _onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected( |
| 13 | + std::bind(&NTPSettingsService::onStationModeDisconnected, this, std::placeholders::_1)); |
| 14 | + _onStationModeGotIPHandler = |
| 15 | + WiFi.onStationModeGotIP(std::bind(&NTPSettingsService::onStationModeGotIP, this, std::placeholders::_1)); |
16 | 16 | #endif
|
17 |
| - |
18 | 17 | NTP.onNTPSyncEvent([this](NTPSyncEvent_t ntpEvent) {
|
19 | 18 | _ntpEvent = ntpEvent;
|
20 | 19 | _syncEventTriggered = true;
|
@@ -68,24 +67,24 @@ void NTPSettingsService::onConfigUpdated() {
|
68 | 67 | _reconfigureNTP = true;
|
69 | 68 | }
|
70 | 69 |
|
71 |
| -#if defined(ESP8266) |
72 |
| -void NTPSettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) { |
| 70 | +#ifdef ESP32 |
| 71 | +void NTPSettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) { |
73 | 72 | Serial.printf("Got IP address, starting NTP Synchronization\n");
|
74 | 73 | _reconfigureNTP = true;
|
75 | 74 | }
|
76 | 75 |
|
77 |
| -void NTPSettingsService::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) { |
| 76 | +void NTPSettingsService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) { |
78 | 77 | Serial.printf("WiFi connection dropped, stopping NTP.\n");
|
79 | 78 | _reconfigureNTP = false;
|
80 | 79 | NTP.stop();
|
81 | 80 | }
|
82 |
| -#elif defined(ESP_PLATFORM) |
83 |
| -void NTPSettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) { |
| 81 | +#elif defined(ESP8266) |
| 82 | +void NTPSettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) { |
84 | 83 | Serial.printf("Got IP address, starting NTP Synchronization\n");
|
85 | 84 | _reconfigureNTP = true;
|
86 | 85 | }
|
87 | 86 |
|
88 |
| -void NTPSettingsService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) { |
| 87 | +void NTPSettingsService::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) { |
89 | 88 | Serial.printf("WiFi connection dropped, stopping NTP.\n");
|
90 | 89 | _reconfigureNTP = false;
|
91 | 90 | NTP.stop();
|
|
0 commit comments