【问题标题】:Arduino ESP32 receive file over BLE (for OTA update)Arduino ESP32 通过 BLE 接收文件(用于 OTA 更新)
【发布时间】:2021-01-07 23:06:01
【问题描述】:

我想通过 BLE (https://github.com/xabre/xamarin-bluetooth-le) 从我的 Xamarin Forms (C#) iOS 应用程序向我的 ESP32 (Arduino) 发送一个文件 (bin)。该文件将是用于更新的 bin 文件。我已经找到了一个关于如何从 spiffs (arduino-esp32 do OTA via BLE) 中更新 ESP32 的解决方案,但是有人知道我如何使用 ESP32 接收文件并将其保存到 spiffs 中吗?

(到esp32的BLE连接应用程序已经完全运行,我可以发送文本,但我不知道如何发送文件)

最好的问候 nflug

【问题讨论】:

    标签: xamarin.forms arduino bluetooth bluetooth-lowenergy esp32


    【解决方案1】:

    您必须将文件内容作为单个字节发送并将其保存到 SPIFFS

    您可以使用以下函数(Arduino 代码)创建和写入二进制文件

    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

    我还创建了一个安卓应用来上传文件ESP32_BLE_OTA_Android

    【讨论】:

      猜你喜欢
      • 2019-04-21
      • 2021-05-25
      • 2019-09-14
      • 1970-01-01
      • 2022-01-12
      • 2021-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多