Fix for empty intopic?

https://github.com/toblum/McLighting/issues/52
This commit is contained in:
Tobias Blum 2017-11-05 01:12:51 +01:00
parent a025e0a35a
commit e79524ed8e
2 changed files with 4 additions and 4 deletions

View file

@ -300,8 +300,8 @@ void setup() {
// ***************************************************************************
#ifdef ENABLE_MQTT
if (mqtt_host != "" && String(mqtt_port).toInt() > 0) {
String(String(HOSTNAME) + "/in").toCharArray(mqtt_intopic, strlen(HOSTNAME) + 4);
String(String(HOSTNAME) + "/out").toCharArray(mqtt_outtopic, strlen(HOSTNAME) + 5);
snprintf(mqtt_intopic, sizeof mqtt_intopic, "%s/in", HOSTNAME);
snprintf(mqtt_outtopic, sizeof mqtt_outtopic, "%s/out", HOSTNAME);
DBG_OUTPUT_PORT.printf("MQTT active: %s:%d\n", mqtt_host, String(mqtt_port).toInt());

View file

@ -22,8 +22,8 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
int mqtt_reconnect_retries = 0;
char mqtt_intopic[strlen(HOSTNAME) + 3]; // Topic in will be: <HOSTNAME>/in
char mqtt_outtopic[strlen(HOSTNAME) + 4]; // Topic out will be: <HOSTNAME>/out
char mqtt_intopic[strlen(HOSTNAME) + 4]; // Topic in will be: <HOSTNAME>/in
char mqtt_outtopic[strlen(HOSTNAME) + 5]; // Topic out will be: <HOSTNAME>/out
const char mqtt_clientid[] = "ESP8266Client"; // MQTT ClientID