added debug information

This commit is contained in:
strawmanbobi
2025-01-22 13:50:06 +08:00
parent 65bd953cff
commit 0e2678625f
3 changed files with 5 additions and 2 deletions

View File

@@ -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: ");

View File

@@ -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;

View File

@@ -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();