updated WM and aliot loop scheduler
This commit is contained in:
@@ -186,6 +186,7 @@ void setup() {
|
||||
void loop() {
|
||||
recvIR();
|
||||
yield();
|
||||
aliotKeepAlive();
|
||||
}
|
||||
|
||||
void factoryReset() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,8 @@ typedef enum {
|
||||
|
||||
void connectToAliyunIoT();
|
||||
|
||||
void aliotKeepAlive();
|
||||
|
||||
void checkAlinkMQTT();
|
||||
|
||||
AliyunIoTSDK getSession();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user