diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f277d74..ab22e79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,4 +112,4 @@ jobs: uses: FreeRTOS/CI-CD-Github-Actions/memory_statistics@main with: config: .github/memory_statistics_config.json - check_against: docs/doxygen/include/size_table.html + check_against: docs/doxygen/include/size_table.md diff --git a/.github/workflows/memory_statistics.yml b/.github/workflows/memory_statistics.yml index 499d205..9c778c7 100644 --- a/.github/workflows/memory_statistics.yml +++ b/.github/workflows/memory_statistics.yml @@ -19,4 +19,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: size_table - path: size_table.html + path: size_table.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b262d7..3eb0d12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ # Changelog for backoffAlgorithm Library -## Changes after v1.0.1 -- [#27](https://github.com/FreeRTOS/backoffAlgorithm/pull/26) Fix incorrect comment about use of BACKOFF_ALGORITHM_RETRY_FOREVER constant in BackoffAlgorithm_GetNextBackoff API. +## v1.1.0 (July 2021) -## v1.0.1 (February 2020) +### Changes + +- [#29](https://github.com/FreeRTOS/backoffAlgorithm/pull/29) Set BACKOFF_ALGORITHM_RETRY_FOREVER to be nonzero and add header guards for C++ linkage. +- [#27](https://github.com/FreeRTOS/backoffAlgorithm/pull/27) Fix incorrect comment about use of BACKOFF_ALGORITHM_RETRY_FOREVER constant in BackoffAlgorithm_GetNextBackoff API. + +## v1.0.1 (February 2021) ### Changes @@ -16,4 +20,4 @@ This is the first release of the backoffAlgorithm library in this repository. The backoffAlgorithm library is a utility library to calculate backoff period using an exponential backoff with jitter algorithm for retrying network operations (like failed network connection with server). This library uses the "Full Jitter" strategy for the exponential backoff with jitter algorithm. -More information about the algorithm can be seen in the [Exponential Backoff and Jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/) AWS blog. \ No newline at end of file +More information about the algorithm can be seen in the [Exponential Backoff and Jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/) AWS blog. diff --git a/README.md b/README.md index f9e88e3..fcf9bff 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Besides, in an environment with poor connectivity, a client can get disconnected A backoff strategy helps the client to conserve battery by not repeatedly attempting reconnections when they are unlikely to succeed. -See memory requirements for this library [here](https://docs.aws.amazon.com/embedded-csdk/202103.00/lib-ref/libraries/standard/backoffAlgorithm/docs/doxygen/output/html/index.html#backoff_algorithm_memory_requirements). +See memory requirements for this library [here](./docs/doxygen/include/size_table.md). **backoffAlgorithm v1.0.0 [source code](https://github.com/FreeRTOS/backoffAlgorithm/tree/v1.0.0/source) is part of the [FreeRTOS 202012.00 LTS](https://github.com/FreeRTOS/FreeRTOS-LTS/tree/202012.00-LTS) release.** @@ -129,7 +129,7 @@ By default, the submodules in this repository are configured with `update=none` To build unit tests, the submodule dependency of Unity is required. Use the following command to clone the submodule: ``` -git submodule update --checkout --init --recursive --test/unit-test/Unity +git submodule update --checkout --init --recursive test/unit-test/Unity ``` ### Platform Prerequisites diff --git a/docs/doxygen/config.doxyfile b/docs/doxygen/config.doxyfile index d80d38d..01da3ef 100644 --- a/docs/doxygen/config.doxyfile +++ b/docs/doxygen/config.doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "backoffAlgorithm" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "v1.0.1" +PROJECT_NUMBER = "v1.1.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/docs/doxygen/include/size_table.html b/docs/doxygen/include/size_table.md similarity index 100% rename from docs/doxygen/include/size_table.html rename to docs/doxygen/include/size_table.md diff --git a/docs/doxygen/pages.dox b/docs/doxygen/pages.dox index 3e71d8c..89d5e3a 100644 --- a/docs/doxygen/pages.dox +++ b/docs/doxygen/pages.dox @@ -34,7 +34,7 @@ For a reference example of using the library, refer to the related README sectio @section backoff_algorithm_memory_requirements Memory Requirements @brief Memory requirements of the backoffAlgorithm library. -@include{doc} size_table.html +@include{doc} size_table.md @section backoff_algorithm_design Design @brief backoffAlgorithm Library Design diff --git a/lexicon.txt b/lexicon.txt index cb7a99e..4eadb40 100644 --- a/lexicon.txt +++ b/lexicon.txt @@ -32,6 +32,7 @@ mainpage maxattempts maxbackoff maxretryattempts +md min misra mockrng @@ -56,4 +57,4 @@ td toolchain tr trng -utils \ No newline at end of file +utils diff --git a/manifest.yml b/manifest.yml index d14995c..a3f03b9 100644 --- a/manifest.yml +++ b/manifest.yml @@ -1,5 +1,5 @@ name : "backoffAlgorithm" -version: "v1.0.1" +version: "v1.1.0" description: | "Algorithm for calculating exponential backoff with jitter for network retry attempts.\n" license: "MIT" diff --git a/source/backoff_algorithm.c b/source/backoff_algorithm.c index 7f1e09b..0ace108 100644 --- a/source/backoff_algorithm.c +++ b/source/backoff_algorithm.c @@ -1,5 +1,5 @@ /* - * backoffAlgorithm v1.0.1 + * backoffAlgorithm v1.1.0 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -44,9 +44,9 @@ BackoffAlgorithmStatus_t BackoffAlgorithm_GetNextBackoff( BackoffAlgorithmContex assert( pRetryContext != NULL ); assert( pNextBackOff != NULL ); - /* If maxRetryAttempts state of the context is set to 0, retry forever. */ - if( ( pRetryContext->attemptsDone < pRetryContext->maxRetryAttempts ) || - ( pRetryContext->maxRetryAttempts == BACKOFF_ALGORITHM_RETRY_FOREVER ) ) + /* If maxRetryAttempts state of the context is set to the maximum, retry forever. */ + if( ( pRetryContext->maxRetryAttempts == BACKOFF_ALGORITHM_RETRY_FOREVER ) || + ( pRetryContext->attemptsDone < pRetryContext->maxRetryAttempts ) ) { /* The next backoff value is a random value between 0 and the maximum jitter value * for the retry attempt. */ diff --git a/source/include/backoff_algorithm.h b/source/include/backoff_algorithm.h index 2e8e58d..000e9dd 100644 --- a/source/include/backoff_algorithm.h +++ b/source/include/backoff_algorithm.h @@ -1,5 +1,5 @@ /* - * backoffAlgorithm v1.0.1 + * backoffAlgorithm v1.1.0 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -36,11 +36,17 @@ /* Standard include. */ #include +/* *INDENT-OFF* */ +#ifdef __cplusplus + extern "C" { +#endif +/* *INDENT-ON* */ + /** * @ingroup backoff_algorithm_constants * @brief Constant to represent unlimited number of retry attempts. */ -#define BACKOFF_ALGORITHM_RETRY_FOREVER ( 0U ) +#define BACKOFF_ALGORITHM_RETRY_FOREVER ( UINT32_MAX ) /** * @ingroup backoff_algorithm_enum_types @@ -130,4 +136,10 @@ BackoffAlgorithmStatus_t BackoffAlgorithm_GetNextBackoff( BackoffAlgorithmContex uint16_t * pNextBackOff ); /* @[define_backoffalgorithm_getnextbackoff] */ +/* *INDENT-OFF* */ +#ifdef __cplusplus + } +#endif +/* *INDENT-ON* */ + #endif /* ifndef BACKOFF_ALGORITHM_H_ */ diff --git a/test/unit-test/backoff_algorithm_utest.c b/test/unit-test/backoff_algorithm_utest.c index 492bf67..1323fad 100644 --- a/test/unit-test/backoff_algorithm_utest.c +++ b/test/unit-test/backoff_algorithm_utest.c @@ -1,5 +1,5 @@ /* - * backoffAlgorithm v1.0.1 + * backoffAlgorithm v1.1.0 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/test/unit-test/catch_assert.h b/test/unit-test/catch_assert.h index 71713d6..8033325 100644 --- a/test/unit-test/catch_assert.h +++ b/test/unit-test/catch_assert.h @@ -1,5 +1,5 @@ /* - * backoffAlgorithm v1.0.1 + * backoffAlgorithm v1.1.0 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of