天猫精灵改的小爱 可以正常使用
https://www.arduino.cn/thread-94282-1-1.html依照上边这个帖子 把天猫改成小爱目前可以正常使用
有没有大佬看看还有别的问题吗?
#define BLINKER_WIFI
#define BLINKER_MIOT_OUTLET
#include <Blinker.h>
char auth[] = "ff376716aec4";//电灯科技上的密钥
char ssid[] = "360WiFi-ABDBDF";//你家的WiFi名字
char pswd[] = "@XINYU404";//你家WiFi的密码
BlinkerButton Button1("anniu"); // 1caiyq52-此组件未点灯app中自己设置的按键,改名"btn-abc"必须与自己APP中设定的名称一致
bool oState = false;
int Pin = 0; //caiyq52-定义控制引脚
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) {
digitalWrite(Pin, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
}
else if (state == BLINKER_CMD_OFF) {
digitalWrite(Pin, LOW);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
}
}
void miotQuery(int32_t queryCode)
{
BLINKER_LOG("MIOT Query codes: ", queryCode);
switch (queryCode)
{
case BLINKER_CMD_QUERY_PM25_NUMBER :
BLINKER_LOG("MIOT Query PM25");
BlinkerMIOT.pm25(20);
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_HUMI_NUMBER :
BLINKER_LOG("MIOT Query HUMI");
BlinkerMIOT.humi(20);
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.temp(20);
BlinkerMIOT.humi(20);
BlinkerMIOT.pm25(20);
BlinkerMIOT.co2(20);
BlinkerMIOT.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内控制按键触发
{
BLINKER_LOG("get button state: ", state);
digitalWrite(Pin, !digitalRead(Pin));
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
pinMode(Pin, OUTPUT); //定义io口为输出
digitalWrite(Pin, HIGH); //定义io默认电平
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachQuery(miotQuery);
Button1.attach(button1_callback);
}
void loop()
{
Blinker.run();
}
页:
[1]