Skip to content

Commit

Permalink
Added MQTT port field, bumped user, pass and CID to 40 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
timothybrown committed Aug 18, 2019
1 parent 95b33c9 commit c57124e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
7 changes: 4 additions & 3 deletions wled00/html_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,10 @@ 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>
<h3>MQTT</h3>
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>
Port: <input name="MQTTPORT" maxlength="5"><br>
Username: <input name="MQTTUSER" maxlength="40"><br>
Password: <input type="password" input name="MQTTPASS" maxlength="40"><br>
Client ID: <input name="MQTTCID" maxlength="40"><br>
Device Topic: <input name="MD" 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>
Expand Down
9 changes: 5 additions & 4 deletions wled00/wled00.ino
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@


//version code in format yymmddb (b = daily build)
#define VERSION 1906201
#define VERSION 190817
char versionString[] = "0.8.5-dev";


Expand Down Expand Up @@ -204,9 +204,10 @@ bool e131Multicast = false;
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 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
char mqttUser[41] = ""; //optional: username for MQTT auth
char mqttPass[41] = ""; //optional: password for MQTT auth
char mqttClientID[41] = ""; //override the client ID
char mqttPort[6] = "";

bool huePollingEnabled = false; //poll hue bridge for light state
uint16_t huePollIntervalMs = 2500; //low values (< 1sec) may cause lag but offer quicker response
Expand Down
14 changes: 8 additions & 6 deletions wled00/wled01_eeprom.ino
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ void saveSettingsToEEPROM()
writeStringToEEPROM(2300, mqttServer, 32);
writeStringToEEPROM(2333, mqttDeviceTopic, 32);
writeStringToEEPROM(2366, mqttGroupTopic, 32);
writeStringToEEPROM(2399, mqttUser, 32);
writeStringToEEPROM(2432, mqttPass, 32);
writeStringToEEPROM(2465, mqttClientID, 32);
writeStringToEEPROM(2399, mqttUser, 40);
writeStringToEEPROM(2440, mqttPass, 40);
writeStringToEEPROM(2481, mqttClientID, 40);
writeStringToEEPROM(2522, mqttPort, 5);

EEPROM.commit();
}
Expand Down Expand Up @@ -477,9 +478,10 @@ void loadSettingsFromEEPROM(bool first)

if (lastEEPROMversion > 10)
{
readStringFromEEPROM(2399, mqttUser, 32);
readStringFromEEPROM(2432, mqttPass, 32);
readStringFromEEPROM(2465, mqttClientID, 32);
readStringFromEEPROM(2399, mqttUser, 40);
readStringFromEEPROM(2440, mqttPass, 40);
readStringFromEEPROM(2481, mqttClientID, 40);
readStringFromEEPROM(2522, mqttPort, 5);
}

receiveDirect = !EEPROM.read(2200);
Expand Down
1 change: 1 addition & 0 deletions wled00/wled02_xml.ino
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',"SA",notifyAlexa);
sappends('s',"BK",(char*)((blynkEnabled)?"Hidden":""));
sappends('s',"MS",mqttServer);
sappends('s',"MQTTPORT",mqttPort);
sappends('s',"MQTTUSER",mqttUser);
sappends('s',"MQTTPASS",mqttPass);
sappends('s',"MQTTCID",mqttClientID);
Expand Down
1 change: 1 addition & 0 deletions wled00/wled03_set.ino
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
}

strcpy(mqttServer, request->arg("MS").c_str());
strcpy(mqttPort, request->arg("MQTTPORT").c_str());
strcpy(mqttUser, request->arg("MQTTUSER").c_str());
strcpy(mqttPass, request->arg("MQTTPASS").c_str());
strcpy(mqttClientID, request->arg("MQTTCID").c_str());
Expand Down
4 changes: 4 additions & 0 deletions wled00/wled05_init.ino
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ void wledInit()
strcpy(mqttClientID, "WLED-");
sprintf(mqttClientID+5, "%*s", 6, escapedMac.c_str()+6);
}
if (mqttPort[0] == 0)
{
strcpy(mqttPort, "1883");
}

strip.service();

Expand Down
6 changes: 3 additions & 3 deletions wled00/wled17_mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* MQTT communication protocol for home automation
*/

#define WLED_MQTT_PORT 1883
//#define WLED_MQTT_PORT 1883

void parseMQTTBriPayload(char* payload)
{
Expand Down Expand Up @@ -223,9 +223,9 @@ bool initMqtt()
IPAddress mqttIP;
if (mqttIP.fromString(mqttServer)) //see if server is IP or domain
{
mqtt->setServer(mqttIP, WLED_MQTT_PORT);
mqtt->setServer(mqttIP, atoi(mqttPort));
} else {
mqtt->setServer(mqttServer, WLED_MQTT_PORT);
mqtt->setServer(mqttServer, atoi(mqttPort));
}
mqtt->setClientId(mqttClientID);
if (mqttUser[0] && mqttPass[0] != 0) mqtt->setCredentials(mqttUser, mqttPass);
Expand Down

0 comments on commit c57124e

Please sign in to comment.