Replace exponential_backoff with submodule to FreeRTOS/backoffAlgorithm (#419)

A new repository, FreeRTOS/backoffAlgorithm, has been created for hosting the library for backoff calculation. This repo replaces the FreeRTOS-Plus/Source/Utilities/exponential_backoff with the submodule to the new repository, and updates all the demos that use retry logic to use the backoffAlgorithm API
This commit is contained in:
Archit Aggarwal
2020-11-24 14:54:31 -08:00
committed by GitHub
parent 5ba1e4cf95
commit 036ec83b65
33 changed files with 699 additions and 554 deletions

View File

@ -26,7 +26,7 @@
#include "http_demo_utils.h"
/* Exponential backoff retry include. */
#include "exponential_backoff.h"
#include "backoff_algorithm.h"
/* Parser utilities. */
#include "http_parser.h"
@ -38,15 +38,18 @@ BaseType_t connectToServerWithBackoffRetries( TransportConnect_t connectFunction
{
BaseType_t xReturn = pdFAIL;
/* Status returned by the retry utilities. */
RetryUtilsStatus_t xRetryUtilsStatus = RetryUtilsSuccess;
BackoffAlgorithmStatus_t xBackoffAlgStatus = BackoffAlgorithmSuccess;
/* Struct containing the next backoff time. */
RetryUtilsParams_t xReconnectParams;
BackoffAlgorithmContext_t xReconnectParams;
assert( connectFunction != NULL );
/* Initialize reconnect attempts and interval */
RetryUtils_ParamsReset( &xReconnectParams );
xReconnectParams.maxRetryAttempts = MAX_RETRY_ATTEMPTS;
BackoffAlgorithm_InitializeParams( &xReconnectParams,
RETRY_BACKOFF_BASE_MS,
RETRY_MAX_BACKOFF_DELAY_MS,
RETRY_MAX_ATTEMPTS,
prvGenerateRandomNumber );
/* Attempt to connect to the HTTP server. If connection fails, retry after a
* timeout. The timeout value will exponentially increase until either the
@ -63,9 +66,9 @@ BaseType_t connectToServerWithBackoffRetries( TransportConnect_t connectFunction
LogInfo( ( "Retry attempt %lu out of maximum retry attempts %lu.",
( xReconnectParams.attemptsDone + 1 ),
MAX_RETRY_ATTEMPTS ) );
xRetryUtilsStatus = RetryUtils_BackoffAndSleep( &xReconnectParams );
xBackoffAlgStatus = BackoffAlgorithm_GetNextBackoff( &xReconnectParams, &usNextBackoff );
}
} while( ( xReturn == pdFAIL ) && ( xRetryUtilsStatus == RetryUtilsSuccess ) );
} while( ( xReturn == pdFAIL ) && ( xBackoffAlgStatus == BackoffAlgorithmSuccess ) );
if( xReturn == pdFAIL )
{