AWS IoT Device SDK C  202009.00
SDK for connecting to AWS IoT from a device using embedded C.
retry_utils.h
Go to the documentation of this file.
1 /*
2  * AWS IoT Device SDK for Embedded C V202009.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
29 #ifndef RETRY_UTILS_H_
30 #define RETRY_UTILS_H_
31 
32 /* Standard include. */
33 #include <stdint.h>
34 
174 #define MAX_RETRY_ATTEMPTS 4U
175 
180 #define INITIAL_RETRY_BACKOFF_SECONDS 1U
181 
185 #define MAX_RETRY_BACKOFF_SECONDS 128U
186 
190 #define MAX_JITTER_VALUE_SECONDS 5U
191 
195 typedef enum RetryUtilsStatus
196 {
200 
204 typedef struct RetryUtilsParams
205 {
210  uint32_t attemptsDone;
211 
215  uint32_t nextJitterMax;
217 
218 
226 /* @[define_retryutils_paramsreset] */
227 void RetryUtils_ParamsReset( RetryUtilsParams_t * pRetryParams );
228 /* @[define_retryutils_paramsreset] */
229 
240 /* @[define_retryutils_backoffandsleep] */
242 /* @[define_retryutils_backoffandsleep] */
243 
244 #endif /* ifndef RETRY_UTILS_H_ */
RetryUtilsRetriesExhausted
@ RetryUtilsRetriesExhausted
The function exhausted all retry attempts.
Definition: retry_utils.h:198
RetryUtilsStatus_t
RetryUtilsStatus_t
Status for RetryUtils_BackoffAndSleep.
Definition: retry_utils.h:196
RetryUtilsSuccess
@ RetryUtilsSuccess
The function returned successfully after sleeping.
Definition: retry_utils.h:197
RetryUtils_BackoffAndSleep
RetryUtilsStatus_t RetryUtils_BackoffAndSleep(RetryUtilsParams_t *pRetryParams)
Simple platform specific exponential backoff function. The application must use this function between...
Definition: retry_utils_posix.c:37
RetryUtilsParams_t::nextJitterMax
uint32_t nextJitterMax
The max jitter value for backoff time in retry attempt.
Definition: retry_utils.h:215
RetryUtilsParams_t
Represents parameters required for retry logic.
Definition: retry_utils.h:205
RetryUtils_ParamsReset
void RetryUtils_ParamsReset(RetryUtilsParams_t *pRetryParams)
Resets the retry timeout value and number of attempts. This function must be called by the applicatio...
Definition: retry_utils_posix.c:82
RetryUtilsParams_t::attemptsDone
uint32_t attemptsDone
The cumulative count of backoff delay cycles completed for retries.
Definition: retry_utils.h:210