From 065b2d177e679f9fcbedcb8ad377a33d057b177e Mon Sep 17 00:00:00 2001 From: technyon Date: Sat, 28 Jan 2023 22:08:43 +0100 Subject: [PATCH] disable certificate input fields when W5500 device is used --- Network.cpp | 4 ++++ Network.h | 1 + WebCfgServer.cpp | 16 +++++++++++----- WebCfgServer.h | 2 +- networkDevices/NetworkDevice.h | 1 + networkDevices/W5500Device.cpp | 4 ++++ networkDevices/W5500Device.h | 2 ++ networkDevices/WifiDevice.cpp | 5 +++++ networkDevices/WifiDevice.h | 1 + 9 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Network.cpp b/Network.cpp index 7a66eeb..703a380 100644 --- a/Network.cpp +++ b/Network.cpp @@ -393,6 +393,10 @@ int Network::mqttConnectionState() return _mqttConnectionState; } +bool Network::encryptionSupported() +{ + return _device->supportsEncryption(); +} void Network::publishFloat(const char* prefix, const char* topic, const float value, const uint8_t precision) { diff --git a/Network.h b/Network.h index d0969af..6375b39 100644 --- a/Network.h +++ b/Network.h @@ -44,6 +44,7 @@ public: void publishPresenceDetection(char* csv); int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed + bool encryptionSupported(); const NetworkDeviceType networkDeviceType(); diff --git a/WebCfgServer.cpp b/WebCfgServer.cpp index 2751842..d161cb5 100644 --- a/WebCfgServer.cpp +++ b/WebCfgServer.cpp @@ -599,9 +599,9 @@ void WebCfgServer::buildMqttConfigHtml(String &response) response.concat("

Advanced MQTT and Network Configuration

"); response.concat(""); printInputField(response, "HASSDISCOVERY", "Home Assistant discovery topic (empty to disable; usually homeassistant)", _preferences->getString(preference_mqtt_hass_discovery).c_str(), 30); - printTextarea(response, "MQTTCA", "MQTT SSL CA Certificate (*, optional)", _preferences->getString(preference_mqtt_ca).c_str(), TLS_CA_MAX_SIZE); - printTextarea(response, "MQTTCRT", "MQTT SSL Client Certificate (*, optional)", _preferences->getString(preference_mqtt_crt).c_str(), TLS_CERT_MAX_SIZE); - printTextarea(response, "MQTTKEY", "MQTT SSL Client Key (*, optional)", _preferences->getString(preference_mqtt_key).c_str(), TLS_KEY_MAX_SIZE); + printTextarea(response, "MQTTCA", "MQTT SSL CA Certificate (*, optional)", _preferences->getString(preference_mqtt_ca).c_str(), TLS_CA_MAX_SIZE, _network->encryptionSupported()); + printTextarea(response, "MQTTCRT", "MQTT SSL Client Certificate (*, optional)", _preferences->getString(preference_mqtt_crt).c_str(), TLS_CERT_MAX_SIZE, _network->encryptionSupported()); + printTextarea(response, "MQTTKEY", "MQTT SSL Client Key (*, optional)", _preferences->getString(preference_mqtt_key).c_str(), TLS_KEY_MAX_SIZE, _network->encryptionSupported()); printDropDown(response, "NWHWDT", "Network hardware detection", String(_preferences->getInt(preference_network_hardware_detect)), getNetworkDetectionOptions()); printInputField(response, "RSSI", "RSSI Publish interval (seconds; -1 to disable)", _preferences->getInt(preference_rssi_publish_interval), 6); printInputField(response, "NETTIMEOUT", "Network Timeout until restart (seconds; -1 to disable)", _preferences->getInt(preference_network_timeout), 5); @@ -795,7 +795,8 @@ void WebCfgServer::printTextarea(String& response, const char *token, const char *description, const char *value, - const size_t maxLength) + const size_t maxLength, + const bool enabled) { char maxLengthStr[20]; @@ -804,7 +805,12 @@ void WebCfgServer::printTextarea(String& response, response.concat("
"); response.concat(description); response.concat(""); - response.concat("