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