|
#define BLINKER_WIFI
#define BLINKER_MIOT_LIGHT//支持小爱同学
#include <Blinker.h>
char auth[] = "fa7aaa479460";//app中获取到的Secret Key(密钥)
char ssid[] = "dayinji";//你家wifi名称
char pswd[] = "qunimade1314";//你家wifi密码
int GPIO = 0; //定义继电器输入引脚为GPIO/0
// 新建组件对象
BlinkerButton Button1("btn-abc");//注意:要和APP组件’数据键名’一致
// 按下BlinkerAPP按键即会执行该函数
void button1_callback(const String & state) {
BLINKER_LOG("get button state: ", state);
digitalWrite(GPIO, !digitalRead(GPIO));
Blinker.vibrate();
}
//小爱电源类操作的回调函数:
//当小爱同学向设备发起控制, 设备端需要有对应控制处理函数
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(GPIO, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(GPIO, LOW);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
}
}
void setup() {
// 初始化串口,并开启调试信息,调试用可以删除
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
// 初始化IO
pinMode(GPIO, OUTPUT);
digitalWrite(GPIO, HIGH);
// 初始化blinker
Blinker.begin(auth, ssid, pswd);
Button1.attach(button1_callback);
//小爱同学务必在回调函数中反馈该控制状态
BlinkerMIOT.attachPowerState(miotPowerState);//注册回调函数
}
void loop() {
Blinker.run();
}
一直出错,换了一套带啊还是 一样
Arduino:1.6.5 (Windows 7), 板:"Generic ESP8266 Module, 80 MHz, ck, 26 MHz, 40MHz, QIO, 512K (no SPIFFS), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
C:\Users\Administrator\AppData\Roaming\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++ -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -IC:\Users\Administrator\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.4.1/tools/sdk/include -IC:\Users\Administrator\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.4.1/tools/sdk/lwip2/include -IC:\Users\Administrator\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.4.1/tools/sdk/libc/xtensa-lx106-elf/include -IC:\Users\ADMINI~1\AppData\Local\Temp\build6583919379802856403.tmp/core -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DARDUINO=10605 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD="ESP8266_GENERIC" -DLED_BUILTIN=2 -DESP8266 -IC:\Users\Administrator\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266 -IC:\Users\Administrator\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\variants\generic C:\Users\ADMINI~1\AppData\Local\Temp\build6583919379802856403.tmp\sketch_dec30a.cpp -o C:\Users\ADMINI~1\AppData\Local\Temp\build6583919379802856403.tmp\sketch_dec30a.cpp.o
sketch_dec30a.ino:3:21: fatal error: Blinker.h: No such file or directory
compilation terminated.
编译有误。
|
|