arduino - ESP32 WebServer中如何使服务器自动从远程IP服务器下载OTA bin文件并启动OTA流程
问题描述
我试图了解在下载托管在远程 IP(网络内)中的 bin 文件后是否有可能(如果是,如何)继续 OTA 过程?该代码将在 ESP32 上运行。(编辑)我正在尝试介绍一种自我 OTA 更新的方法。它也可以通过点击 esp 网络服务器的端点来触发(通过 mqtt、http 等)
我指的是如何使服务器能够使用 arduino for ESP32 WebServer 自动下载文件,而不使用 SPIFFS,而是使用 SDcard 文件,但它侧重于从 sd 卡而不是网络下载。
目前,我正在关注https://randomnerdtutorials.com/esp32-over-the-air-ota-programming/中提到的代码,该代码目前处理通过浏览器上传 bin 文件,我正在尝试自动化。如果我能以某种方式以编程方式用数据触发这部分代码,那么我认为我的问题仍然会得到解决。
server.on("/update", HTTP_POST, []() {
server.sendHeader("Connection", "close");
server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
ESP.restart();
}, []() {
HTTPUpload& upload = server.upload();
if (upload.status == UPLOAD_FILE_START) {
Serial.printf("Update: %s\n", upload.filename.c_str());
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { //start with max available size
Update.printError(Serial);
}
} else if (upload.status == UPLOAD_FILE_WRITE) {
/* flashing firmware to ESP*/
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
Update.printError(Serial);
}
} else if (upload.status == UPLOAD_FILE_END) {
if (Update.end(true)) { //true to set the size to the current progress
Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
} else {
Update.printError(Serial);
}
}
});
问候, 沙里克
解决方案
推荐阅读
- python - Launch a roslaunch file using a push button in Qt (PyQt)
- javascript - 如何自动计算图表的最大值和最小值,以使高值或低值不会掉出来?
- python - How to reduce part of a dataframe colunm value based on another column
- arrays - 在 Minizinc 中混合两个可变大小的数组
- python-3.x - 存在 n 时未定义“N”
- json - 将身份验证令牌传递给服务
- java - Convert elapsed time between epoch time and current moment to ISO 8601 duration with Java
- asp.net - 2 tables, receive Id from one table and add value to another table but with id
- sql-server - 当过去的项目发生变化时更新多个运行总计
- python - 推送被拒绝,无法编译 Python 应用程序 - Python 版本错误