[md]问题现象:一直复位
android版本:9
手机型号:OPPO A51
库版本: v0.3.4
开发板:esp8266 NodeMCU1.0
LOG信息:
```
ets Jan 8 2013,rst cause:2, boot mode:(3,7)
load 0x4010f000, len 3664, room 16
tail 0
chksum 0xee
csum 0xee
v39c79d9b
~ld
[65]
[65]
__ __ __
/\ \ /\ \ __ /\ \ v0.3.4
\ \ \___ \ \ \ /\_\ ___\ \ \/'\ __ _ __
\ \ '__`\\ \ \ \/\ \ /' _ `\ \ , < /'__`\/\`'__\
\ \ \L\ \\ \ \_\ \ \/\ \/\ \ \ \\`\ /\ __/\ \ \./
\ \_,__/ \ \__\\ \_\ \_\ \_\ \_\ \_\ \____\\ \_\
\/___/ \/__/ \/_/\/_/\/_/\/_/\/_/\/____/ \/_/
To better use blinker with your IoT project!
Download latest blinker library here!
=> https://github.com/blinker-iot/blinker-library
[99] Connecting to TP-LINK_2A38
[104] ESP8266_MQTT initialized...
[104]
===========================================================
================== Blinker Timer loaded! ==================
Warning!EEPROM address 1536-2431 is used for Blinker Timer!
============= DON'T USE THESE EEPROM ADDRESS! =============
===========================================================
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
Soft WDT reset
>>>stack>>>
ctx: cont
sp: 3ffffde0 end: 3fffffc0 offset: 01a0
3fffff80: 3fffdad0 3ffef950 00000000 402103ed
3fffff90: 80006e00 feefeffe 80efeffe feefeffe
3fffffa0: 3fffdad0 00000000 3fff0b1c 40228374
3fffffb0: feefeffe feefeffe 3ffe85cc 40101181
<<<stack<<<
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
```
```
#define BLINKER_PRINT Serial //用于打开串口
#define BLINKER_WIFI
#define BLINKER_MIOT_LIGHT
#include <Blinker.h>
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRrecv.h>
#include <IRutils.h>
#define Key 5 //-----------D1
//红外遥控
const uint16_t RecvPin = 4; //定义4号引脚(D2)为信号接受脚
IRrecv myrecv(RecvPin); //创建一个信号接收对象myrecv
decode_results results; //收到后外信号解码后的值
char auth[] = "5121bddd997e";
char ssid[] = "TP-LINK_2A38";
char pswd[] = "13854359579";
int colorW;
unsigned char led_power;
u8_t wsMode;
BlinkerButton Button1("Key"); //app新建组件 Key
// app 端按下按键即会执行该函数 回调函数
void button1_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
if (state=="on") {
digitalWrite(LED_BUILTIN, LOW);
// 反馈开关状态
Button1.print("on");
} else if(state=="off"){
digitalWrite(LED_BUILTIN, HIGH);
// 反馈开关状态
Button1.print("off");
}
}
//用户自定义电源类操作的回调函数: 小米小爱
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(LED_BUILTIN, LOW);
led_power = 1;
Button1.print("on");
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(LED_BUILTIN, HIGH);
led_power = 0;
Button1.print("off");
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
}
}
//用户自定义亮度控制的回调函数:小爱同学 灯的亮度控制函数 亮度范围为1-100
void miotBright(const String & bright)
{
BLINKER_LOG("need set brightness: ", bright);
colorW = bright.toInt();
analogWrite(LED_BUILTIN,100 - colorW);
BLINKER_LOG("now set brightness: ", colorW);
BlinkerMIOT.brightness(colorW);
BlinkerMIOT.print();
}
//用户自定义设备查询的回调函数:
void miotQuery(int32_t queryCode)
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case 0: //查询所有设备的情况
BLINKER_LOG("MIOT Query brightness: ", colorW);
BlinkerMIOT.brightness(colorW); //反馈灯的亮度
BlinkerMIOT.powerState(led_power ?"on":"off"); //反馈灯的亮灭
BlinkerMIOT.print(); //反馈至小爱
break;
case BLINKER_CMD_QUERY_PM25_NUMBER : /* 下面的这些用不到,供参考*/
BLINKER_LOG("MIOT Query PM25");
BlinkerMIOT.pm25(20);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_HUMI_NUMBER :
BLINKER_LOG("MIOT Query HUMI");
BlinkerMIOT.humi(20);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_TEMP_NUMBER :
BLINKER_LOG("MIOT Query TEMP");
BlinkerMIOT.temp(20);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_TIME_NUMBER :
BLINKER_LOG("MIOT Query Time");
//BlinkerMIOT.time(millis());
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.temp(20);
BlinkerMIOT.humi(20);
BlinkerMIOT.pm25(20);
BlinkerMIOT.co2(20);
BlinkerMIOT.print();
break;
}
}
//用户自定义模式设置的回调函数:
void miotMode(uint8_t mode)
{
BLINKER_LOG("need set mode: ", mode);
if (mode == BLINKER_CMD_MIOT_DAY) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_NIGHT) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_COLOR) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_WARMTH) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_TV) {
// Your mode function
}
else if (mode == BLINKER_CMD_MIOT_READING) {
// Your mode function
analogWrite(LED_BUILTIN,100-80);
}
else if (mode == BLINKER_CMD_MIOT_COMPUTER) {
// Your mode function
analogWrite(LED_BUILTIN,100-50);
}
wsMode = mode;
BlinkerMIOT.mode(mode);
BlinkerMIOT.print();
}
void setup()
{
//开启串口
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial); //串口打印调试信息
Blinker.begin(auth, ssid, pswd);
//初始化LED引脚
pinMode(LED_BUILTIN,OUTPUT);
digitalWrite(LED_BUILTIN,HIGH);
//独立按键
pinMode(Key,INPUT);
digitalWrite(Key,HIGH);
//设置灯的亮度调节范围
analogWriteRange(100);
//注册回调函数 电源类回调函数
BlinkerMIOT.attachPowerState(miotPowerState);
//注册回调函数: 用户自定义设备查询
BlinkerMIOT.attachQuery(miotQuery);
//注册回调函数 亮度回调函数
BlinkerMIOT.attachBrightness(miotBright);
//注册回调函数 模式回调函数
BlinkerMIOT.attachMode(miotMode);
//注册回调函数 按键回调
Button1.attach(button1_callback);
//红外初始化
myrecv.enableIRIn(); // 启用红外接收
}
void loop()
{
Blinker.run(); /*每次运行都会将设备收到的数据进行一次解析。
//在使用WiFi接入时,该语句也负责保持网络连接*/
if(wsMode==BLINKER_CMD_MIOT_NIGHT)
{
for (uint i = 0; i < 100; i++)
{
analogWrite(LED_BUILTIN,100-i);
Blinker.delay(10);
}
for (uint i = 99; i > 0; i--)
{
analogWrite(LED_BUILTIN,100-i);
Blinker.delay(10);
}
}
if(digitalRead(Key)==LOW)
{
delay(20);
digitalWrite(LED_BUILTIN,LOW);
led_power = 0;
Button1.print("on");
while(digitalRead(Key)==LOW);
Serial.print("LOW!");
}
if (myrecv.decode(&results)) // 接受到信号并解码
{
serialPrintUint64(results.value);//串口显示收到的信号值
Serial.println(" ");//换行
if (results.value==16724175)
{
digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN));//实现按下亮再按灭
}
myrecv.resume(); //刷新
}
delay(100);
}
```[/md] |