added debug information
This commit is contained in:
@@ -132,7 +132,7 @@ int AliyunIoTSDK::mqttCheckConnect() {
|
||||
connectRetry = 0;
|
||||
while (false == client->connected()) {
|
||||
client->disconnect();
|
||||
Serial.print("INFO: Connecting to MQTT Server, clientId = ");
|
||||
Serial.print("INFO: Connecting to Aliyun MQTT Server, clientId = ");
|
||||
Serial.print(clientId);
|
||||
Serial.print(", mqttUserName = ");
|
||||
Serial.print(mqttUsername);
|
||||
@@ -145,6 +145,7 @@ int AliyunIoTSDK::mqttCheckConnect() {
|
||||
} else {
|
||||
Serial.print("ERROR: MQTT Connect err: ");
|
||||
Serial.println(client->state());
|
||||
client->disconnect();
|
||||
delay(MQTT_WAIT_GENERIC);
|
||||
connectRetry++;
|
||||
Serial.print("INFO: Aliot connection retry: ");
|
||||
|
||||
@@ -62,7 +62,7 @@ int connectToAliot(PubSubClient& mqtt_client) {
|
||||
if (0 == res && mqtt_client.connected()) {
|
||||
INFOF("Aliyun IoT connected\n");
|
||||
} else {
|
||||
ERRORF("Failed to connect to Aliyun IoT\n");
|
||||
ERRORF("Failed to connect to Aliyun IoT : %d\n", res);
|
||||
res = -1;
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -139,6 +139,8 @@ void keepAliveIot() {
|
||||
unsigned long current_time = millis();
|
||||
if (current_time - last_check_time > 10000) {
|
||||
if (!g_mqtt_client.connected()) {
|
||||
ERRORF("MQTT client is not connected, force disconnect and retry\n");
|
||||
g_mqtt_client.disconnect();
|
||||
g_mqtt_client.unsubscribe(g_downstream_topic.c_str());
|
||||
g_subscribed = false;
|
||||
connectIot();
|
||||
|
||||
Reference in New Issue
Block a user