#define BLINKER_MIOT_MULTI_OUTLET
#include <Blinker.h>
char auth[] = "1111111111111";
char ssid[] = "fandaye";
char pswd[] = "12345678";
#define k1 5 //这里宏申明了为什么验证时就是这老出问题
#define k2 4
bool oState = { false };
void miotPowerState(const String & state, uint8_t num)
{
BLINKER_LOG("need set outlet: ", num, ", power state: ", state);
if (state == BLINKER_CMD_ON) {
if (num==0){
digitalWrite(LED_BUILTIN, HIGH);
}
else if(num==1){
digitalWrite(k1,HIGH);
}
else if(num==2){
digitalWrite(k2,HIGH);
}
BlinkerMIOT.powerState("on", num);
BlinkerMIOT.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) {
BlinkerMIOT.powerState("off", num);
BlinkerMIOT.print();
oState = false;
if (num == 0)
{
for (uint8_t o_num = 0; o_num < 5; o_num++)
{
oState = false;
}
digitalWrite(LED_BUILTIN, LOW);
}
else if(num==1){
digitalWrite(k1,LOW);
}
else if(num==2){
digitalWrite(k2,LOW);
}
}
}
void miotQuery(int32_t queryCode, uint8_t num)
{
BLINKER_LOG("MIOT Query outlet: ", num,", codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(oState ? "on" : "off", num);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(oState ? "on" : "off", num);
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(oState ? "on" : "off", num);
BlinkerMIOT.print();
break;
}
}
void dataRead(const String & data)
{
BLINKER_LOG("Blinker readString: ", data);
Blinker.vibrate();
uint32_t BlinkerTime = millis();
Blinker.print("millis", BlinkerTime);
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachQuery(miotQuery);
}
void loop()
{
Blinker.run();
}
gyq-svip 发表于 2021-8-10 10:46
你少了很多引号好 加上就可以了我编译正常
能贴一段我试一下吗
15892617059 发表于 2021-8-10 10:50
能贴一段我试一下吗
都贴给你了啊 15892617059 发表于 2021-8-10 10:48
按照图上对应的做过还是不行的
首先感谢回帖的朋友。问题已经解决,是我犯了一个低级错误没有安装Blinker的库文件造成的。
页:
1
[2]