mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-14 08:47:45 -04:00
Bump backoffAlgorithm submodule for API change and update demos (#426)
The API of FreeRTOS/backoffAlgorithm library has changed to remove dependency on random number generator; instead require the caller to generate the random number and pass it to the BackoffAlgorithm_GetNextBackoff API for backoff period calculation. This PR updates the submodule pointer commit, and updates the demos and tests to use the simplied library API
This commit is contained in:
parent
220dd5cc1c
commit
682447445b
9 changed files with 121 additions and 287 deletions
|
@ -359,15 +359,11 @@ static TlsTransportStatus_t prvConnectToServerWithBackoffRetries( NetworkContext
|
|||
#endif
|
||||
xNetworkCredentials.pAlpnProtos = pcAlpnProtocols;
|
||||
|
||||
/* Initialize reconnect attempts and interval.
|
||||
* Note: This utility uses a pseudo random number generator for use with the backoff
|
||||
* algorithm. However, it is recommended to use a True Random Number generator to
|
||||
* avoid possibility of collisions between multiple devices retrying connection. */
|
||||
/* Initialize reconnect attempts and interval.*/
|
||||
BackoffAlgorithm_InitializeParams( &xReconnectParams,
|
||||
RETRY_BACKOFF_BASE_MS,
|
||||
RETRY_MAX_BACKOFF_DELAY_MS,
|
||||
RETRY_MAX_ATTEMPTS,
|
||||
prvGenerateRandomNumber );
|
||||
RETRY_MAX_ATTEMPTS );
|
||||
|
||||
/* Attempt to connect to MQTT broker. If connection fails, retry after
|
||||
* a timeout. Timeout value will exponentially increase until maximum
|
||||
|
@ -390,9 +386,12 @@ static TlsTransportStatus_t prvConnectToServerWithBackoffRetries( NetworkContext
|
|||
|
||||
if( xNetworkStatus != TLS_TRANSPORT_SUCCESS )
|
||||
{
|
||||
/* Get back-off value (in milliseconds) for the next connection retry. */
|
||||
xBackoffAlgStatus = BackoffAlgorithm_GetNextBackoff( &xReconnectParams, &usNextRetryBackOff );
|
||||
configASSERT( xBackoffAlgStatus != BackoffAlgorithmRngFailure );
|
||||
/* Generate a random number and calculate backoff value (in milliseconds) for
|
||||
* the next connection retry.
|
||||
* Note: It is recommended to seed the random number generator with a device-specific
|
||||
* entropy source so that possibility of multiple devices retrying failed network operations
|
||||
* at similar intervals can be avoided. */
|
||||
xBackoffAlgStatus = BackoffAlgorithm_GetNextBackoff( &xReconnectParams, uxRand(), &usNextRetryBackOff );
|
||||
|
||||
if( xBackoffAlgStatus == BackoffAlgorithmRetriesExhausted )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue