From 700f2e82abc0ce7215f69a9027a85d4d440639b1 Mon Sep 17 00:00:00 2001 From: vmasdani Date: Fri, 1 Feb 2019 14:40:07 +0700 Subject: [PATCH] Added client ID --- src/AntaresESP8266MQTT.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/AntaresESP8266MQTT.cpp b/src/AntaresESP8266MQTT.cpp index d8197a5..ed13f0d 100644 --- a/src/AntaresESP8266MQTT.cpp +++ b/src/AntaresESP8266MQTT.cpp @@ -24,8 +24,16 @@ void AntaresESP8266MQTT::checkMqttConnection() { if(!client.connected()) { while(!client.connected()) { printDebug("[ANTARES] Attempting MQTT connection...\n"); - if(client.connect("ESP8266-TESTVALIAN")) { - printDebug("[ANTARES] Connected!"); + + String clientId = "ESP8266-" + _accessKey; + + char clientIdChar[clientId.length() + 1]; + clientId.toCharArray(clientIdChar, clientId.length() + 1); + + if(client.connect(clientIdChar)) { + printDebug("[ANTARES] Connected! Client ID:"); + printDebug(clientIdChar); + printDebug("\n"); char subscriptionTopicChar[_subscriptionTopic.length() + 1]; _subscriptionTopic.toCharArray(subscriptionTopicChar, _subscriptionTopic.length() + 1);