Browse Source

Merge pull request #741 from mcspr/732-cust

Missing values in MQTT configuration, hostname define.
rfm69
Xose Pérez 6 years ago
committed by GitHub
parent
commit
22b02fa386
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 5 deletions
  1. +5
    -0
      code/espurna/config/defaults.h
  2. +1
    -1
      code/espurna/espurna.ino
  3. +4
    -4
      code/espurna/mqtt.ino
  4. +8
    -0
      code/espurna/utils.ino

+ 5
- 0
code/espurna/config/defaults.h View File

@ -399,6 +399,11 @@
// General // 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 (?) // Needed for ESP8285 boards under Windows using PlatformIO (?)
#ifndef BUTTON_PUSHBUTTON #ifndef BUTTON_PUSHBUTTON
#define BUTTON_PUSHBUTTON 0 #define BUTTON_PUSHBUTTON 0


+ 1
- 1
code/espurna/espurna.ino View File

@ -50,7 +50,7 @@ void setup() {
// Hostname & board name initialization // Hostname & board name initialization
if (getSetting("hostname").length() == 0) { if (getSetting("hostname").length() == 0) {
setSetting("hostname", getIdentifier());
setDefaultHostname();
} }
setBoardName(); setBoardName();


+ 4
- 4
code/espurna/mqtt.ino View File

@ -304,16 +304,16 @@ void _mqttWebSocketOnSend(JsonObject& root) {
root["mqttEnabled"] = mqttEnabled(); root["mqttEnabled"] = mqttEnabled();
root["mqttServer"] = getSetting("mqttServer", MQTT_SERVER); root["mqttServer"] = getSetting("mqttServer", MQTT_SERVER);
root["mqttPort"] = getSetting("mqttPort", MQTT_PORT); root["mqttPort"] = getSetting("mqttPort", MQTT_PORT);
root["mqttUser"] = getSetting("mqttUser");
root["mqttUser"] = getSetting("mqttUser", MQTT_USER);
root["mqttClientID"] = getSetting("mqttClientID"); root["mqttClientID"] = getSetting("mqttClientID");
root["mqttPassword"] = getSetting("mqttPassword");
root["mqttPassword"] = getSetting("mqttPassword", MQTT_PASS);
root["mqttKeep"] = _mqtt_keepalive; root["mqttKeep"] = _mqtt_keepalive;
root["mqttRetain"] = _mqtt_retain; root["mqttRetain"] = _mqtt_retain;
root["mqttQoS"] = _mqtt_qos; root["mqttQoS"] = _mqtt_qos;
#if ASYNC_TCP_SSL_ENABLED #if ASYNC_TCP_SSL_ENABLED
root["mqttsslVisible"] = 1; 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 #endif
root["mqttTopic"] = getSetting("mqttTopic", MQTT_TOPIC); root["mqttTopic"] = getSetting("mqttTopic", MQTT_TOPIC);
root["mqttUseJson"] = getSetting("mqttUseJson", MQTT_USE_JSON).toInt() == 1; root["mqttUseJson"] = getSetting("mqttUseJson", MQTT_USE_JSON).toInt() == 1;


+ 8
- 0
code/espurna/utils.ino View File

@ -15,6 +15,14 @@ String getIdentifier() {
return String(buffer); return String(buffer);
} }
void setDefaultHostname() {
if (strlen(HOSTNAME) > 0) {
setSetting("hostname", HOSTNAME);
} else {
setSetting("hostname", getIdentifier());
}
}
void setBoardName() { void setBoardName() {
#ifndef ESPURNA_CORE #ifndef ESPURNA_CORE
setSetting("boardName", DEVICE_NAME); setSetting("boardName", DEVICE_NAME);


Loading…
Cancel
Save