Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1618 from aws/fix/OTAAgentStateMachine
Browse files Browse the repository at this point in the history
fIX: Shutdown OTA agent so that it reconnects after max errors
  • Loading branch information
pvyawaha authored Dec 13, 2019
2 parents 19d6cb8 + 0d4b779 commit 571462f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions libraries/freertos_plus/aws/ota/src/aws_iot_ota_agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,8 @@ OTAStateTableEntry_t OTATransitionTable[] =
{ eOTA_AgentState_CreatingFile, eOTA_AgentEvent_StartSelfTest, prvInSelfTestHandler, eOTA_AgentState_WaitingForJob },
{ eOTA_AgentState_CreatingFile, eOTA_AgentEvent_CreateFile, prvInitFileHandler, eOTA_AgentState_RequestingFileBlock },
{ eOTA_AgentState_CreatingFile, eOTA_AgentEvent_RequestTimer, prvInitFileHandler, eOTA_AgentState_RequestingFileBlock },
{ eOTA_AgentState_CreatingFile, eOTA_AgentEvent_CloseFile, prvCloseFileHandler, eOTA_AgentState_WaitingForJob },
{ eOTA_AgentState_RequestingFileBlock, eOTA_AgentEvent_RequestFileBlock, prvRequestDataHandler, eOTA_AgentState_WaitingForFileBlock },
{ eOTA_AgentState_RequestingFileBlock, eOTA_AgentEvent_RequestTimer, prvRequestDataHandler, eOTA_AgentState_WaitingForFileBlock },
{ eOTA_AgentState_RequestingFileBlock, eOTA_AgentEvent_CloseFile, prvCloseFileHandler, eOTA_AgentState_WaitingForJob },
{ eOTA_AgentState_WaitingForFileBlock, eOTA_AgentEvent_ReceivedFileBlock, prvProcessDataHandler, eOTA_AgentState_WaitingForFileBlock },
{ eOTA_AgentState_WaitingForFileBlock, eOTA_AgentEvent_RequestTimer, prvRequestDataHandler, eOTA_AgentState_WaitingForFileBlock },
{ eOTA_AgentState_WaitingForFileBlock, eOTA_AgentEvent_RequestFileBlock, prvRequestDataHandler, eOTA_AgentState_WaitingForFileBlock },
Expand Down Expand Up @@ -915,8 +913,8 @@ static OTA_Err_t prvInitFileHandler( OTA_EventData_t * pxEventData )
/* Stop the request timer. */
prvStopRequestTimer();

/* Send close file event. */
xEventMsg.xEventId = eOTA_AgentEvent_CloseFile;
/* Send shutdown event. */
xEventMsg.xEventId = eOTA_AgentEvent_Shutdown;
OTA_SignalEvent( &xEventMsg );

/* Too many requests have been sent without a response or too many failures
Expand Down Expand Up @@ -964,8 +962,8 @@ static OTA_Err_t prvRequestDataHandler( OTA_EventData_t * pxEventData )
/* Failed to send data request abort and close file. */
( void ) prvSetImageStateWithReason( eOTA_ImageState_Aborted, xErr );

/* Send close file event. */
xEventMsg.xEventId = eOTA_AgentEvent_CloseFile;
/* Send shutdown event. */
xEventMsg.xEventId = eOTA_AgentEvent_Shutdown;
OTA_SignalEvent( &xEventMsg );

/* Too many requests have been sent without a response or too many failures
Expand Down

0 comments on commit 571462f

Please sign in to comment.