From 98a53941ba56a9ea53985a00cffa75cebf1e7fd2 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Thu, 29 Mar 2018 00:26:49 +0300 Subject: [PATCH 1/3] Show default MQTT user and password in WebUI --- code/espurna/mqtt.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index 350e5000..b12e6e9c 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -304,9 +304,9 @@ void _mqttWebSocketOnSend(JsonObject& root) { root["mqttEnabled"] = mqttEnabled(); root["mqttServer"] = getSetting("mqttServer", MQTT_SERVER); root["mqttPort"] = getSetting("mqttPort", MQTT_PORT); - root["mqttUser"] = getSetting("mqttUser"); + root["mqttUser"] = getSetting("mqttUser", MQTT_USER); root["mqttClientID"] = getSetting("mqttClientID"); - root["mqttPassword"] = getSetting("mqttPassword"); + root["mqttPassword"] = getSetting("mqttPassword", MQTT_PASS); root["mqttKeep"] = _mqtt_keepalive; root["mqttRetain"] = _mqtt_retain; root["mqttQoS"] = _mqtt_qos; From 922096e9daec0a2fdf77a917299cecaa94a107ed Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Thu, 29 Mar 2018 00:31:27 +0300 Subject: [PATCH 2/3] Build-time default value for hostname --- code/espurna/config/defaults.h | 5 +++++ code/espurna/espurna.ino | 2 +- code/espurna/utils.ino | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/code/espurna/config/defaults.h b/code/espurna/config/defaults.h index 8e82543b..86e25993 100644 --- a/code/espurna/config/defaults.h +++ b/code/espurna/config/defaults.h @@ -399,6 +399,11 @@ // General // ----------------------------------------------------------------------------- +// Default hostname will be ESPURNA_XXXXXX, where XXXXXX is last 3 octets of chipID +#ifndef HOSTNAME +#define HOSTNAME "" +#endif + // Needed for ESP8285 boards under Windows using PlatformIO (?) #ifndef BUTTON_PUSHBUTTON #define BUTTON_PUSHBUTTON 0 diff --git a/code/espurna/espurna.ino b/code/espurna/espurna.ino index 8c23ad62..6f6c8435 100644 --- a/code/espurna/espurna.ino +++ b/code/espurna/espurna.ino @@ -50,7 +50,7 @@ void setup() { // Hostname & board name initialization if (getSetting("hostname").length() == 0) { - setSetting("hostname", getIdentifier()); + setDefaultHostname(); } setBoardName(); diff --git a/code/espurna/utils.ino b/code/espurna/utils.ino index 4c01cf12..7398b802 100644 --- a/code/espurna/utils.ino +++ b/code/espurna/utils.ino @@ -15,6 +15,14 @@ String getIdentifier() { return String(buffer); } +void setDefaultHostname() { + if (strlen(HOSTNAME) > 0) { + setSetting("hostname", HOSTNAME); + } else { + setSetting("hostname", getIdentifier()); + } +} + void setBoardName() { #ifndef ESPURNA_CORE setSetting("boardName", DEVICE_NAME); From 83f848db96a7e36060629d6e38234f71d591c79a Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Thu, 29 Mar 2018 14:40:35 +0300 Subject: [PATCH 3/3] Send default SSL settings too --- code/espurna/mqtt.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index b12e6e9c..14ff7262 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -312,8 +312,8 @@ void _mqttWebSocketOnSend(JsonObject& root) { root["mqttQoS"] = _mqtt_qos; #if ASYNC_TCP_SSL_ENABLED root["mqttsslVisible"] = 1; - root["mqttUseSSL"] = getSetting("mqttUseSSL", 0).toInt() == 1; - root["mqttFP"] = getSetting("mqttFP"); + root["mqttUseSSL"] = getSetting("mqttUseSSL", MQTT_SSL_ENABLED).toInt() == 1; + root["mqttFP"] = getSetting("mqttFP", MQTT_SSL_FINGERPRINT); #endif root["mqttTopic"] = getSetting("mqttTopic", MQTT_TOPIC); root["mqttUseJson"] = getSetting("mqttUseJson", MQTT_USE_JSON).toInt() == 1;