|
本帖最后由 biexiwang 于 2020-12-25 20:07 编辑
这是刷入的代码
#define BLINKER_WIFI
#define BLINKER_MIOT_OUTLET //小爱同学
#define BLINKER_DUEROS_OUTLET
#define BLINKER_ALIGENIE_OUTLET //天猫精灵
#include <Blinker.h>
char auth[] = "8faf81dd9b7d"; //这里密钥
char ssid[] = "CU_u98L"; //这里WIFI名称
char pswd[] = "yxhjbjjp"; //这里WIFI密码
BlinkerButton Button1("btn-on"); //定义按钮数据
BlinkerButton Button2("btn-off");
bool oState = false;
int counter = 0;
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) { //小爱同学控制开命令
digitalWrite(0, LOW);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) { //小爱同学控制关命令
digitalWrite(0,HIGH);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
oState = false;
}
}
void miotQuery(int32_t queryCode) //小爱同学控制
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
}
}
void AliGeniePowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) { //小爱同学控制开命令
digitalWrite(0, LOW);
BlinkerAliGenie.powerState("on");
BlinkerAliGenie.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) { //小爱同学控制关命令
digitalWrite(0,HIGH);
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 dataRead(const String & data) // 如果未绑定的组件被触发,则会执行其中内容
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
}
void button1_callback(const String & state) //点灯app内控制按键触发
{
digitalWrite(0,LOW);
BLINKER_LOG("get button staten", state);
}
void button2_callback(const String & state) //点灯app内控制按键触发
{
digitalWrite(0,HIGH);
BLINKER_LOG("get button stateff", state);
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
BLINKER_DEBUG.debugAll();
pinMode(0, OUTPUT); //定义io口为输出
digitalWrite(0, LOW); //定义io默认为高电平
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
BlinkerAliGenie.attachPowerState(AliGeniePowerState);
BlinkerAliGenie.attachQuery(AliGenieQuery);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachQuery(miotQuery);
Button1.attach(button1_callback);
Button2.attach(button2_callback);
}
void loop()
{
Blinker.run();
}
这是用Arduino 1.8.13刷入后的提示
Executable segment sizes:
IROM : 503124 - code in flash (default or ICACHE_FLASH_ATTR)
IRAM : 27996 / 32768 - code in IRAM (ICACHE_RAM_ATTR, ISRs...)
DATA : 1472 ) - initialized variables (global, static) in RAM/HEAP
RODATA : 5564 ) / 81920 - constants (global, static) in RAM/HEAP
BSS : 30248 ) - zeroed variables (global, static) in RAM/HEAP
项目使用了 538156 字节,占用了 (56%) 程序存储空间。最大为 958448 字节。
全局变量使用了37284字节,(45%)的动态内存,余留44636字节局部变量。最大为81920字节。
esptool.py v2.8
Serial port COM3
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: c8:2b:96:2e:8d:ab
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Compressed 542304 bytes to 385629...
Wrote 542304 bytes (385629 compressed) at 0x00000000 in 34.4 seconds (effective 126.3 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
这是我的设置
设置好的
这是我的硬件。
反面
正面
对应的密匙也是对的。WIFI名字和密码也对的。就是刷过之后手机怎么刷新也不会上线!!求大神指点指点。
|
|