diff --git a/Version.h b/Version.h index b20657e..a98d287 100644 --- a/Version.h +++ b/Version.h @@ -1,3 +1,3 @@ #pragma once -#define nuki_hub_version "4.1" \ No newline at end of file +#define nuki_hub_version "4.2" \ No newline at end of file diff --git a/networkDevices/WifiDevice.cpp b/networkDevices/WifiDevice.cpp index 3428e99..ffbdc24 100644 --- a/networkDevices/WifiDevice.cpp +++ b/networkDevices/WifiDevice.cpp @@ -74,6 +74,9 @@ void WifiDevice::initialize() Serial.println(WiFi.localIP().toString()); } + _wifiSSID = wm.getWiFiSSID(); + _wifiPSK = wm.getWiFiPass(); + _mqttClient->setBufferSize(_mqttMaxBufferSize); } @@ -103,6 +106,15 @@ bool WifiDevice::isConnected() bool WifiDevice::reconnect() { + WiFi.disconnect(); + WiFi.begin(_wifiSSID.c_str(), _wifiPSK.c_str()); + + unsigned long timeout = millis() + 5000; + while(!isConnected() && millis() < timeout) + { + delay(100); + } + return isConnected(); } diff --git a/networkDevices/WifiDevice.h b/networkDevices/WifiDevice.h index 27b6728..30d35ed 100644 --- a/networkDevices/WifiDevice.h +++ b/networkDevices/WifiDevice.h @@ -27,6 +27,10 @@ private: WiFiClientSecure* _wifiClientSecure = nullptr; PubSubClient* _mqttClient = nullptr; SpiffsCookie _cookie; + + String _wifiSSID = ""; + String _wifiPSK = ""; + char _ca[TLS_CA_MAX_SIZE]; char _cert[TLS_CERT_MAX_SIZE]; char _key[TLS_KEY_MAX_SIZE];