Arduino ESP32通过BLE接收文件(用于OTA更新) [英] Arduino ESP32 receive file over BLE (for OTA update)
问题描述
我想通过BLE( https://github.com/xabre/xamarin-bluetooth-le )连接到我的ESP32(Arduino).该文件将是要更新的bin文件.我已经找到了一种解决方法,可以解决ESP32的问题( arduino-esp32做OTA通过BLE ),但是没有人知道我如何使用ESP32接收文件并将其保存为Spiffs吗?
I want to send a file (bin) from my Xamarin Forms (C#) iOS App over BLE (https://github.com/xabre/xamarin-bluetooth-le) to my ESP32 (Arduino). That file would be a bin file for updating. I found already a solution on how to update the ESP32 out of spiffs (arduino-esp32 do OTA via BLE) but does anyone know how I can receive the file with the ESP32 and save it into spiffs?
(到esp32的BLE连接应用程序已经可以正常工作,我可以发送文本,但是我不知道如何发送文件)
(The BLE connection app to esp32 is already fully working, I can send texts, but I don't know how to send files)
最诚挚的问候nflug
Best regards nflug
推荐答案
您必须将文件内容作为单个字节发送并将其保存到SPIFFS
You have to send the file content as individual bytes and save it to SPIFFS
您可以使用下面的函数(Arduino代码)创建并写入二进制文件
You can create and write to a binary file using the function below (Arduino code)
void writeBinary(fs::FS &fs, const char * path, uint8_t *dat, int len) {
//Serial.printf("Write binary file %s\r\n", path);
File file = fs.open(path, FILE_APPEND);
if (!file) {
Serial.println("- failed to open file for writing");
return;
}
file.write(dat, len);
file.close();
}
在此处 ESP32_BLE_OTA_Arduino 来查看用法.
我还创建了一个Android应用来上传文件 ESP32_BLE_OTA_Android
I have also created an android app to upload the file ESP32_BLE_OTA_Android
这篇关于Arduino ESP32通过BLE接收文件(用于OTA更新)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!