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

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 7771|回复: 2

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

[复制链接]
发表于 2021-12-7 09:21 | 显示全部楼层 |阅读模式
本帖最后由 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);
}

 楼主| 发表于 2021-12-7 09:24 | 显示全部楼层
本帖最后由 wangjing123 于 2021-12-7 09:25 编辑

串口如下
  1. 09:24:13.696 ->
  2. 09:24:14.164 ->  __       __                __
  3. 09:24:14.164 -> /\ \     /\ \    __        /\ \              v0.3.80210927
  4. 09:24:14.164 -> \ \ \___ \ \ \  /\_\    ___\ \ \/'\      __   _ __   
  5. 09:24:14.211 ->  \ \ '__`\\ \ \ \/\ \ /' _ `\ \ , <    /'__`\/\`'__\
  6. 09:24:14.211 ->   \ \ \L\ \\ \ \_\ \ \/\ \/\ \ \ \\`\ /\  __/\ \ \./
  7. 09:24:14.211 ->    \ \_,__/ \ \__\\ \_\ \_\ \_\ \_\ \_\ \____\\ \_\  
  8. 09:24:14.211 ->     \/___/   \/__/ \/_/\/_/\/_/\/_/\/_/\/____/ \/_/  
  9. 09:24:14.211 ->     To better use blinker with your IoT project!
  10. 09:24:14.211 ->     Download latest blinker library here!
  11. 09:24:14.211 ->     => https://github.com/blinker-iot/blinker-library
  12. 09:24:14.211 ->
  13. 09:24:14.211 -> [106] wlan config check,success
  14. 09:24:14.725 -> [606] Connecting to WiFi:
  15. 09:24:14.725 -> [607] ESP8266_MQTT initialized...
  16. 09:24:14.725 -> [607]
  17. 09:24:14.725 -> ===========================================================
  18. 09:24:14.725 -> ================== Blinker Timer loaded! ==================
  19. 09:24:14.725 ->      EEPROM address 1536-2431 is used for Blinker Timer!
  20. 09:24:14.725 -> ========= PLEASE AVOID USING THESE EEPROM ADDRESS! ========
  21. 09:24:14.725 -> ===========================================================
  22. 09:24:14.725 ->
复制代码

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 11:39 , Processed in 0.091820 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表