|
#define BLINKER_WIFI
#define BLINKER_MIOT_MULTI_OUTLET //设置为小爱多个插座的模式
#include <Blinker.h>
BlinkerButton Button1("kai"); //设置blinkerapp内数据键名
BlinkerButton Button2("suo"); //这里只用了其中三个
BlinkerButton Button3("guan");
BlinkerText Text1("text_1");
char i;
char auth[] = "080cafce7864";
char ssid[] = "MF-yanfa";
char pswd[] = "mfyf8888";
bool oState[5] = { false }; //设置5路开关控制
void miotPowerState(const String & state, uint8_t num) //小爱同学控制指令
{
BLINKER_LOG("need set outlet: ", num, ", power state: ", state);
if(num==1){
i=D1; //指定每一路开关对应在开发板上的通道接口
}else if(num==2){
i=D2;
}else if(num==3){
i=D5;
}
if (state == BLINKER_CMD_ON) {
digitalWrite(i, HIGH); //这里控制模式都是点动模式
Blinker.delay(200); //高电平触发继电器200毫秒后低电平断开继电器
digitalWrite(i, LOW);
BlinkerMIOT.powerState("on", num);
BlinkerMIOT.print();
oState[num] = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(i, HIGH);
Blinker.delay(200);
digitalWrite(i, LOW);
BlinkerMIOT.powerState("off", num);
BlinkerMIOT.print();
oState[num] = false;
if (num == 0)
{
for (uint8_t o_num = 0; o_num < 5; o_num++)
{
oState[o_num] = false;
}
}
}
}
void miotQuery(int32_t queryCode, uint8_t num)
{
BLINKER_LOG("AliGenie Query outlet: ", num,", codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(oState[num] ? "on" : "off", num);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(oState[num] ? "on" : "off", num);
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(oState[num] ? "on" : "off", num)
这是我在抖音刷到的,然后也弄好了,就是在点灯科技app里科技操作设备,在小爱里面可以识别到设备,但操作不了,不知道是哪里出了问题!
求大神帮忙!!!
|
|