8266 AP配网后,断电重启后卡死在读取配网信息的界面上-Arduino中文社区 - Powered by Discuz! Archiver

wangjing123 发表于 2021-12-7 09:21

8266 AP配网后,断电重启后卡死在读取配网信息的界面上

本帖最后由 wangjing123 于 2021-12-7 15:03 编辑

#define BLINKER_PRINT Serial
#define BLINKER_WIFI
#define BLINKER_APCONFIG
#define BLINKER_ALIGENIE_OUTLET
#define BLINKER_BUTTON_PIN 4

#include <Blinker.h>
#include "OneButton.h"

char auth[] = "";
//char ssid[] = "";
//char pswd[] = "";

// 新建组件对象
BlinkerButton Button1("btn-abc");
OneButton button(BLINKER_BUTTON_PIN, true);

int JIDIANQI = 13;
int SUCCESS = 12;
bool oState = false;

void deviceReset()
{
    Blinker.reset();
}

void aligeniePowerState(const String & state)
{
    BLINKER_LOG("need set power state: ", state);

    if (state == BLINKER_CMD_ON) {
      digitalWrite(JIDIANQI, HIGH);

      BlinkerAliGenie.powerState("on");
      BlinkerAliGenie.print();

      oState = true;
    }
    else if (state == BLINKER_CMD_OFF) {
      digitalWrite(JIDIANQI, LOW);

      BlinkerAliGenie.powerState("off");
      BlinkerAliGenie.print();

      oState = false;
    }
}

void aligenieQuery(int32_t queryCode)
{
    BLINKER_LOG("AliGenie Query codes: ", queryCode);

    switch (queryCode)
    {
      case BLINKER_CMD_QUERY_ALL_NUMBER :
            BLINKER_LOG("AliGenie Query All");
            BlinkerAliGenie.powerState(oState ? "on" : "off");
            BlinkerAliGenie.print();
            break;
      case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
            BLINKER_LOG("AliGenie Query Power State");
            BlinkerAliGenie.powerState(oState ? "on" : "off");
            BlinkerAliGenie.print();
            break;
      default :
            BlinkerAliGenie.powerState(oState ? "on" : "off");
            BlinkerAliGenie.print();
            break;
    }
}

// 按下按键即会执行该函数
void button1_callback(const String & state)
{
    BLINKER_LOG("get button state: ", state);
    digitalWrite(JIDIANQI, !digitalRead(JIDIANQI));
}

void dataRead(const String & data)
{
    BLINKER_LOG("Blinker readString: ", data);

    Blinker.vibrate();

    uint32_t BlinkerTime = millis();

    Blinker.print("millis", BlinkerTime);
}

void setup()
{
    // 初始化串口
    Serial.begin(115200);
    BLINKER_DEBUG.stream(Serial);
    pinMode(JIDIANQI, OUTPUT);
    digitalWrite(JIDIANQI, HIGH);
    //pinMode(SUCCESS, OUTPUT);
    //digitalWrite(SUCCESS, HIGH);
    //Blinker.begin(auth,ssid,pswd);
    Blinker.begin(auth);
    Blinker.attachData(dataRead);
    BlinkerAliGenie.attachPowerState(aligeniePowerState);
    BlinkerAliGenie.attachQuery(aligenieQuery);
    Button1.attach(button1_callback);
    button.attachLongPressStop(deviceReset);
}

void loop()
{
    Blinker.run();
    button.tick();
    //while(!Blinker.connect()) {
//      digitalWrite(SUCCESS, HIGH);
   //   delay(500);
      //digitalWrite(SUCCESS, LOW);
      //delay(500);
//}
       // digitalWrite(SUCCESS, LOW);
}

wangjing123 发表于 2021-12-7 09:24

本帖最后由 wangjing123 于 2021-12-7 09:25 编辑

串口如下
09:24:13.696 ->
09:24:14.164 ->__       __                __
09:24:14.164 -> /\ \   /\ \    __      /\ \            v0.3.80210927
09:24:14.164 -> \ \ \___ \ \ \/\_\    ___\ \ \/'\      __   _ __   
09:24:14.211 ->\ \ '__`\\ \ \ \/\ \ /' _ `\ \ , <    /'__`\/\`'__\
09:24:14.211 ->   \ \ \L\ \\ \ \_\ \ \/\ \/\ \ \ \\`\ /\__/\ \ \./
09:24:14.211 ->    \ \_,__/ \ \__\\ \_\ \_\ \_\ \_\ \_\ \____\\ \_\
09:24:14.211 ->   \/___/   \/__/ \/_/\/_/\/_/\/_/\/_/\/____/ \/_/
09:24:14.211 ->   To better use blinker with your IoT project!
09:24:14.211 ->   Download latest blinker library here!
09:24:14.211 ->   => https://github.com/blinker-iot/blinker-library
09:24:14.211 ->
09:24:14.211 -> wlan config check,success
09:24:14.725 -> Connecting to WiFi:
09:24:14.725 -> ESP8266_MQTT initialized...
09:24:14.725 ->
09:24:14.725 -> ===========================================================
09:24:14.725 -> ================== Blinker Timer loaded! ==================
09:24:14.725 ->      EEPROM address 1536-2431 is used for Blinker Timer!
09:24:14.725 -> ========= PLEASE AVOID USING THESE EEPROM ADDRESS! ========
09:24:14.725 -> ===========================================================
09:24:14.725 ->

页: [1]
查看完整版本: 8266 AP配网后,断电重启后卡死在读取配网信息的界面上