完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我想从受 SSL/TLS 保护的站点将文件下载到我的 ESP8266。
我从 HTTP over TLS (HTTPS) 示例草图开始,下载一个 3 字节的小文件后效果很好。当我将文件步进到大约 100,000 字节的更大文件时,我遇到了崩溃。崩溃似乎发生在 GET 调用之后的一小段时间。如果我在 GET 之后注释掉所有访问 HTTPClient 对象的调用,我就不会崩溃。如果我只注释掉 http.getStreamPtr(); 我仍然在 .End() 上遇到崩溃。似乎没有任何帮助。我可以调用 http.getSize(); 连续 5 次,没有崩溃,但之后的任何其他调用都崩溃了。 文件的内容是否会导致 HTTPClient 崩溃? 我会不会内存不足并且 http 对象被杀死,然后任何调用任何 http.xxx() 的尝试都会导致取消引用失败?我可以尝试缩小范围吗? 代码:全选/* HTTP over TLS (HTTPS) example sketch This example demonstrates how to use WiFiClientSecure class to access HTTPS API. We fetch and display the status of esp8266/Arduino project continuous integration build. Limitations: only RSA certificates no support of Perfect Forward Secrecy (PFS) TLSv1.2 is supported since version 2.4.0-rc1 Created by Ivan Grokhotkov, 2015. This example is in public domain. */ #include #include #include const char* ssid = "xxxx"; const char* password = "xxxx"; const char* host = "test.test.com"; const int httpsPort = 8080; // Use web browser to view and copy // SHA1 fingerprint of the certificate const char* fingerprint = "35 85 74 EF 67 35 A7 CE 40 69 50 F3 C0 F6 80 CF 80 3B 2E 19"; uint8_t buff[128] = { 0 }; int len; HTTPClient http; WiFiClientSecure client; WiFiClient* stream; void setup() { Serial.begin(115200); Serial.println(); Serial.print("connecting to "); Serial.println(ssid); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); len=0; Serial.print("connecting to "); Serial.println(host); if (!client.connect(host, httpsPort)) { Serial.println("connection failed"); return; } if (client.verify(fingerprint, host)) { Serial.println("certificate matches"); } else { Serial.println("certificate doesn't match"); } http.begin("https://test.test.com/app/upload/common/platform/recovery/2_1/test.bin" , fingerprint); String postMessage = ""; http.setReuse(true); int httpCode = http.POST(postMessage); if(httpCode == 200) { Serial.print("http result:"); Serial.println(httpCode); Serial.println("File Size: "); len = http.getSize(); Serial.println(len); if(http.connected()) { Serial.println("Getting Stream"); stream = http.getStreamPtr(); Serial.println("Got Stream"); } Serial.println("After Stream"); http.end(); } else { Serial.println("Call Failed"); } } void loop() { } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
545浏览 6评论
457浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
437浏览 5评论
441浏览 4评论
411浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 04:02 , Processed in 0.779158 second(s), Total 75, Slave 58 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号