Browse Source

Merged in derfloh/espurna/master (pull request #22)

Add #defines for MQTT Username+Password

Approved-by: Xose Pérez <xose.perez@gmail.com>
fastled
Florian 7 years ago
committed by Xose Pérez
parent
commit
569f139ebb
2 changed files with 4 additions and 2 deletions
  1. +2
    -0
      code/espurna/config/general.h
  2. +2
    -2
      code/espurna/mqtt.ino

+ 2
- 0
code/espurna/config/general.h View File

@ -337,6 +337,8 @@ PROGMEM const char* const custom_reset_string[] = {
#define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SUPPORT=1 will perform an autodiscover and #define MQTT_AUTOCONNECT 1 // If enabled and MDNS_SUPPORT=1 will perform an autodiscover and
// autoconnect to the first MQTT broker found if none defined // autoconnect to the first MQTT broker found if none defined
#define MQTT_SERVER "" // Default MQTT broker address #define MQTT_SERVER "" // Default MQTT broker address
#define MQTT_USER "" // Default MQTT broker usename
#define MQTT_PASS "" // Default MQTT broker password
#define MQTT_PORT 1883 // MQTT broker port #define MQTT_PORT 1883 // MQTT broker port
#define MQTT_TOPIC "/test/switch/{identifier}" // Default MQTT base topic #define MQTT_TOPIC "/test/switch/{identifier}" // Default MQTT base topic
#define MQTT_RETAIN true // MQTT retain flag #define MQTT_RETAIN true // MQTT retain flag


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

@ -340,8 +340,8 @@ void mqttConnect() {
char * host = strdup(getSetting("mqttServer", MQTT_SERVER).c_str()); char * host = strdup(getSetting("mqttServer", MQTT_SERVER).c_str());
if (strlen(host) == 0) return; if (strlen(host) == 0) return;
unsigned int port = getSetting("mqttPort", MQTT_PORT).toInt(); unsigned int port = getSetting("mqttPort", MQTT_PORT).toInt();
_mqttUser = strdup(getSetting("mqttUser").c_str());
_mqttPass = strdup(getSetting("mqttPassword").c_str());
_mqttUser = strdup(getSetting("mqttUser", MQTT_USER).c_str());
_mqttPass = strdup(getSetting("mqttPassword", MQTT_PASSWORD).c_str());
if (_mqttWill) free(_mqttWill); if (_mqttWill) free(_mqttWill);
_mqttWill = strdup((_mqttTopic + MQTT_TOPIC_STATUS).c_str()); _mqttWill = strdup((_mqttTopic + MQTT_TOPIC_STATUS).c_str());


Loading…
Cancel
Save