Skip to content

[BUG] No signal to coreMQTT-Agent network manager that OTA job has stopped, once OTA is successful #73

Closed
@NightSkySK

Description

@NightSkySK

Describe the bug
After OTA job is finished and new firmware is verified successfully, there is no signal to coreMQTT-Agent network manager that an OTA job has stopped.
The signal is released only if OtaJobEventFail

        case OtaJobEventFail:
            ESP_LOGI( TAG, "Received an OtaJobEventFail notification from OTA Agent." );

            /* Signal coreMQTT-Agent network manager that an OTA job has stopped. */
            xCoreMqttAgentManagerPost( CORE_MQTT_AGENT_OTA_STOPPED_EVENT );
            break;

System information

  • Hardware board: ESP32
  • IDE used: IDF 5.1
  • Operating System: Windows
  • Code version: v202212.00-50-ge2d407f
  • Project/Demo: iot-reference-esp32c3
  • If your project is a custom application, please add the relevant code snippet(s) in the section titled "Code to reproduce bug".

Expected behavior
After OtaJobEventStartTest is done and image validation is finished there should be signal xCoreMqttAgentManagerPost(CORE_MQTT_AGENT_OTA_STOPPED_EVENT)
like this:

  case OtaJobEventStartTest:

    /* This demo just accepts the image since it was a good OTA update and
     * networking and services are all working (or we would not have made it
     * this far). If this were some custom device that wants to test other
     * things before validating new image, this would be the place to kick off
     * those tests before calling OTA_SetImageState() with the final result of
     * either accepted or rejected. */

    ESP_LOGI(TAG, "Received OtaJobEventStartTest callback from OTA Agent.");

    err = OTA_SetImageState(OtaImageStateAccepted);

    if (err == OtaErrNone) {
      ESP_LOGI(TAG, "New image validation succeeded in self test mode.");
    } else {
      ESP_LOGE(TAG, "Failed to set image state as accepted with error %d.",
               err);
    }
    xCoreMqttAgentManagerPost(CORE_MQTT_AGENT_OTA_STOPPED_EVENT);
    break;

and only after this flag other tasks can start their activity again.

Actually based on FreeRTOS documentation there should be one more case OtaJobEventUpdateComplete = 7, but I can't find this event in : https://github.com/FreeRTOS/iot-reference-esp32c3/blob/main/main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c#L516-L609

typedef enum OtaJobEvent
{
    OtaJobEventActivate = 0,       /*!< @brief OTA receive is authenticated and ready to activate. */
    OtaJobEventFail = 1,           /*!< @brief OTA receive failed. Unable to use this update. */
    OtaJobEventStartTest = 2,      /*!< @brief OTA job is now in self test, perform user tests. */
    OtaJobEventProcessed = 3,      /*!< @brief OTA event queued by OTA_SignalEvent is processed. */
    OtaJobEventSelfTestFailed = 4, /*!< @brief OTA self-test failed for current job. */
    OtaJobEventParseCustomJob = 5, /*!< @brief OTA event for parsing custom job document. */
    OtaJobEventReceivedJob = 6,    /*!< @brief OTA event when a new valid AFT-OTA job is received. */
    OtaJobEventUpdateComplete = 7, /*!< @brief OTA event when the update is completed. */
    OtaLastJobEvent = OtaJobEventStartTest
} OtaJobEvent_t; 

Additional question
In case OtaJobEventSelfTestFailed OTA_Shutdown is executed, should program also trigger xCoreMqttAgentManagerPost(CORE_MQTT_AGENT_OTA_STOPPED_EVENT); in that case or ot will be covered by
OtaJobEventFail any way?

        case OtaJobEventSelfTestFailed:
            ESP_LOGI( TAG, "Received OtaJobEventSelfTestFailed callback from OTA Agent." );

            /* Requires manual activation of previous image as self-test for
             * new image downloaded failed.*/
            ESP_LOGE( TAG, "OTA Self-test failed for new image. shutting down OTA Agent." );

            /* Shutdown OTA Agent, if it is required that the unsubscribe operations are not
             * performed while shutting down please set the second parameter to 0 instead of 1. */
            OTA_Shutdown( 0, 1 );

            break;

Screenshots or console output
Sorry, I didn't record console output for that case. How ever after sucessful OTA update other task kept beeing inactive. And only way to recover from this stage was to manually reboot the device

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions