diff --git a/CMakeLists.txt b/CMakeLists.txt index 58cdf70..8dd9c71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ project(nuki_hub CXX) set(LOG_LEVEL ARDUHAL_LOG_LEVEL_NONE) # Length of char arrays to store certificates for MQTTS -add_compile_definitions(TLS_CA_MAX_SIZE=1800) -add_compile_definitions(TLS_CERT_MAX_SIZE=1800) +add_compile_definitions(TLS_CA_MAX_SIZE=1500) +add_compile_definitions(TLS_CERT_MAX_SIZE=1500) add_compile_definitions(TLS_KEY_MAX_SIZE=1800) include_directories(${PROJECT_NAME} diff --git a/Network.cpp b/Network.cpp index 61435fc..91fb69b 100644 --- a/Network.cpp +++ b/Network.cpp @@ -161,6 +161,8 @@ bool Network::reconnect() { Serial.print(F("MQTT connect failed, rc=")); Serial.println(_device->mqttClient()->state()); + _device->printError(); + _device->mqttClient()->disconnect(); _mqttConnected = false; _nextReconnect = millis() + 5000; } diff --git a/networkDevices/NetworkDevice.h b/networkDevices/NetworkDevice.h index e1ec20c..7fc65bf 100644 --- a/networkDevices/NetworkDevice.h +++ b/networkDevices/NetworkDevice.h @@ -14,6 +14,7 @@ public: virtual void initialize() = 0; virtual bool reconnect() = 0; virtual void reconfigure() = 0; + virtual void printError() = 0; virtual void update() = 0; diff --git a/networkDevices/W5500Device.cpp b/networkDevices/W5500Device.cpp index 1041046..79bbc85 100644 --- a/networkDevices/W5500Device.cpp +++ b/networkDevices/W5500Device.cpp @@ -117,6 +117,13 @@ void W5500Device::resetDevice() nwDelay(1500); } + +void W5500Device::printError() +{ + Serial.print(F("Free Heap: ")); + Serial.println(ESP.getFreeHeap()); +} + PubSubClient *W5500Device::mqttClient() { return _mqttClient; diff --git a/networkDevices/W5500Device.h b/networkDevices/W5500Device.h index 6cd1bc5..9ba726d 100644 --- a/networkDevices/W5500Device.h +++ b/networkDevices/W5500Device.h @@ -13,6 +13,7 @@ public: virtual void initialize(); virtual bool reconnect(); virtual void reconfigure(); + virtual void printError(); virtual void update(); diff --git a/networkDevices/WifiDevice.cpp b/networkDevices/WifiDevice.cpp index 8a26b59..3428e99 100644 --- a/networkDevices/WifiDevice.cpp +++ b/networkDevices/WifiDevice.cpp @@ -84,6 +84,18 @@ void WifiDevice::reconfigure() ESP.restart(); } +void WifiDevice::printError() +{ + if(_wifiClientSecure != nullptr) + { + char lastError[100]; + _wifiClientSecure->lastError(lastError,100); + Serial.println(lastError); + } + Serial.print(F("Free Heap: ")); + Serial.println(ESP.getFreeHeap()); +} + bool WifiDevice::isConnected() { return WiFi.isConnected(); diff --git a/networkDevices/WifiDevice.h b/networkDevices/WifiDevice.h index 8f2e522..27b6728 100644 --- a/networkDevices/WifiDevice.h +++ b/networkDevices/WifiDevice.h @@ -14,6 +14,7 @@ public: virtual void initialize(); virtual void reconfigure(); virtual bool reconnect(); + virtual void printError(); virtual void update();