免费版不能配置一键配网吗-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2471|回复: 4

[已解答] 免费版不能配置一键配网吗

[复制链接]
发表于 2020-10-29 22:22 | 显示全部楼层 |阅读模式
使用免费版的设备不能配置实体键一键配网嘛,那个char type[] = "Your Device Type"; 怎么获取?

谁帮忙完善一下,代码:

[md]#define BLINKER_ALIGENIE_OUTLET
#define BLINKER_WIFI
#define BLINKER_ESP_SMARTCONFIG

#include <Blinker.h>

char type[] = "Your Device Type";
char auth[] = "Your Device Secret Key";

/*设置按键*/
#define BUTTON_1 "btn-01"
#define BUTTON_2 "btn-02"

BlinkerButton Button1(BUTTON_1);
BlinkerButton Button2(BUTTON_2);

void button1_callback(const String & state)
{
    BLINKER_LOG("get button state: ", state);

    if (state == BLINKER_CMD_ON) {
        //digitalWrite(5, HIGH);
        digitalWrite(5, LOW);
        digitalWrite(16, LOW);

        BLINKER_LOG("Toggle on!");

        //Button1.icon("icon_1");
        Button1.color("#0000FF");
        Button1.text("打开");
        // Button1.text("Your button name", "describe");
        Button1.print("on");
    }
    else if (state == BLINKER_CMD_OFF) {
        //digitalWrite(5, LOW);
        digitalWrite(5, HIGH);
        digitalWrite(16, HIGH);

        BLINKER_LOG("Toggle off!");

        //Button1.icon("icon_1");
        Button1.color("#363636");
        Button1.text("关闭");
        // Button1.text("Your button name", "describe");
        Button1.print("off");
    }
}

void button2_callback(const String & state)
{
    BLINKER_LOG("get button state: ", state);

    if (state == BLINKER_CMD_ON) {
        //digitalWrite(5, HIGH);
        digitalWrite(2, LOW);

        BLINKER_LOG("Toggle on!");

        //Button2.icon("icon_1");
        Button2.color("#0000FF");
        Button2.text("开灯");
        // Button2.text("Your button name", "describe");
        Button2.print("on");
    }
    else if (state == BLINKER_CMD_OFF) {
        //digitalWrite(5, LOW);
        digitalWrite(2, HIGH);

        BLINKER_LOG("Toggle off!");

        //Button2.icon("icon_1");
        Button2.color("#363636");
        Button2.text("关灯");
        // Button2.text("Your button name", "describe");
        Button2.print("off");
    }
}

/*....结束....*/

bool oState = false;

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

    if (state == BLINKER_CMD_ON) {
        digitalWrite(5, LOW);
        digitalWrite(16, LOW);

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

        oState = true;
    }
    else if (state == BLINKER_CMD_OFF) {
        digitalWrite(5, HIGH);
        digitalWrite(16, HIGH);

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

        oState = false;
    }
}

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(oState ? "on" : "off");
            BlinkerAliGenie.print();
            break;
        case BLINKER_CMD_QUERY_POWERSTATE_NUMBER :
            BLINKER_LOG("AliGenie Query Power State");
            BlinkerAliGenie.powerState(oState ? "on" : "off");
            BlinkerAliGenie.print();
            break;
        default :
            BlinkerAliGenie.powerState(oState ? "on" : "off");
            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(5, OUTPUT);
    digitalWrite(5, LOW);
    pinMode(16, OUTPUT);
    digitalWrite(16, LOW);
    pinMode(2, OUTPUT);
    digitalWrite(2, LOW);

    Blinker.begin(auth, type);
    Blinker.attachData(dataRead);
    Button1.attach(button1_callback);
    Button2.attach(button2_callback);
   
    BlinkerAliGenie.attachPowerState(aligeniePowerState);
    BlinkerAliGenie.attachQuery(aligenieQuery);
}

void loop()
{
    Blinker.run();
}[/md]
发表于 2020-10-30 08:42 | 显示全部楼层
可以,请看例程

点评

IDE>文件菜单>示例>blinker>smartconfig/apconfig  详情 回复 发表于 2020-11-3 19:03
有例程链接吗?没找到  发表于 2020-11-3 15:40
发表于 2020-11-3 19:03 | 显示全部楼层

IDE>文件菜单>示例>blinker>smartconfig/apconfig
发表于 2020-11-15 15:09 | 显示全部楼层
能改authkey吗?不能改key的程序,都是死程序。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-11-28 13:41 , Processed in 0.069883 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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