mirror of
https://github.com/wled/WLED.git
synced 2025-07-27 20:56:40 +00:00
Added MQTT authentication support
This commit is contained in:
parent
f0f02c4ea6
commit
c6d8b63e54
@ -57,7 +57,7 @@ arduino_core_2_4_1 = espressif8266@1.7.3
|
|||||||
arduino_core_2_4_2 = espressif8266@1.8.0
|
arduino_core_2_4_2 = espressif8266@1.8.0
|
||||||
arduino_core_2_5_0 = espressif8266@2.0.4
|
arduino_core_2_5_0 = espressif8266@2.0.4
|
||||||
arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage
|
arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage
|
||||||
platform = ${common:esp8266.arduino_core_2_4_2}
|
platform = ${common:esp8266.arduino_core_2_5_0}
|
||||||
build_flags =
|
build_flags =
|
||||||
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
|
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
|
||||||
-Wl,-Teagle.flash.4m1m.ld ;;;; Required for core > v2.5.0 or staging version 4MB Flash 3MB SPIFFs
|
-Wl,-Teagle.flash.4m1m.ld ;;;; Required for core > v2.5.0 or staging version 4MB Flash 3MB SPIFFs
|
||||||
@ -160,4 +160,3 @@ lib_deps =
|
|||||||
${common.lib_deps_external}
|
${common.lib_deps_external}
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
IRremoteESP8266
|
IRremoteESP8266
|
||||||
|
|
Binary file not shown.
@ -253,6 +253,9 @@ Device Auth token: <input name="BK" maxlength="33"><br>
|
|||||||
<i>Clear the token field to disable. </i><a href="https://github.com/Aircoookie/WLED/wiki/Blynk" target="_blank">Setup info</a>
|
<i>Clear the token field to disable. </i><a href="https://github.com/Aircoookie/WLED/wiki/Blynk" target="_blank">Setup info</a>
|
||||||
<h3>MQTT</h3>
|
<h3>MQTT</h3>
|
||||||
Broker: <input name="MS" maxlength="32"><br>
|
Broker: <input name="MS" maxlength="32"><br>
|
||||||
|
Username: <input name="MQTTUSER" maxlength="32"><br>
|
||||||
|
Password: <input type="password" input name="MQTTPASS" maxlength="32"><br>
|
||||||
|
Client ID: <input name="MQTTCID" maxlength="32"><br>
|
||||||
Device Topic: <input name="MD" maxlength="32"><br>
|
Device Topic: <input name="MD" maxlength="32"><br>
|
||||||
Group Topic: <input name="MG" maxlength="32"><br>
|
Group Topic: <input name="MG" maxlength="32"><br>
|
||||||
<i>Reboot required to apply changes. </i><a href="https://github.com/Aircoookie/WLED/wiki/MQTT" target="_blank">MQTT info</a>
|
<i>Reboot required to apply changes. </i><a href="https://github.com/Aircoookie/WLED/wiki/MQTT" target="_blank">MQTT info</a>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* @title WLED project sketch
|
* @title WLED project sketch
|
||||||
* @version 0.8.4
|
* @version 0.8.5-dev #mqttauth @TimothyBrown
|
||||||
* @author Christian Schwinne
|
* @author Christian Schwinne
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -204,6 +204,9 @@ bool e131Multicast = false;
|
|||||||
char mqttDeviceTopic[33] = ""; //main MQTT topic (individual per device, default is wled/mac)
|
char mqttDeviceTopic[33] = ""; //main MQTT topic (individual per device, default is wled/mac)
|
||||||
char mqttGroupTopic[33] = "wled/all"; //second MQTT topic (for example to group devices)
|
char mqttGroupTopic[33] = "wled/all"; //second MQTT topic (for example to group devices)
|
||||||
char mqttServer[33] = ""; //both domains and IPs should work (no SSL)
|
char mqttServer[33] = ""; //both domains and IPs should work (no SSL)
|
||||||
|
char mqttUser[33] = ""; //optional: username for MQTT auth
|
||||||
|
char mqttPass[33] = ""; //optional: password for MQTT auth
|
||||||
|
char mqttClientID[33] = ""; //override the client ID
|
||||||
|
|
||||||
bool huePollingEnabled = false; //poll hue bridge for light state
|
bool huePollingEnabled = false; //poll hue bridge for light state
|
||||||
uint16_t huePollIntervalMs = 2500; //low values (< 1sec) may cause lag but offer quicker response
|
uint16_t huePollIntervalMs = 2500; //low values (< 1sec) may cause lag but offer quicker response
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define EEPSIZE 2560
|
#define EEPSIZE 2560
|
||||||
|
|
||||||
//eeprom Version code, enables default settings instead of 0 init on update
|
//eeprom Version code, enables default settings instead of 0 init on update
|
||||||
#define EEPVER 10
|
#define EEPVER 11
|
||||||
//0 -> old version, default
|
//0 -> old version, default
|
||||||
//1 -> 0.4p 1711272 and up
|
//1 -> 0.4p 1711272 and up
|
||||||
//2 -> 0.4p 1711302 and up
|
//2 -> 0.4p 1711302 and up
|
||||||
@ -18,6 +18,7 @@
|
|||||||
//8 -> 0.8.0-a and up
|
//8 -> 0.8.0-a and up
|
||||||
//9 -> 0.8.0
|
//9 -> 0.8.0
|
||||||
//10-> 0.8.2
|
//10-> 0.8.2
|
||||||
|
//11-> 0.8.5-dev #mqttauth @TimothyBrown
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -253,9 +254,12 @@ void saveSettingsToEEPROM()
|
|||||||
EEPROM.write(2290 + i, timerMacro[i] );
|
EEPROM.write(2290 + i, timerMacro[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
writeStringToEEPROM(2300, mqttServer, 32);
|
writeStringToEEPROM(2300, mqttServer, 32);
|
||||||
writeStringToEEPROM(2333, mqttDeviceTopic, 32);
|
writeStringToEEPROM(2333, mqttDeviceTopic, 32);
|
||||||
writeStringToEEPROM(2366, mqttGroupTopic, 32);
|
writeStringToEEPROM(2366, mqttGroupTopic, 32);
|
||||||
|
writeStringToEEPROM(2399, mqttUser, 32);
|
||||||
|
writeStringToEEPROM(2432, mqttPass, 32);
|
||||||
|
writeStringToEEPROM(2465, mqttClientID, 32);
|
||||||
|
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
@ -454,9 +458,9 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
|
|
||||||
if (lastEEPROMversion > 8)
|
if (lastEEPROMversion > 8)
|
||||||
{
|
{
|
||||||
readStringFromEEPROM(2300, mqttServer, 32);
|
readStringFromEEPROM(2300, mqttServer, 32);
|
||||||
readStringFromEEPROM(2333, mqttDeviceTopic, 32);
|
readStringFromEEPROM(2333, mqttDeviceTopic, 32);
|
||||||
readStringFromEEPROM(2366, mqttGroupTopic, 32);
|
readStringFromEEPROM(2366, mqttGroupTopic, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastEEPROMversion > 9)
|
if (lastEEPROMversion > 9)
|
||||||
@ -471,6 +475,13 @@ void loadSettingsFromEEPROM(bool first)
|
|||||||
strip.ablMilliampsMax = ABL_MILLIAMPS_DEFAULT;
|
strip.ablMilliampsMax = ABL_MILLIAMPS_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastEEPROMversion > 10)
|
||||||
|
{
|
||||||
|
readStringFromEEPROM(2399, mqttUser, 32);
|
||||||
|
readStringFromEEPROM(2432, mqttPass, 32);
|
||||||
|
readStringFromEEPROM(2465, mqttClientID, 32);
|
||||||
|
}
|
||||||
|
|
||||||
receiveDirect = !EEPROM.read(2200);
|
receiveDirect = !EEPROM.read(2200);
|
||||||
notifyMacro = EEPROM.read(2201);
|
notifyMacro = EEPROM.read(2201);
|
||||||
uiConfiguration = EEPROM.read(2202);
|
uiConfiguration = EEPROM.read(2202);
|
||||||
|
@ -308,6 +308,9 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
sappend('c',"SA",notifyAlexa);
|
sappend('c',"SA",notifyAlexa);
|
||||||
sappends('s',"BK",(char*)((blynkEnabled)?"Hidden":""));
|
sappends('s',"BK",(char*)((blynkEnabled)?"Hidden":""));
|
||||||
sappends('s',"MS",mqttServer);
|
sappends('s',"MS",mqttServer);
|
||||||
|
sappends('s',"MQTTUSER",mqttUser);
|
||||||
|
sappends('s',"MQTTPASS",mqttPass);
|
||||||
|
sappends('s',"MQTTCID",mqttClientID);
|
||||||
sappends('s',"MD",mqttDeviceTopic);
|
sappends('s',"MD",mqttDeviceTopic);
|
||||||
sappends('s',"MG",mqttGroupTopic);
|
sappends('s',"MG",mqttGroupTopic);
|
||||||
sappend('v',"H0",hueIP[0]);
|
sappend('v',"H0",hueIP[0]);
|
||||||
|
@ -177,6 +177,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
strcpy(mqttServer, request->arg("MS").c_str());
|
strcpy(mqttServer, request->arg("MS").c_str());
|
||||||
|
strcpy(mqttUser, request->arg("MQTTUSER").c_str());
|
||||||
|
strcpy(mqttPass, request->arg("MQTTPASS").c_str());
|
||||||
|
strcpy(mqttClientID, request->arg("MQTTCID").c_str());
|
||||||
strcpy(mqttDeviceTopic, request->arg("MD").c_str());
|
strcpy(mqttDeviceTopic, request->arg("MD").c_str());
|
||||||
strcpy(mqttGroupTopic, request->arg("MG").c_str());
|
strcpy(mqttGroupTopic, request->arg("MG").c_str());
|
||||||
|
|
||||||
|
@ -85,6 +85,11 @@ void wledInit()
|
|||||||
strcpy(mqttDeviceTopic, "wled/");
|
strcpy(mqttDeviceTopic, "wled/");
|
||||||
strcat(mqttDeviceTopic, escapedMac.c_str());
|
strcat(mqttDeviceTopic, escapedMac.c_str());
|
||||||
}
|
}
|
||||||
|
if (mqttClientID[0] == 0)
|
||||||
|
{
|
||||||
|
strcpy(mqttClientID, "WLED-");
|
||||||
|
sprintf(mqttClientID+5, "%*s", 6, escapedMac.c_str()+6);
|
||||||
|
}
|
||||||
|
|
||||||
strip.service();
|
strip.service();
|
||||||
|
|
||||||
|
@ -227,7 +227,9 @@ bool initMqtt()
|
|||||||
} else {
|
} else {
|
||||||
mqtt->setServer(mqttServer, WLED_MQTT_PORT);
|
mqtt->setServer(mqttServer, WLED_MQTT_PORT);
|
||||||
}
|
}
|
||||||
mqtt->setClientId(escapedMac.c_str());
|
//mqtt->setClientId(escapedMac.c_str());
|
||||||
|
mqtt->setClientId(mqttClientID);
|
||||||
|
if (mqttUser[0] && mqttPass[0] != 0) mqtt->setCredentials(mqttUser, mqttPass);
|
||||||
mqtt->onMessage(onMqttMessage);
|
mqtt->onMessage(onMqttMessage);
|
||||||
mqtt->onConnect(onMqttConnect);
|
mqtt->onConnect(onMqttConnect);
|
||||||
mqtt->connect();
|
mqtt->connect();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user