(新手)官方的代码,为什不行呢?-Arduino中文社区 - Powered by Discuz! Archiver

浮3战 发表于 2020-5-10 09:52

(新手)官方的代码,为什不行呢?

项目是:esp8266 & WiFi接入代码是:
/* *****************************************************************
*
* Download latest Blinker library here:
* https://github.com/blinker-iot/blinker-library/archive/master.zip
*
*
* Blinker is a cross-hardware, cross-platform solution for the IoT.
* It provides APP, device and server support,
* and uses public cloud services for data transmission and storage.
* It can be used in smart home, data monitoring and other fields
* to help users build Internet of Things projects etter and faster.
*
* Make sure installed 2.5.0 or later ESP8266/Arduino package,
* if use ESP8266 with Blinker.
* https://github.com/esp8266/Arduino/releases
*
* Make sure installed 1.0.2 or later ESP32/Arduino package,
* if use ESP32 with Blinker.
* https://github.com/espressif/arduino-esp32/releases
*
* Docs: https://doc.blinker.app/
*       https://github.com/blinker-iot/blinker-doc/wiki
*
* *****************************************************************
*
* Blinker 库下载地址:
* https://github.com/blinker-iot/blinker-library/archive/master.zip
*
* Blinker 是一套跨硬件、跨平台的物联网解决方案,提供APP端、设备端、
* 服务器端支持,使用公有云服务进行数据传输存储。可用于智能家居、
* 数据监测等领域,可以帮助用户更好更快地搭建物联网项目。
*
* 如果使用 ESP8266 接入 Blinker,
* 请确保安装了 2.5.0 或更新的 ESP8266/Arduino 支持包。
* https://github.com/esp8266/Arduino/releases
*
* 如果使用 ESP32 接入 Blinker,
* 请确保安装了 1.0.2 或更新的 ESP32/Arduino 支持包。
* https://github.com/espressif/arduino-esp32/releases
*
* 文档: https://doc.blinker.app/
*       https://github.com/blinker-iot/blinker-doc/wiki
*
* *****************************************************************/

#define BLINKER_WIFI

#include <Blinker.h>

char auth[] = "af3b19d6f753";
char ssid[] = "shi kai";
char pswd[] = "sk123456789";

// 新建组件对象
BlinkerButton Button1("btn-abc");
BlinkerNumber Number1("num-abc");

int counter = 0;

// 按下按键即会执行该函数
void button1_callback(const String & state)
{
    BLINKER_LOG("get button state: ", state);
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}

// 如果未绑定的组件被触发,则会执行其中内容
void dataRead(const String & data)
{
    BLINKER_LOG("Blinker readString: ", data);
    counter++;
    Number1.print(counter);
}


void setup()
{
    // 初始化串口
    Serial.begin(115200);
    BLINKER_DEBUG.stream(Serial);
   
    // 初始化有LED的IO
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, HIGH);
    // 初始化blinker
    Blinker.begin(auth, ssid, pswd);
    Blinker.attachData(dataRead);

    Button1.attach(button1_callback);
}

void loop() {
    Blinker.run();
}

问题是:(很长很长长!!!!!)
Arduino:1.8.12 (Windows 10), 开发板:"Generic ESP8266 Module, 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

In file included from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/BlinkerESPMQTT.h:10:0,

               from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker.h:36,

               from C:\Users\45428\Desktop\Hello_WiFi\Hello_WiFi.ino:48:

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Adapters/BlinkerMQTT.h: In member function 'virtual char* BlinkerMQTT::lastRead()':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Adapters/BlinkerMQTT.h:683:17: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

   else return "";

               ^

In file included from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:82:0,

               from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/BlinkerESPMQTT.h:11,

               from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker.h:36,

               from C:\Users\45428\Desktop\Hello_WiFi\Hello_WiFi.ino:48:

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApiBase.h: In member function 'char* BlinkerBridge_key::getName()':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApiBase.h:194:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

               else return "false";

                           ^

In file included from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:83:0,

               from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/BlinkerESPMQTT.h:11,

               from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker.h:36,

               from C:\Users\45428\Desktop\Hello_WiFi\Hello_WiFi.ino:48:

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h: In member function 'char* BlinkerProtocol::deviceName()':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h:97:86: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

             char * deviceName() { if (isInit) return conn->deviceName(); else return ""; }

                                                                                    ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h: In member function 'char* BlinkerProtocol::authKey()':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h:98:83: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

             char * authKey()    { if (isInit) return conn->authKey(); else return "";}

                                                                                 ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h: In member function 'char* BlinkerProtocol::dataParse()':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerProtocol.h:234:86: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

         char* dataParse()       { if (canParse) return conn->lastRead(); else return ""; }

                                                                                    ^

