BLE OTA 配置文件
BLE OTA 配置文件基于 esp_ble_conn_mgr 提供分扇区固件传输能力。
该配置文件使用 OTA 服务 UUID 0x8018,并处理主机发送的 START/STOP 命令与固件数据包。
该配置文件会校验:
命令包 CRC16
扇区序号与分包序号连续性
扇区 CRC16(通过后才将数据回调给应用)
示例
API 参考
Header File
Functions
-
esp_err_t esp_ble_ota_raw_init(void)
Initialize BLE OTA profile over ble_conn_mgr.
Registers OTA service (0x8018) and DIS service. BLE connection manager init/start is done by the application.
- 返回
ESP_OK: success
Others: error from dependent service initialization
-
esp_err_t esp_ble_ota_raw_deinit(void)
Deinitialize BLE OTA profile over ble_conn_mgr.
- 返回
ESP_OK: success
Others: error from OTA service deinitialization
-
esp_err_t esp_ble_ota_raw_recv_fw_data_callback(esp_ble_ota_raw_recv_fw_cb_t callback)
Register OTA firmware receive callback for conn_mgr backend.
Callback is invoked when one full sector passes CRC check. Register this before processing START command from the host.
- 参数
callback – [in] Firmware receive callback.
- 返回
ESP_OK: success
-
uint32_t esp_ble_ota_raw_get_fw_length(void)
Get current OTA firmware total length.
Returns
UINT32_MAXbefore START command is received.- 返回
Total firmware size in bytes, or
UINT32_MAXwhen OTA is not started.
Type Definitions
-
typedef void (*esp_ble_ota_raw_recv_fw_cb_t)(uint8_t *buf, uint32_t length)
Firmware data callback from BLE OTA profile.
- Param buf
[in] Firmware data buffer (owned by profile, valid only during callback).
- Param length
[in] Data length in bytes.