updated WM and aliot loop scheduler

This commit is contained in:
strawmanbobi
2022-09-01 10:53:54 +08:00
parent e8cd9d4c84
commit d5f9e3b5a0
42 changed files with 7061 additions and 1159 deletions

View File

@@ -186,6 +186,7 @@ void setup() {
void loop() {
recvIR();
yield();
aliotKeepAlive();
}
void factoryReset() {

View File

@@ -84,27 +84,8 @@ void connectToAliyunIoT() {
}
void checkAlinkMQTT() {
int mqttStatus = 0;
mqttStatus = iot.loop();
if (0 == mqttStatus) {
iot_retry = 0;
if (false == downstream_topic_subscribed) {
INFOF("subscribe topic : %s\n", g_downstream_topic.c_str());
registerCallback(g_downstream_topic.c_str(), 0);
downstream_topic_subscribed = true;
} else {
sendIrisKitHeartBeat();
}
} else {
INFOF("Alink MQTT check failed, retry = %d\n", iot_retry);
iot_retry++;
}
if (iot_retry >= IOT_RETRY_MAX) {
ERRORLN("Alink could not established, something went wrong, reset...");
factoryReset();
}
void aliotKeepAlive() {
iot.loop();
}
// not only for IRIS related topic based session
@@ -129,3 +110,25 @@ static void irisAlinkCallback(const char *topic, uint8_t *data, int length) {
handleIrisKitMessage((const char*) data, length);
}
}
void checkAlinkMQTT() {
int mqttStatus = 0;
if (0 == mqttStatus) {
iot_retry = 0;
if (false == downstream_topic_subscribed) {
INFOF("subscribe topic : %s\n", g_downstream_topic.c_str());
registerCallback(g_downstream_topic.c_str(), 0);
downstream_topic_subscribed = true;
} else {
sendIrisKitHeartBeat();
}
} else {
INFOF("Alink MQTT check failed, retry = %d\n", iot_retry);
iot_retry++;
}
if (iot_retry >= IOT_RETRY_MAX) {
ERRORLN("Alink could not established, something went wrong, reset...");
factoryReset();
}
}

View File

@@ -37,6 +37,8 @@ typedef enum {
void connectToAliyunIoT();
void aliotKeepAlive();
void checkAlinkMQTT();
AliyunIoTSDK getSession();

View File

@@ -47,8 +47,8 @@ typedef unsigned char uint8_t;
/* ----------------- user settings ----------------- */
/* mqtt settings */
#define MQTT_CHECK_INTERVALS 30 // seconds
#define MQTT_CONNECT_WAIT_TIME 20000 // MQTT 连接等待时间
#define MQTT_CHECK_INTERVALS 30 // seconds
#define MQTT_CONNECT_WAIT_TIME 20000 // MQTT 连接等待时间
/* receive disable */
#define DISABLE_SIGNAL_INTERVALS 600 // seconds