完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
你好!
我正在使用 NodeMCU 测试 OTA,espClient 被 ESPhttpUpdate.update 断开连接,如您所见: 代码:全选#include "Arduino.h" #include #include #include #define ssid "SSID" // Change this #define password "PASSWORD" // Change this String upUrl = "https://bin.bemfa.com/b/3BcN2Q1NGY4NWFmNDI5NzZlZTNjMjY5M2U2OTJhNmJiNTk=light002.bin"; char serverName[] = "baidu.com"; WiFiClient espClient; void onStart() { Serial.println("onStart"); Serial.printf("WiFiClient is %sconnected.rn", espClient.connected() ? "" : "NOT "); } void onEnd() { Serial.println("onEnd"); } void onProgress(int cur, int total) { Serial.printf("onProgress at %d of %d bytes.rn", cur, total); Serial.printf("WiFiClient is %sconnected.rn", espClient.connected() ? "" : "NOT "); } void onError(int err) { Serial.printf("onError, err code = %d.rn", err); } void updateBin() { WiFiClientSecure updateClient; updateClient.setinsecure(); ESPhttpUpdate.onStart(onStart); ESPhttpUpdate.onEnd(onEnd); ESPhttpUpdate.onProgress(onProgress); ESPhttpUpdate.onError(onError); t_httpUpdate_return ret = ESPhttpUpdate.update(updateClient, upUrl); switch (ret) { case HTTP_UPDATE_FAILED: Serial.println("HTTP_UPDATE_FAILED"); break; case HTTP_UPDATE_NO_UPDATES: Serial.println("HTTP_UPDATE_NO_UPDATES"); break; case HTTP_UPDATE_OK: Serial.println("HTTP_UPDATE_OK"); break; } } void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); if (espClient.connect(serverName, 443)) { if (espClient.connected()) { Serial.println("Connected to https://baidu.com."); } updateBin(); } } void loop() { } 代码:全选........... Connected to https://baidu.com. onStart WiFiClient is connected. onProgress at 0 of 305120 bytes. WiFiClient is NOT connected. onProgress at 0 of 305120 bytes. WiFiClient is NOT connected. onProgress at 4096 of 305120 bytes. WiFiClient is NOT connected. ... 我错过了什么或者这是正常的吗? 在 ESPhttpUpdate.update 工作时,我应该如何保持 espClient 连接? 英禄 |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
524浏览 6评论
433浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
421浏览 5评论
414浏览 4评论
387浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-2 12:03 , Processed in 0.687253 second(s), Total 73, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号