天猫精灵用不了blinker,是哪出问题了?求帮助-Arduino中文社区 - Powered by Discuz! Archiver

hhxianzi 发表于 2020-6-24 00:22

天猫精灵用不了blinker,是哪出问题了?求帮助


已经更新开发版的库
https://github.com/blinker-iot/blinker-library/tree/dev_3.0
后编译提示:

Leaving...
Hard resetting via RTS pin...
找到无效库在 C:\Users\HP\Documents\Arduino\libraries\blinker-library-dev_3.0: no headers files (.h) found in C:\Users\HP\Documents\Arduino\libraries\blinker-library-dev_3.0
找到无效库在 C:\Users\HP\Documents\Arduino\libraries\blinker-library-dev_3.0: no headers files (.h) found in C:\Users\HP\Documents\Arduino\libraries\blinker-library-dev_3.0

硬件:esp-12-f
看论坛里还有人说:本月在重构接口
还有其他人说:重新绑定了可以用

反正现在天猫精灵就是说,设备故障,需要主人帮忙。。。巴拉巴拉一大堆

我都弄了一遍还是不行,请问现在是哪里出了问题呢?

先谢谢各位大佬



调试信息如下:
WiFi Connected.
IP Address:
192.168.1.11
begin: https://iot.diandeng.tech/api/v1/user/device/diy/auth?authKey=4dc3403cb2af&aliType=light
GET... code: 200
reply was:
==============================
{"detail": {"broker": "aliyun", "deviceName": "15653864C9Y18B0RNUR2ITGG", "host": "mqtt://public.iot-as-mqtt.cn-shanghai.aliyuncs.com", "iotId": "HxPyFV5n4phbLTagppOkz20000", "iotToken": "^1^1592495780883^f38e16124dce771", "port": "1883", "productKey": "JgCGbHlndgz", "uuid": "00edee4d9ae9676494e45c59b95852ea"}, "message": 1000}
==============================
====================
DEVICE_NAME_MQTT: 15653864C9Y18B0RNUR2ITGG
MQTT_PRODUCTINFO_MQTT: JgCGbHlndgz
MQTT_ID_MQTT: 15653864C9Y18B0RNUR2ITGG
MQTT_NAME_MQTT: HxPyFV5n4phbLTagppOkz20000
MQTT_KEY_MQTT: ^1^1592495780883^f38e16124dce771
MQTT_BROKER: aliyun
HOST: public.iot-as-mqtt.cn-shanghai.aliyuncs.com
PORT: 1883
UUID_MQTT: 00edee4d9ae9676494e45c59b95852ea
====================
BLINKER_PUB_TOPIC_MQTT: /JgCGbHlndgz/15653864C9Y18B0RNUR2ITGG/s
BLINKER_SUB_TOPIC_MQTT: /JgCGbHlndgz/15653864C9Y18B0RNUR2ITGG/r
Freeheap: 9840
mDNS responder started
webSocket_MQTT server started
ws://15653864C9Y18B0RNUR2ITGG.local:81
Current time: Thu Jun 18 23:56:21 2020

NTP time: 1592495781
time (millis() - ntpFreshTime): 7386
ntpGetTime: 0
1
==== needInit ====
message: /share/device?deviceName=15653864C9Y18B0RNUR2ITGG&key=4dc3403cb2af
blinker server begin
Freeheap: 31728
HTTPS begin: https://iot.diandeng.tech/api/v1/user/device/share/device?deviceName=15653864C9Y18B0RNUR2ITGG&key=4dc3403cb2af
HTTPS payload: /share/device?deviceName=15653864C9Y18B0RNUR2ITGG&key=4dc3403cb2af
status... code: 200
{"detail": {"users": []}, "message": 1000}
payload: {"users":[]}
sharers data: {"users":[]}
load timing
load timing taskCount: 0
freshTiming wDay: 4, nowMins: 1436, nowSeconds: 86183
nextTask: 10apartSeconds: 217 wDay: 4
cbackData: 10
Connecting to MQTT...
MQTT Connected!
Freeheap: 10808
millis: 10151, connect_time: 7388
MQTT conn init success
MQTT Ping!
Freeheap: 10304
MQTT Ping!
Freeheap: 10304
MQTT Ping!
Freeheap: 10304


程序代码如下:
代码如下:

#define BLINKER_WIFI
#define BLINKER_ALIGENIE_LIGHT

#include <Blinker.h>

char auth[] = "**********";
char ssid[] = "*****";
char pswd[] = "******";

// Download Adafruit_NeoPixel library here:
// https://github.com/adafruit/Adafruit_NeoPixel
#include <Adafruit_NeoPixel.h>

#define PIN            4
#define NUMPIXELS      29
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define RGB_1 "RGBKey"

BlinkerRGB WS2812(RGB_1);

uint8_t colorR, colorG, colorB, colorW;
bool wsState;
String wsMode = BLINKER_CMD_COMMON;

void pixelShow()
{
    pixels.setBrightness(colorW);

    for(int i = 0; i < NUMPIXELS; i++){
      pixels.setPixelColor(i, colorR, colorG, colorB);
    }
    pixels.show();
}

void ws2812_callback(uint8_t r_value, uint8_t g_value, uint8_t b_value, uint8_t bright_value)
{
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
    BLINKER_LOG("R value: ", r_value);
    BLINKER_LOG("G value: ", g_value);
    BLINKER_LOG("B value: ", b_value);
    BLINKER_LOG("Rrightness value: ", bright_value);

    colorR = r_value;
    colorG = g_value;
    colorB = b_value;
    colorW = bright_value;

    pixelShow();
}

String getColor()
{
    uint32_t color = colorR << 16 | colorG << 8 | colorB;

    switch (color)
    {
      case 0xFF0000 :
            return "Red";
      case 0xFFFF00 :
            return "Yellow";
      case 0x0000FF :
            return "Blue";
      case 0x00FF00 :
            return "Green";
      case 0xFFFFFF :
            return "White";
      case 0x000000 :
            return "Black";
      case 0x00FFFF :
            return "Cyan";
      case 0x800080 :
            return "Purple";
      case 0xFFA500 :
            return "Orange";
      default :
            return "White";
    }
}

void aligeniePowerState(const String & state)
{
    BLINKER_LOG("need set power state: ", state);

    if (state == BLINKER_CMD_ON) {
      digitalWrite(LED_BUILTIN, HIGH);

      BlinkerAliGenie.powerState("on");
      BlinkerAliGenie.print();

      wsState = true;

      if (colorW == 0) colorW = 255;
    }
    else if (state == BLINKER_CMD_OFF) {
      digitalWrite(LED_BUILTIN, LOW);

      BlinkerAliGenie.powerState("off");
      BlinkerAliGenie.print();

      wsState = false;
    }

    pixelShow();
}

void aligenieColor(const String & color)
{
    BLINKER_LOG("need set color: ", color);

    if (color == "Red") {
      colorR = 255;
      colorG = 0;
      colorB = 0;
    }
    else if (color == "Yellow") {
      colorR = 255;
      colorG = 255;
      colorB = 0;
    }
    else if (color == "Blue") {
      colorR = 0;
      colorG = 0;
      colorB = 255;
    }
    else if (color == "Green") {
      colorR = 0;
      colorG = 255;
      colorB = 0;
    }
    else if (color == "White") {
      colorR = 255;
      colorG = 255;
      colorB = 255;
    }
    else if (color == "Black") {
      colorR = 0;
      colorG = 0;
      colorB = 0;
    }
    else if (color == "Cyan") {
      colorR = 0;
      colorG = 255;
      colorB = 255;
    }
    else if (color == "Purple") {
      colorR = 128;
      colorG = 0;
      colorB = 128;
    }
    else if (color == "Orange") {
      colorR = 255;
      colorG = 165;
      colorB = 0;
    }

    if (wsState == false) {
      wsState = true;
      colorW = 255;
    }

    if (colorW == 0) {
      colorW = 255;
    }

    pixelShow();

    BlinkerAliGenie.color(color);
    BlinkerAliGenie.print();
}

void aligenieMode(const String & mode)
{
    BLINKER_LOG("need set mode: ", mode);

    if (mode == BLINKER_CMD_ALIGENIE_READING) {
      // Your mode function
    }
    else if (mode == BLINKER_CMD_ALIGENIE_MOVIE) {
      // Your mode function
    }
    else if (mode == BLINKER_CMD_ALIGENIE_SLEEP) {
      // Your mode function
    }
    else if (mode == BLINKER_CMD_ALIGENIE_HOLIDAY) {
      // Your mode function
    }
    else if (mode == BLINKER_CMD_ALIGENIE_MUSIC) {
      // Your mode function
    }
    else if (mode == BLINKER_CMD_ALIGENIE_COMMON) {
      // Your mode function
    }

    wsMode = mode;

    BlinkerAliGenie.mode(mode);
    BlinkerAliGenie.print();
}

void aligeniecMode(const String & cmode)
{
    BLINKER_LOG("need cancel mode: ", cmode);

    if (cmode == BLINKER_CMD_ALIGENIE_READING) {
      // Your mode function
    }
    else if (cmode == BLINKER_CMD_ALIGENIE_MOVIE) {
      // Your mode function
    }
    else if (cmode == BLINKER_CMD_ALIGENIE_SLEEP) {
      // Your mode function
    }
    else if (cmode == BLINKER_CMD_ALIGENIE_HOLIDAY) {
      // Your mode function
    }
    else if (cmode == BLINKER_CMD_ALIGENIE_MUSIC) {
      // Your mode function
    }
    else if (cmode == BLINKER_CMD_ALIGENIE_COMMON) {
      // Your mode function
    }

    wsMode = BLINKER_CMD_COMMON; // new mode

    BlinkerAliGenie.mode(wsMode); // must response
    BlinkerAliGenie.print();
}

void aligenieBright(const String & bright)
{
    BLINKER_LOG("need set brightness: ", bright);

    if (bright == BLINKER_CMD_MAX) {
      colorW = 255;
    }
    else if (bright == BLINKER_CMD_MIN) {
      colorW = 0;
    }
    else {
      colorW = bright.toInt();
    }

    BLINKER_LOG("now set brightness: ", colorW);

    pixelShow();

    BlinkerAliGenie.brightness(colorW);
    BlinkerAliGenie.print();
}

void aligenieRelativeBright(int32_t bright)
{
    BLINKER_LOG("need set relative brightness: ", bright);

    if (colorW + bright < 255 && colorW + bright >= 0) {
      colorW += bright;
    }

    BLINKER_LOG("now set brightness: ", colorW);

    pixelShow();

    BlinkerAliGenie.brightness(bright);
    BlinkerAliGenie.print();
}

void aligenieColoTemp(int32_t colorTemp)
{
    BLINKER_LOG("need set colorTemperature: ", colorTemp);

    BlinkerAliGenie.colorTemp(colorTemp);
    BlinkerAliGenie.print();
}

void aligenieRelativeColoTemp(int32_t colorTemp)
{
    BLINKER_LOG("need set relative colorTemperature: ", colorTemp);

    BlinkerAliGenie.colorTemp(colorTemp);
    BlinkerAliGenie.print();
}

void aligenieQuery(int32_t queryCode)
{
    BLINKER_LOG("AliGenie Query codes: ", queryCode);

    switch (queryCode)
    {
      case BLINKER_CMD_QUERY_ALL_NUMBER :
            BLINKER_LOG("AliGenie Query All");
            BlinkerAliGenie.powerState(wsState ? "on" : "off");
            BlinkerAliGenie.color(getColor());
            BlinkerAliGenie.mode(wsMode);
            BlinkerAliGenie.colorTemp(50);
            BlinkerAliGenie.brightness(colorW);
            BlinkerAliGenie.print();
            break;
      case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
            BLINKER_LOG("AliGenie Query Power State");
            BlinkerAliGenie.powerState(wsState ? "on" : "off");
            BlinkerAliGenie.print();
            break;
      case BLINKER_CMD_QUERY_COLOR_NUMBER :
            BLINKER_LOG("AliGenie Query Color");
            BlinkerAliGenie.color(getColor());
            BlinkerAliGenie.print();
            break;
      case BLINKER_CMD_QUERY_MODE_NUMBER :
            BLINKER_LOG("AliGenie Query Mode");
            BlinkerAliGenie.mode(wsMode);
            BlinkerAliGenie.print();
            break;
      case BLINKER_CMD_QUERY_COLORTEMP_NUMBER :
            BLINKER_LOG("AliGenie Query ColorTemperature");
            BlinkerAliGenie.colorTemp(50);
            BlinkerAliGenie.print();
            break;
      case BLINKER_CMD_QUERY_BRIGHTNESS_NUMBER :
            BLINKER_LOG("AliGenie Query Brightness");
            BlinkerAliGenie.brightness(colorW);
            BlinkerAliGenie.print();
            break;
      default :
            BlinkerAliGenie.powerState(wsState ? "on" : "off");
            BlinkerAliGenie.color(getColor());
            BlinkerAliGenie.mode(wsMode);
            BlinkerAliGenie.colorTemp(50);
            BlinkerAliGenie.brightness(colorW);
            BlinkerAliGenie.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);
   
    BlinkerAliGenie.attachPowerState(aligeniePowerState);
    BlinkerAliGenie.attachColor(aligenieColor);
    BlinkerAliGenie.attachMode(aligenieMode);
    BlinkerAliGenie.attachCancelMode(aligeniecMode);
    BlinkerAliGenie.attachBrightness(aligenieBright);
    BlinkerAliGenie.attachRelativeBrightness(aligenieRelativeBright);
    BlinkerAliGenie.attachColorTemperature(aligenieColoTemp);
    BlinkerAliGenie.attachRelativeColorTemperature(aligenieRelativeColoTemp);
    BlinkerAliGenie.attachQuery(aligenieQuery);

    pinMode(14, OUTPUT);
    digitalWrite(14, HIGH);
    pinMode(15, OUTPUT);
    digitalWrite(15, HIGH);

    colorR = 255;
    colorG = 255;
    colorB = 255;
    colorW = 0;
    wsState = true;

    pixels.begin();
    pixels.setBrightness(colorW);
    WS2812.attach(ws2812_callback);
    pixelShow();
   
    BLINKER_DEBUG.stream(Serial);
    BLINKER_DEBUG.debugAll();
}

void loop()
{
    Blinker.run();

    for(int i = 0; i < NUMPIXELS; i++){
      pixels.setPixelColor(i, colorR, colorG, colorB);
    }
    pixels.show();
}

carlbeven 发表于 2020-6-24 13:09

库更新了

wishwell 发表于 2020-6-24 13:49

小爱语音也无法控制。

hhxianzi 发表于 2020-6-25 00:41

carlbeven 发表于 2020-6-24 13:09
库更新了

谢谢,我又重新下载了库文件,现在灯可以亮了,就是关不了了。说关灯后,灯还是亮的
页: [1]
查看完整版本: 天猫精灵用不了blinker,是哪出问题了?求帮助