BLE OTA Profile

[中文]

The BLE OTA Profile provides sector-based firmware transfer over BLE on top of esp_ble_conn_mgr. It uses the OTA service UUID 0x8018 and parses START/STOP commands plus firmware packets from the host.

The profile validates:

  • command packet CRC16

  • sector index and packet sequence continuity

  • sector CRC16 before delivering data to application callback

Examples

bluetooth/ble_profiles/ble_ota.

API Reference

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.

Returns

  • 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.

Returns

  • 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.

Parameters

callback[in] Firmware receive callback.

Returns

  • ESP_OK: success

uint32_t esp_ble_ota_raw_get_fw_length(void)

Get current OTA firmware total length.

Returns UINT32_MAX before START command is received.

Returns

Total firmware size in bytes, or UINT32_MAX when 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.