Arduino ESP32 通过 BLE 接收文件(用于 OTA 更新) [英] Arduino ESP32 receive file over BLE (for OTA update)

查看:79
本文介绍了Arduino ESP32 通过 BLE 接收文件(用于 OTA 更新)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 BLE 从我的 Xamarin Forms (C#) iOS 应用程序发送一个文件 (bin) (https://github.com/xabre/xamarin-bluetooth-le) 到我的 ESP32 (Arduino).该文件将是用于更新的 bin 文件.我已经找到了一个关于如何从 spiffs 中更新 ESP32 的解决方案(arduino-esp32 do 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

推荐答案

您必须将文件内容作为单独的字节发送并保存到 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