#define BLINKER_WIFI
#define BLINKER_ALIGENIE_OUTLET //天猫精灵
#include <Blinker.h>
char auth[] = "277c9caae6da";
char ssid[] = "CMCC-shuai";
char pswd[] = "yuanyuan1120...";
BlinkerButton Button1("btn-on"); //定义按钮数据
BlinkerButton Button2("btn-off");
BlinkerButton Button3("btn-aaa");
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);
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("MIOT 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 button3_callback(const String & state) //点灯app内控制按键触发
{
BLINKER_LOG("get button staten", state);
Blinker.print(state);
if(state=="on"){
digitalWrite(0,LOW);
// Button3.print("on");
}else if(state =="off"){
digitalWrite(0,HIGH);
// Button3.print("off");
}
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(0, OUTPUT); //定义io口为输出
digitalWrite(0, LOW); //定义io默认为高电平
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
BlinkerAliGenie.attachPowerState(aligeniePowerState); 显示这里错误 这句话应该怎么写
BlinkerAliGenie.attachQuery(AliGenieQuery);
Button1.attach(button1_callback);
Button2.attach(button2_callback);
Button3.attach(button3_callback);
}
void loop()
{
Blinker.run();
}
错误代码
Arduino:1.8.12 (Windows 7), 开发板:"Generic ESP8266 Module, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
C:\Users\Administrator.PC-20190614TYWN\Desktop\爆改车间_灯泡 (1)\blinker_xiaoai_dengpao\blinker_xiaoai_dengpao\blinker_xiaoai_dengpao.ino: In function 'void setup()':
blinker_xiaoai_dengpao:118:38: error: 'aligeniePowerState' was not declared in this scope
"Blinker.h" 对应多个库
已使用: C:\Users\Administrator.PC-20190614TYWN\Documents\Arduino\libraries\blinker-library-master
未使用:C:\Users\Administrator.PC-20190614TYWN\Documents\Arduino\libraries\src
exit status 1
'aligeniePowerState' was not declared in this scope
在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。
|