Merge pull request from debsahu/master

Added #define ENABLE_MQTT_HOSTNAME_CHIPID, disabled by default
This commit is contained in:
Deb 2018-04-24 16:53:17 -04:00 committed by GitHub
commit 8520e9b350
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions
Arduino/McLighting

View file

@ -413,24 +413,24 @@ void setup() {
// Configure MQTT
// ***************************************************************************
#ifdef ENABLE_MQTT
if (mqtt_host != "" && String(mqtt_port).toInt() > 0) {
if (mqtt_host != "" && atoi(mqtt_port) > 0) {
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());
mqtt_client.setServer(mqtt_host, String(mqtt_port).toInt());
mqtt_client.setServer(mqtt_host, atoi(mqtt_port));
mqtt_client.setCallback(mqtt_callback);
}
#endif
#ifdef ENABLE_AMQTT
if (mqtt_host != "" && String(mqtt_port).toInt() > 0) {
if (mqtt_host != "" && atoi(mqtt_port) > 0) {
amqttClient.onConnect(onMqttConnect);
amqttClient.onDisconnect(onMqttDisconnect);
amqttClient.onMessage(onMqttMessage);
amqttClient.setServer(mqtt_host, String(mqtt_port).toInt());
amqttClient.setCredentials(mqtt_user, mqtt_pass);
amqttClient.setServer(mqtt_host, atoi(mqtt_port));
if (mqtt_user != "" or mqtt_pass != "") amqttClient.setCredentials(mqtt_user, mqtt_pass);
amqttClient.setClientId(mqtt_clientid);
connectToMqtt();
@ -969,4 +969,4 @@ void loop() {
EEPROM.commit();
}
#endif
}
}

View file

@ -70,7 +70,13 @@ uint32_t autoParams[][4] = { // color, speed, mode, duration (seconds)
uint16_t color_temp = 327; // min is 154 and max is 500
#endif
const char mqtt_clientid[] = "NeoPixelsStrip"; // MQTT ClientID
//#define ENABLE_MQTT_HOSTNAME_CHIPID // Uncomment/comment to add ESPChipID to end of MQTT hostname
#ifdef ENABLE_MQTT_HOSTNAME_CHIPID
const char* mqtt_clientid = String(String(HOSTNAME) + "-" + String(ESP.getChipId())).c_str(); // MQTT ClientID
#else
const char* mqtt_clientid = HOSTNAME; // MQTT ClientID
#endif
char mqtt_host[64] = "";
char mqtt_port[6] = "";
@ -140,4 +146,4 @@ LEDState main_color = { 255, 0, 0 }; // Store the "main color" of the strip use
byte KeyPressCount = 0;
byte prevKeyState = HIGH; // button is active low
boolean buttonState = false;
#endif
#endif