diff --git a/components/esp_https_ota/include/esp_https_ota.h b/components/esp_https_ota/include/esp_https_ota.h index f880862f28..da7ad89a5b 100644 --- a/components/esp_https_ota/include/esp_https_ota.h +++ b/components/esp_https_ota/include/esp_https_ota.h @@ -22,17 +22,6 @@ ESP_EVENT_DECLARE_BASE(ESP_HTTPS_OTA_EVENT); /** * @brief Events generated by OTA process - * - * @note Expected data type for different OTA events: - * - ESP_HTTPS_OTA_START : NULL - * - ESP_HTTPS_OTA_CONNECTED : NULL - * - ESP_HTTPS_OTA_GET_IMG_DESC : NULL - * - ESP_HTTPS_OTA_VERIFY_CHIP_ID : esp_chip_id_t - * - ESP_HTTPS_OTA_DECRYPT_CB : NULL - * - ESP_HTTPS_OTA_WRITE_FLASH : int - * - ESP_HTTPS_OTA_UPDATE_BOOT_PARTITION : esp_partition_subtype_t - * - ESP_HTTPS_OTA_FINISH : NULL - * - ESP_HTTPS_OTA_ABORT : NULL */ typedef enum { ESP_HTTPS_OTA_START, /*!< OTA started */ diff --git a/docs/en/api-reference/system/esp_https_ota.rst b/docs/en/api-reference/system/esp_https_ota.rst index 2ea4a623e5..30ebf3ba65 100644 --- a/docs/en/api-reference/system/esp_https_ota.rst +++ b/docs/en/api-reference/system/esp_https_ota.rst @@ -70,6 +70,67 @@ To perform OTA upgrades with Pre-Encrypted Firmware, please enable :ref:`CONFIG_ Example that performs OTA upgrade with Pre-Encrypted Firmware: :example:`system/ota/pre_encrypted_ota`. +OTA System Events +----------------- + +ESP HTTPS OTA has various events for which a handler can be triggered by :doc:`the Event Loop library <../system/esp_event>` when the particular event occurs. The handler has to be registered using :cpp:func:`esp_event_handler_register`. This helps in event handling for ESP HTTPS OTA. +:cpp:enum:`esp_https_ota_event_t` has all the events which can happen when performing OTA upgrade using ESP HTTPS OTA. + +Event Handler Example +^^^^^^^^^^^^^^^^^^^^^ + + .. highlight:: c + + :: + + /* Event handler for catching system events */ + static void event_handler(void* arg, esp_event_base_t event_base, + int32_t event_id, void* event_data) + { + if (event_base == ESP_HTTPS_OTA_EVENT) { + switch (event_id) { + case ESP_HTTPS_OTA_START: + ESP_LOGI(TAG, "OTA started"); + break; + case ESP_HTTPS_OTA_CONNECTED: + ESP_LOGI(TAG, "Connected to server"); + break; + case ESP_HTTPS_OTA_GET_IMG_DESC: + ESP_LOGI(TAG, "Reading Image Description"); + break; + case ESP_HTTPS_OTA_VERIFY_CHIP_ID: + ESP_LOGI(TAG, "Verifying chip id of new image: %d", *(esp_chip_id_t *)event_data); + break; + case ESP_HTTPS_OTA_DECRYPT_CB: + ESP_LOGI(TAG, "Callback to decrypt function"); + break; + case ESP_HTTPS_OTA_WRITE_FLASH: + ESP_LOGD(TAG, "Writing to flash: %d written", *(int *)event_data); + break; + case ESP_HTTPS_OTA_UPDATE_BOOT_PARTITION: + ESP_LOGI(TAG, "Boot partition updated. Next Partition: %d", *(esp_partition_subtype_t *)event_data); + break; + case ESP_HTTPS_OTA_FINISH: + ESP_LOGI(TAG, "OTA finish"); + break; + case ESP_HTTPS_OTA_ABORT: + ESP_LOGI(TAG, "OTA abort"); + break; + } + } + } + +Expected data type for different ESP HTTPS OTA events in the system event loop: + - ESP_HTTPS_OTA_START : ``NULL`` + - ESP_HTTPS_OTA_CONNECTED : ``NULL`` + - ESP_HTTPS_OTA_GET_IMG_DESC : ``NULL`` + - ESP_HTTPS_OTA_VERIFY_CHIP_ID : ``esp_chip_id_t`` + - ESP_HTTPS_OTA_DECRYPT_CB : ``NULL`` + - ESP_HTTPS_OTA_WRITE_FLASH : ``int`` + - ESP_HTTPS_OTA_UPDATE_BOOT_PARTITION : ``esp_partition_subtype_t`` + - ESP_HTTPS_OTA_FINISH : ``NULL`` + - ESP_HTTPS_OTA_ABORT : ``NULL`` + API Reference -------------