|
__ __ __
/\ \ /\ \ __ /\ \ v0.3.80210704
\ \ \___ \ \ \ /\_\ ___\ \ \/'\ __ _ __
\ \ '__`\\ \ \ \/\ \ /' _ `\ \ , < /'__`\/\`'__\
\ \ \L\ \\ \ \_\ \ \/\ \/\ \ \ \\`\ /\ __/\ \ \./
\ \_,__/ \ \__\\ \_\ \_\ \_\ \_\ \_\ \____\\ \_\
\/___/ \/__/ \/_/\/_/\/_/\/_/\/_/\/____/ \/_/
To better use blinker with your IoT project!
Download latest blinker library here!
=> https://github.com/blinker-iot/blinker-library
[102] _aliType:
[104] _duerType:
[106] _miType: &miType=outlet
[108] _authKey: a277a978f7b3
[111] Connecting to Xiaomi
[116] ESP8266_MQTT initialized...
[117]
===========================================================
================== Blinker Timer loaded! ==================
EEPROM address 1536-2431 is used for Blinker Timer!
========= PLEASE AVOID USING THESE EEPROM ADDRESS! ========
===========================================================
[145] countdown state: false
[145] _cdRunState: 0
[147] _totalTime: 0
[149] _runTime: 0
[151] _action:
[153] loop state: false
[154] _lpRunState: 0
[156] _times: 0
[158] _tri_times: 0
[160] _time1: 0
[161] _action1:
[163] _time2: 0
[164] _action2:
[166] _lpData: 0
[167] checkNum count: 1
[251806] WiFi Connected.
[251806] IP Address:
[251807] XXX.XXX.XXX.XXX
[251817] [HTTP] begin: http://iot.diandeng.tech/api/v1/user/device/diy/auth?authKey=a277a978f7b3&miType=outlet&version=0.1.0&protocol=mqtt
[251819] [HTTP] GET... failed, error: connection failed
[251824]
[251824] reply was:
[251826] ==============================
[251830]
[251831] ==============================
[251834] ERROR: Maybe you have put in the wrong AuthKey!
[251839] ERROR: Or maybe your request is too frequently!
[251844] ERROR: Or maybe your network is disconnected!
[261826] [HTTP] begin: http://iot.diandeng.tech/api/v1/user/device/diy/auth?authKey=a277a978f7b3&miType=outlet&version=0.1.0&protocol=mqtt
[261828] [HTTP] GET... failed, error: connection failed
[261832]
[261833] reply was:
[261835] ==============================
[261839]
[261840] ==============================
[261843] ERROR: Maybe you have put in the wrong AuthKey!
[261848] ERROR: Or maybe your request is too frequently!
[261853] ERROR: Or maybe your network is disconnected!
[271831] [HTTP] begin: http://iot.diandeng.tech/api/v1/user/device/diy/auth?authKey=a277a978f7b3&miType=outlet&version=0.1.0&protocol=mqtt
[271833] [HTTP] GET... failed, error: connection failed
[271838]
[271838] reply was:
[271840] ==============================
[271844]
[271845] ==============================
[271848] ERROR: Maybe you have put in the wrong AuthKey!
[271853] ERROR: Or maybe your request is too frequently!
[271858] ERROR: Or maybe your network is disconnected!
[331848] [HTTP] begin: http://iot.diandeng.tech/api/v1/user/device/diy/auth?authKey=a277a978f7b3&miType=outlet&version=0.1.0&protocol=mqtt
[331850] [HTTP] GET... failed, error: connection failed
[331855]
[331855] reply was:
[331857] ==============================
[331861]
[331862] ==============================
[331865] ERROR: Maybe you have put in the wrong AuthKey!
[331870] ERROR: Or maybe your request is too frequently!
[331875] ERROR: Or maybe your network is disconnected!
[341854] [HTTP] begin: http://iot.diandeng.tech/api/v1/user/device/diy/auth?authKey=a277a978f7b3&miType=outlet&version=0.1.0&protocol=mqtt
[341855] [HTTP] GET... failed, error: connection failed
[341860]
[341861] reply was:
[341862] ==============================
[341866]
[341867] ==============================
[341871] ERROR: Maybe you have put in the wrong AuthKey!
[341876] ERROR: Or maybe your request is too frequently!
[341881] ERROR: Or maybe your network is disconnected!
[351859] [HTTP] begin: http://iot.diandeng.tech/api/v1/user/device/diy/auth?authKey=a277a978f7b3&miType=outlet&version=0.1.0&protocol=mqtt
[351861] [HTTP] GET... failed, error: connection failed
[351865]
[351866] reply was:
[351868] ==============================
[351871]
[351872] ==============================
[351876] ERROR: Maybe you have put in the wrong AuthKey!
[351881] ERROR: Or maybe your request is too frequently!
[351886] ERROR: Or maybe your network is disconnected!
代码是照搬的,
#define BLINKER_WIFI
#define BLINKER_MIOT_OUTLET //小爱同学
#include <Blinker.h>
char auth[] = "a277a978f7b3";
char ssid[] = "Xiaomi";
char pswd[] = "213213213";
BlinkerButton Button1("btn-abc"); //定义按钮数据
bool oState = false;
int counter = 0;
void miotPowerState(const String & state)
{
BLINKER_LOG("need set power state: ", state);
if (state == BLINKER_CMD_ON) { //小爱同学控制开命令
digitalWrite(0, LOW);
delay(200);
digitalWrite(0, HIGH);
BlinkerMIOT.powerState("on");
BlinkerMIOT.print();
oState = true;
}
else if (state == BLINKER_CMD_OFF) { //小爱同学控制关命令
digitalWrite(0, LOW);
delay(200);
digitalWrite(0, HIGH);
BlinkerMIOT.powerState("off");
BlinkerMIOT.print();
oState = false;
}
}
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(oState ? "on" : "off");
BlinkerMIOT.print();
break;
case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
BLINKER_LOG("MIOT Query Power State");
BlinkerMIOT.powerState(oState ? "on" : "off");
BlinkerMIOT.print();
break;
default :
BlinkerMIOT.powerState(oState ? "on" : "off");
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(0, LOW);
delay(200);
digitalWrite(0, HIGH);
}
void setup()
{
Serial.begin(115200);
BLINKER_DEBUG.stream(Serial);
BLINKER_DEBUG.debugAll();
pinMode(0, OUTPUT); //定义io口为输出
digitalWrite(0, HIGH); //定义io默认为高电平
Blinker.begin(auth, ssid, pswd);
Blinker.attachData(dataRead);
BlinkerMIOT.attachPowerState(miotPowerState);
BlinkerMIOT.attachQuery(miotQuery);
Button1.attach(button1_callback);
}
void loop()
{
Blinker.run();
}
网络是连的自己手机在用的wifi,后台看流量累计只消耗了11k,一脸懵逼,代码只加了个debug all
|
|