自己做的插座,使用小爱唤醒备注只能是灯,备注插座小爱就会提示找不到,并且推荐我它支持的插座设备,这种方法能通过代码解决吗
#define BLINKER_MIOT_LIGHT
#define BLINKER_WIFI
#include <Blinker.h>
char auth[] = "***********";//电灯科技上的密钥
char ssid[] = "***********";//你家的WiFi名字
char pswd[] = "**********";//你家WiFi的密码
int GPIO=0;
#define BUTTON_1 "ButtonKey"
BlinkerButton Button1("anniu");//这个anniu必须要和电灯科技上的按键相同
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_OFF) {
digitalWrite(GPIO, HIGH);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
}
else if (state == BLINKER_CMD_ON) {
digitalWrite(GPIO, LOW);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
}
}
void setup() {
Serial.begin(115200);
pinMode(GPIO,OUTPUT);
digitalWrite(GPIO,HIGH);
Blinker.begin(auth, ssid, pswd);
Button1.attach(button1_callback);
BlinkerMIOT.attachPowerState(miotPowerState);
}
void loop()
{
Blinker.run();
}
|