|
这是我的代码,用小爱语音训练然后打开eco模式,然后小爱反馈设备出现问题,然后串口打印
[ ERROR: Print data is not Json! {"data":{"eco"n,"messageId":"62e8ea5e28f434cf"},"fromDevice":"7E93AFF2DYMJSRA938GFT3SE","toDevice":"ServerReceiver","deviceType":"vAssistant"}
是因为BlinkerMIOT.mode(mode, state);的模式反馈错误吗
void miotPowerState(const String & state)
{
BLINKER_LOG("小爱同学开关空调 ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(Relay_T, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
power = true;
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(Relay_T, LOW);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
power = false;
}
}
void miotLevel(uint8_t level)
{
BLINKER_LOG("小爱控制风速: ", level);
// 0:AUTO MODE, 1-3 LEVEL
switch (level) {
case 0:
Serial.println("自动");
break;
case 1:
Serial.println("风速1");
break;
case 2:
Serial.println("风速2");
break;
case 3:
Serial.println("风速3");
break;
default:
break;
}
setLevel = level;
BlinkerMIOT.level(level);
BlinkerMIOT.print();
}
////小爱同学模式设置
void miotMode(const String & mode, const String & state)
{
BLINKER_LOG("小爱模式设置: ", mode);
BLINKER_LOG("小爱模式状态: ", state);
if (mode == "eco" && state == "on") {
Serial.println("aaa");
ecomode=true;
}
else if (mode == "eco" && state == "off") {
Serial.println("bbb");
ecomode=false;
}
BlinkerMIOT.mode(mode, state);
BlinkerMIOT.print();
}
//小爱同学设备查询接口
void miotQuery(int32_t queryCode)
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_ALL_NUMBER :
BLINKER_LOG("MIOT Query All");
BlinkerMIOT.powerState(power ? "on" : "off");
BlinkerMIOT.level(setLevel);
BlinkerMIOT.eco(ecomode ? "on" : "off");
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(power ? "on" : "off");
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(power ? "on" : "off");
BlinkerMIOT.level(setLevel);
BlinkerMIOT.eco(ecomode ? "on" : "off");
BlinkerMIOT.print();
break;
}
}
void setup() {
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
Blinker.begin(auth, ssid, pswd);
pinMode(Relay_T, OUTPUT);
digitalWrite(Relay_T, LOW);
// 初始化blinker
BlinkerMIOT.attachPowerState(miotPowerState);//小爱同学回调函数
BlinkerMIOT.attachLevel(miotLevel);
BlinkerMIOT.attachMode(miotMode);
BlinkerMIOT.attachQuery(miotQuery);
}
void loop() {
Blinker.run();
}
|
|