In file included from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/BlinkerESPMQTT.h:11:0,

               from C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker.h:36,

               from C:\Users\45428\Desktop\Hello_WiFi\Hello_WiFi.ino:48:

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: At global scope:

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:777:97: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

         BlinkerWidgets_string _BUILTIN_SWITCH = BlinkerWidgets_string(BLINKER_CMD_BUILTIN_SWITCH);

                                                                                                 ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::bridgeKey(uint8_t)':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:6380:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

         else return "";

                     ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::bridgeName(uint8_t)':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:6387:21: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

         else return "false";

                     ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_str(uint8_t)':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:7012:17: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

   else return "";

               ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_rgb(uint8_t)':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:7026:17: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

   else return "";

               ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_int(uint8_t)':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:7032:17: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

   else return "";

               ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h: In member function 'char* BlinkerApi::widgetName_tab(uint8_t)':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src/Blinker/BlinkerApi.h:7038:17: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

   else return "";

               ^

C:\Users\45428\Desktop\Hello_WiFi\Hello_WiFi.ino: At global scope:

C:\Users\45428\Desktop\Hello_WiFi\Hello_WiFi.ino:55:32: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

BlinkerButton Button1("btn-abc");

                              ^

C:\Users\45428\Desktop\Hello_WiFi\Hello_WiFi.ino:56:32: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

BlinkerNumber Number1("num-abc");

                              ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src\modules\WebSockets\WebSocketsClient.cpp: In member function 'void WebSocketsClient::loop()':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src\modules\WebSockets\WebSocketsClient.cpp:174:87: warning: 'bool BearSSL::WiFiClientSecure::setCACert(const uint8_t*, size_t)' is deprecated (declared at C:\Users\45428\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:142): This is deprecated AxTLS API, check https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/WiFiClientSecure.h#L25-L99 [-Wdeprecated-declarations]

               _client.ssl->setCACert((const uint8_t *)_CA_cert, strlen(_CA_cert) + 1);

                                                                                       ^

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src\modules\WebSockets\WebSocketsClient.cpp: In member function 'void WebSocketsClient::connectedCb()':

C:\Users\45428\Documents\Arduino\libraries\blinker-library-master\src\modules\WebSockets\WebSocketsClient.cpp:761:68: warning: 'bool BearSSL::WiFiClientSecure::verify(const char*, const char*)' is deprecated (declared at C:\Users\45428\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WiFi\src/WiFiClientSecureBearSSL.h:182): This is deprecated AxTLS API, check https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/WiFiClientSecure.h#L25-L99 [-Wdeprecated-declarations]

         if(!_client.ssl->verify(_fingerprint.c_str(), _host.c_str())) {

                                                                  ^

Executable segment sizes:


IROM   : 495112          - code in flash         (default or ICACHE_FLASH_ATTR)


IRAM   : 28084   / 32768 - code in IRAM          (ICACHE_RAM_ATTR, ISRs...)


DATA   : 1392)         - initialized variables (global, static) in RAM/HEAP


RODATA : 5388) / 81920 - constants             (global, static) in RAM/HEAP


BSS    : 30056 )         - zeroed variables      (global, static) in RAM/HEAP


项目使用了 529976 字节,占用了 (55%) 程序存储空间。最大为 958448 字节。
全局变量使用了36836字节,(44%)的动态内存,余留45084字节局部变量。最大为81920字节。
esptool.py v2.8
Serial port COM4
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):
File "C:\Users\45428\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/upload.py", line 65, in <module>
    esptool.main(cmdline)
File "C:/Users/45428/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 2890, in main
    esp.connect(args.before)
File "C:/Users/45428/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 483, in connect
    raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

_

在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。



浮3战 发表于 2020-5-10 09:54

我只改了 Secret Key(auth)和要连接的WiFi热点名(ssid)、密码(pswd)
点击编译就出现这个错误
我想问一下 编译的时间很长 得有一分钟 正常吗

coloz 发表于 2020-5-10 09:58

上传失败,和代码无关,建议找卖家咨询

浮3战 发表于 2020-5-10 10:01

coloz 发表于 2020-5-10 09:58
上传失败,和代码无关,建议找卖家咨询

Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):

出现这个 不就是说明上传成功了吗

coloz 发表于 2020-5-10 10:03

浮3战 发表于 2020-5-10 10:01
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most...

Connecting是连接中的意思,建议使用百度翻译。。。

浮3战 发表于 2020-5-10 10:05

coloz 发表于 2020-5-10 10:03
Connecting是连接中的意思,建议使用百度翻译。。。

我的意思 你误解了:lol
我想表达的是既然都已经开始连接了是不是说明 程序下载成功了?

coloz 发表于 2020-5-10 10:10

浮3战 发表于 2020-5-10 10:05
我的意思 你误解了
我想表达的是既然都已经开始连接了是不是说明 程序下载成功了? ...
我没有误解,是您在误解,建议您使用百度翻译
FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

admin1314 发表于 2020-5-10 15:49

你这是编译完成后开始上传,但是你的ESP8266不是上传模式或者接触不好。至于怎么触发具体百度。。。。
页: [1]
查看完整版本: (新手)官方的代码,为什不行呢?