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

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2039|回复: 7

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

[复制链接]
发表于 2020-5-10 09:52 | 显示全部楼层 |阅读模式
项目是:esp8266 & WiFi接入代码是:
[mw_shl_code=arduino,true]/* *****************************************************************
*
* 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();
}[/mw_shl_code]

问题是:(很长很长长!!!!!)
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

_

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



 楼主| 发表于 2020-5-10 09:54 | 显示全部楼层
我只改了 Secret Key(auth)和要连接的WiFi热点名(ssid)、密码(pswd)
点击编译  就出现这个错误  
我想问一下 编译的时间很长 得有一分钟 正常吗
发表于 2020-5-10 09:58 | 显示全部楼层
上传失败,和代码无关,建议找卖家咨询
 楼主| 发表于 2020-5-10 10:01 | 显示全部楼层
coloz 发表于 2020-5-10 09:58
上传失败,和代码无关,建议找卖家咨询

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

出现这个 不就是说明上传成功了吗
发表于 2020-5-10 10:03 | 显示全部楼层
浮3战 发表于 2020-5-10 10:01
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most  ...

Connecting是连接中的意思,建议使用百度翻译。。。
 楼主| 发表于 2020-5-10 10:05 | 显示全部楼层
coloz 发表于 2020-5-10 10:03
Connecting是连接中的意思,建议使用百度翻译。。。

我的意思 你误解了
我想表达的是  既然都已经开始连接了是不是说明 程序下载成功了?
发表于 2020-5-10 10:10 | 显示全部楼层
浮3战 发表于 2020-5-10 10:05
我的意思 你误解了
我想表达的是  既然都已经开始连接了是不是说明 程序下载成功了? ...

我没有误解,是您在误解,建议您使用百度翻译
FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
发表于 2020-5-10 15:49 | 显示全部楼层
你这是编译完成后开始上传,但是你的ESP8266不是上传模式或者接触不好。至于怎么触发具体百度。。。。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-11-28 12:43 , Processed in 0.251323 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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