|
setup()里增加了EEPROM_Init(); 函数就不行了,去掉的话运行正常
//读取失败或读到密钥或长度不对,就采用默认值
void EEPROM_Init(void) //FLASH初始化
{
char write_data[100]; //用户数据存储空间
uint16_t i;
uint8_t Key_len;
EEPROM.begin(3000 + 100); //申请操作100字节数据
for(i = 0; i < 100; i ++)
{
write_data[i] = EEPROM.read(i + 3000); //读数据
}
Key_len = write_data[0];
Serial.printf("Key_len = %d\r\n", Key_len);
if ((Key_len < 5) || (Key_len > 20)) //读到的长度不对,认为是第一次上电,用默认值
{
pKey = KEY;
}
else
{
pKey = (char *)zalloc(Key_len + 1);
strncpy(pKey, write_data + 10, Key_len);
}
Serial.printf("Key:%s\r\n", pKey);
}
void setup()
{
Serial.begin(115200); //初始化串口
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT); //初始化有LED的IO
digitalWrite(LED_BUILTIN, HIGH); //高为关,低为开
EEPROM_Init(); //FLASH初始化
Blinker.begin(auth); //使用smartconfig进行配网//初始化blinker
Blinker.attachData(dataRead); //注册回调函数,当有设备收到APP发来的数据时会调用对应的回调函数pKey
Button1.attach(button1_callback); //组件回调函数
。。。。。。。。。。。。。。
但是从串口打印信息来看,早就过了EEROM函数运行的地方了,也不知道哪里导致的复位
HTTP server started
Open http://192.168.8.109/update in your browser to update
Open http://192.168.8.109/set in your browser to set
[1132] WiFi Connected.
[1134] IP Address:
[1136] 192.168.8.109
[5003] Freeheap: 7136
[5006] mDNS responder started
[5007] webSocket_MQTT server started
[5007] ws://9CE8EF10FE7PE7TM8X7DJUZK.local:81
[7140] Connecting to MQTT...
[9400] MQTT Connected!
[9401] Freeheap: 7416
[9401] =======================================================
[9401] =========== Blinker Auto Control mode init! ===========
[9405] Warning!EEPROM address 0-1279 is used for Auto Control!
[9410] =========== DON'T USE THESE EEPROM ADDRESS! ===========
[9416] =======================================================
Exception (28):
epc1=0x4022684a epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffd70 end: 3fffffc0 offset: 01a0
3fffff10: 00000000 3fff0158 3ffeff58 40202e49
3fffff20: 4027ff14 80ff0073 3fff0424 00001778
3fffff30: 3fff0afc 3fff0158 3ffeff58 40205c90
3fffff40: 0000046c 3fff0158 3ffeff58 40213241
3fffff50: 3fff0f90 00000001 3ffefdd0 40226b74
3fffff60: 00f42400 38ffe28b 3ffefd00 40213ec9
3fffff70: 000024b9 00000000 00001388 4022658c
3fffff80: 00000000 00000000 00000001 3fff10ec
3fffff90: 3fffdad0 00000000 3fff10ac 40213fac
3fffffa0: 3fffdad0 00000000 3fff10ac 40224db4
3fffffb0: feefeffe feefeffe 3ffe856c 40100325
<<<stack<<<
last failed alloc call: 4021E948
|
|