请问一下大家,为什么串口log输出,频繁的时候每一分钟出现一次Connection failed,5秒钟后重新连接又连接成功,很稳定的一分钟出现一次
下面是我代码(代码就是例程HELLO_WIFI,就define了引脚,其他什么都没改)
#define BLINKER_WIFI
#define LED_BUILTIN 2
#include <Blinker.h>
char auth[] = "******";
char ssid[] = "TP-LINK_**C";
char pswd[] = "*******";
// 新建组件对象
BlinkerButton Button1("btn-abc");
BlinkerNumber Number1("num-abc");
int counter = 0;
// 按下按键即会执行该函数
void button1_callback(const String & state)
{
BLINKER_LOG("get button state: ", state);
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
// 如果未绑定的组件被触发,则会执行其中内容
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
counter++;
Number1.print(counter);
}
void setup()
{
// 初始化串口
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
// 初始化有LED的IO
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
// 初始化blinker
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
Button1.attach(button1_callback);
}
void loop() {
Blinker.run();
}
下面是串口打印的log
16:24:42.815 -> [9440] =======================================================
16:24:42.815 -> [9440] =========== Blinker Auto Control mode init! ===========
16:24:42.815 -> [9444] Warning!EEPROM address 0-1279 is used for Auto Control!
16:24:42.815 -> [9450] =========== DON'T USE THESE EEPROM ADDRESS! ===========
16:24:42.815 -> [9455] =======================================================
16:25:12.773 -> [39456] MQTT Ping!
16:25:33.366 -> [60051] Connecting to MQTT...
16:25:33.400 -> [60062] Connection failed
16:25:33.400 -> [60062] Retrying MQTT connection in 5 seconds...
16:25:38.390 -> [65062] Connecting to MQTT...
16:25:39.340 -> [66022] MQTT Connected!
16:25:39.340 -> [66022] Freeheap: 10784
16:26:09.348 -> [96027] MQTT Ping!
16:26:33.375 -> [120047] Connecting to MQTT...
16:26:35.344 -> [122010] MQTT Connected!
16:26:35.344 -> [122011] Freeheap: 10720
16:27:05.364 -> [152030] MQTT Ping!
16:27:33.366 -> [180041] Connecting to MQTT...
16:27:35.333 -> [181996] MQTT Connected!
16:27:35.333 -> [181996] Freeheap: 11200
16:28:05.339 -> [212017] MQTT Ping!
16:28:33.373 -> [240039] Connecting to MQTT...
16:28:33.407 -> [240049] Connection failed
16:28:33.407 -> [240050] Retrying MQTT connection in 5 seconds...
16:28:38.391 -> [245050] Connecting to MQTT...
16:28:39.342 -> [246000] MQTT Connected!
16:28:39.342 -> [246000] Freeheap: 11168
谢谢各位大神了 |