Merge branch 'v1.0.2'

This commit is contained in:
Nicu Hodos 2024-06-29 17:28:07 +02:00
commit 443b7c29d8
2 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "Wifi", "name": "Wifi",
"version": "1.0.1", "version": "1.0.2",
"description": "Helper classes for handling wifi connectiviy and OTA", "description": "Helper classes for handling wifi connectiviy and OTA",
"repository": "repository":
{ {

View File

@ -33,9 +33,9 @@ namespace Wifi {
currentPsk = WiFi.psk(); currentPsk = WiFi.psk();
tReconnect.enable(); tReconnect.enable();
} }
); );
void setup(Scheduler& ts, void(*onConnected)() = nullptr) { void setup(Scheduler& ts, void(*onConnected)() = nullptr, void(*onDisconnected)() = nullptr) {
stationConnectedHandler = WiFi.onStationModeGotIP( stationConnectedHandler = WiFi.onStationModeGotIP(
[onConnected](const WiFiEventStationModeGotIP& e) { [onConnected](const WiFiEventStationModeGotIP& e) {
Serial.println("Connected to network."); Serial.println("Connected to network.");
@ -45,9 +45,10 @@ namespace Wifi {
}); });
stationDisconnectedHandler = WiFi.onStationModeDisconnected( stationDisconnectedHandler = WiFi.onStationModeDisconnected(
[](const WiFiEventStationModeDisconnected& e) { [onDisconnected](const WiFiEventStationModeDisconnected& e) {
Serial.println("Disconnected from network."); Serial.println("Disconnected from network.");
tReconnect.restartDelayed(); tReconnect.enableIfNot();
if (onDisconnected) onDisconnected();
}); });