存储EEPROM的问题-Arduino中文社区 - Powered by Discuz! Archiver

guosaijun 发表于 2019-8-3 08:16

存储EEPROM的问题

/* *****************************************************************
*
* Download latest Blinker library here:
* https://github.com/blinker-iot/blinker-library/archive/master.zip
*
*
* Blinker is a cross-hardware, cross-platform solution for the IoT.
* It provides APP, device and server support,
* and uses public cloud services for data transmission and storage.
* It can be used in smart home, data monitoring and other fields
* to help users build Internet of Things projects better and faster.
*
* Make sure installed 2.5.0 or later ESP8266/Arduino package,
* if use ESP8266 with Blinker.
* https://github.com/esp8266/Arduino/releases
*
* Make sure installed 1.0.2 or later ESP32/Arduino package,
* if use ESP32 with Blinker.
* https://github.com/espressif/arduino-esp32/releases
*
* Docs: https://doc.blinker.app/
*       https://github.com/blinker-iot/blinker-doc/wiki
*
* *****************************************************************
*
* Blinker 库下载地址:
* https://github.com/blinker-iot/blinker-library/archive/master.zip
*
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
*
* 如果使用 ESP8266 接入 Blinker,
* 请确保安装了 2.5.0 或更新的 ESP8266/Arduino 支持包。
* https://github.com/esp8266/Arduino/releases
*
* 如果使用 ESP32 接入 Blinker,
* 请确保安装了 1.0.2 或更新的 ESP32/Arduino 支持包。
* https://github.com/espressif/arduino-esp32/releases
*
* 文档: https://doc.blinker.app/
*       https://github.com/blinker-iot/blinker-doc/wiki
*
* *****************************************************************/

#define BLINKER_WIFI

#include <Blinker.h>

char auth[] = "aaa";
char ssid[] = "bbb";
char pswd[] = "ccc";

int AK4 = 0;

#define BUTTON_1 "ButtonKey"

BlinkerButton Button1(BUTTON_1);

void button1_callback(const String & state)
{
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
    BLINKER_LOG("get button state: ", state);

    if (state == BLINKER_CMD_BUTTON_TAP) {
      BLINKER_LOG("Button tap!");

      Button1.icon("icon_1");
      Button1.color("#FFFFFF");
      Button1.text("Your button name or describe");
      Button1.print();
      AK4 = 1;
    }
    else if (state == BLINKER_CMD_BUTTON_PRESSED) {
      BLINKER_LOG("Button pressed!");

      Button1.icon("icon_1");
      Button1.color("#FFFFFF");
      Button1.text("Your button name or describe");
      Button1.print();
      AK4 = 1;
    }
    else if (state == BLINKER_CMD_BUTTON_RELEASED) {
      BLINKER_LOG("Button released!");

      Button1.icon("icon_1");
      Button1.color("#FFFFFF");
      Button1.text("Your button name or describe");
      // Button1.text("Your button name", "describe");
      Button1.print();
      AK4 = 1;
    }
    else if (state == BLINKER_CMD_ON) {
      BLINKER_LOG("Toggle on!");

      Button1.icon("icon_1");
      Button1.color("#FFFFFF");
      Button1.text("Your button name or describe");
      // Button1.text("Your button name", "describe");
      Button1.print("on");
      AK4 = 1;
    }
    else if (state == BLINKER_CMD_OFF) {
      BLINKER_LOG("Toggle off!");

      Button1.icon("icon_1");
      Button1.color("#FFFFFF");
      Button1.text("Your button name or describe");
      // Button1.text("Your button name", "describe");
      Button1.print("off");
      AK4 = 1;
    }
    else {
      BLINKER_LOG("Get user setting: ", state);

      Button1.icon("icon_1");
      Button1.color("#FFFFFF");
      Button1.text("Your button name or describe");
      // Button1.text("Your button name", "describe");
      Button1.print();
      AK4 = 1;
    }
}

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);
    BLINKER_DEBUG.debugAll();//开启调试,你可以在串口监视器中看到相应信息。
   
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, LOW);

    Blinker.begin(auth, ssid, pswd);
    Blinker.attachData(dataRead);
    Button1.attach(button1_callback);
}

void loop()
{
    Blinker.run();
    EEPwrite();
}

void EEPwrite(){
if (AK4 == 1){
EEPROM.begin(4096);
for(int a = 0;a<6;a++){
EEPROM.write( a+3000,a);
}
for(int a = 0;a<4;a++){
EEPROM.write( a+3006,a);
}
EEPROM.commit();
AK4 = 0;
}

}


每次按按键就会储存下参数,
但是按了就死机重启 。
原来用不是认证版的不会重启的!

parse data: {"ButtonKey":"tap"}
defined BLINKER_ARDUINOJSON
strWidgetsParse isParsed
strWidgetsParse: ButtonKey
get button state: tap
Button tap!
autoFormatData key: ButtonKey, json: "ButtonKey":{"ico":"icon_1","clr":"#FFFFFF","tex":"Your button name or describe"}
new.
isParsed

Abort called

>>>stack>>>

ctx: cont
sp: 3ffffdb0 end: 3fffffc0 offset: 01b0
3fffff60:feefeffe 3fff0378 3fff0e08 402282b4
3fffff70:0000df47 00000000 00000000 4021d000
3fffff80:00000000 3fff0e08 3fff0f40 402039ae
3fffff90:3fffdad0 00000000 3fff0f40 40210503
3fffffa0:3fffdad0 00000000 3fff0f40 4021ec8c
3fffffb0:feefeffe feefeffe 3ffe8590 40100b05
<<<stack<<<

last failed alloc call: 402282E4(4096)

ets Jan8 2013,rst cause:2, boot mode:(1,0)


ets Jan8 2013,rst cause:4, boot mode:(1,0)

wdt reset

奈何col 发表于 2019-8-3 12:45

经测试,最新blinker lib+ 2.5.2 8266 package,表现正常,因此该问题应该不是软件方面问题

xuejy628 发表于 2019-11-21 11:22

我也到这样的的问题,怎么解决?
页: [1]
查看完整版本: 存储EEPROM的问题