Merge pull request #151 from debsahu/master
Added #define ENABLE_MQTT_HOSTNAME_CHIPID, disabled by default
This commit is contained in:
commit
8520e9b350
2 changed files with 14 additions and 8 deletions
Arduino/McLighting
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue