天猫精灵还是不可以用-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1276|回复: 8

[已解答] 天猫精灵还是不可以用

[复制链接]
发表于 2020-6-17 23:54 | 显示全部楼层 |阅读模式
已经更新开发版的库
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




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

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

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

先谢谢各位大佬

 楼主| 发表于 2020-6-18 00:00 | 显示全部楼层
烧录后手机blinker APP显示设备在线,天猫精灵语音控制不了
发表于 2020-6-18 08:34 | 显示全部楼层
你用的什么开发板
发表于 2020-6-18 11:35 | 显示全部楼层
 楼主| 发表于 2020-6-18 23:39 | 显示全部楼层

主板是:esp-12f,之前正常,最近突然就不能用了
 楼主| 发表于 2020-6-18 23:59 | 显示全部楼层
奈何col 发表于 2020-6-18 11:35
https://www.arduino.cn/thread-84332-1-1.html
看调试信息

你好,调试信息我看不懂

[3710] WiFi Connected.
[3710] IP Address:
[3710] 192.168.1.11
[3722] [HTTP] begin: https://iot.diandeng.tech/api/v1/user/device/diy/auth?authKey=4dc3403cb2af&aliType=light
[6283] [HTTP] GET... code: 200
[6293] reply was:
[6293] ==============================
[6293] {"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}
[6316] ==============================
[6321] ====================
[6322] DEVICE_NAME_MQTT: 15653864C9Y18B0RNUR2ITGG
[6326] MQTT_PRODUCTINFO_MQTT: JgCGbHlndgz
[6330] MQTT_ID_MQTT: 15653864C9Y18B0RNUR2ITGG
[6334] MQTT_NAME_MQTT: HxPyFV5n4phbLTagppOkz20000
[6339] MQTT_KEY_MQTT: ^1^1592495780883^f38e16124dce771
[6343] MQTT_BROKER: aliyun
[6346] HOST: public.iot-as-mqtt.cn-shanghai.aliyuncs.com
[6351] PORT: 1883
[6353] UUID_MQTT: 00edee4d9ae9676494e45c59b95852ea
[6357] ====================
[6360] BLINKER_PUB_TOPIC_MQTT: /JgCGbHlndgz/15653864C9Y18B0RNUR2ITGG/s
[6366] BLINKER_SUB_TOPIC_MQTT: /JgCGbHlndgz/15653864C9Y18B0RNUR2ITGG/r
[6372] Freeheap: 9840
[6377] mDNS responder started
[6378] webSocket_MQTT server started
[6380] ws://15653864C9Y18B0RNUR2ITGG.local:81
[7386] Current time: Thu Jun 18 23:56:21 2020

[7386] NTP time: 1592495781
[7386] time (millis() - ntpFreshTime): 7386
[7386] ntpGetTime: 0
[7387] 1
[7388] ==== needInit ====
[7391] message: /share/device?deviceName=15653864C9Y18B0RNUR2ITGG&key=4dc3403cb2af
[7398] blinker server begin
[7400] Freeheap: 31728
[8870] HTTPS begin: https://iot.diandeng.tech/api/v1/user/device/share/device?deviceName=15653864C9Y18B0RNUR2ITGG&key=4dc3403cb2af
[8871] HTTPS payload: /share/device?deviceName=15653864C9Y18B0RNUR2ITGG&key=4dc3403cb2af
[8879] [HTTP] status... code: 200
[8883] {"detail": {"users": []}, "message": 1000}
[8887] payload: {"users":[]}
[8891] sharers data: {"users":[]}
[8892] load timing
[8893] load timing taskCount: 0
[8897] freshTiming wDay: 4, nowMins: 1436, nowSeconds: 86183
[8902] nextTask: 10  apartSeconds: 217 wDay: 4
[8906] cbackData: 10
[9008] Connecting to MQTT...
[10151] MQTT Connected!
[10151] Freeheap: 10808
[10151] millis: 10151, connect_time: 7388
[10152] MQTT conn init success
[40173] MQTT Ping!
[40173] Freeheap: 10304
[70745] MQTT Ping!
[70746] Freeheap: 10304
[101308] MQTT Ping!
[101308] Freeheap: 10304

点评

你这就没有用天猫精灵的程序吧?  详情 回复 发表于 2020-6-19 08:59
发表于 2020-6-19 08:59 | 显示全部楼层
hhxianzi 发表于 2020-6-18 23:59
你好,调试信息我看不懂

[3710] WiFi Connected.

你这就没有用天猫精灵的程序吧?
 楼主| 发表于 2020-6-19 10:59 | 显示全部楼层
奈何col 发表于 2020-6-19 08:59
你这就没有用天猫精灵的程序吧?

程序就是例程:C:\Users\HP\Documents\Arduino\libraries\blinker-library-dev_3.0\blinker-library-dev_3.0\examples\Blinker_AliGenie\AliGenie_LIGHT\AliGenie_LIGHT.ino

只是这部分改成自己的内容了:
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



 楼主| 发表于 2020-6-19 11:00 | 显示全部楼层
奈何col 发表于 2020-6-19 08:59
你这就没有用天猫精灵的程序吧?

代码如下:

#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();
}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 09:33 , Processed in 0.072481 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表