diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad9774a8..c82b0462 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,6 +116,7 @@ jobs: config: .github/memory_statistics_config.json check_against: docs/doxygen/include/size_table.md proof_ci: + if: ${{ github.event.pull_request }} runs-on: cbmc_ubuntu-latest_16-core steps: - name: Set up CBMC runner diff --git a/source/include/shadow.h b/source/include/shadow.h index 95ce8268..9d834064 100644 --- a/source/include/shadow.h +++ b/source/include/shadow.h @@ -4,22 +4,23 @@ * * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ /** @@ -35,7 +36,7 @@ /* *INDENT-OFF* */ #ifdef __cplusplus - extern "C" { +extern "C" { #endif /* *INDENT-ON* */ @@ -75,8 +76,8 @@ typedef enum ShadowMessageType * @ingroup shadow_enum_types * @brief Each of these values describes the type of a shadow topic string. * - * These are used for topicType parameter of Shadow_AssembleTopicString() to tell it - * what topic string to assemble. + * These are used for topicType parameter of Shadow_AssembleTopicString() to + * tell it what topic string to assemble. */ typedef enum ShadowTopicStringType { @@ -100,14 +101,18 @@ typedef enum ShadowTopicStringType */ typedef enum ShadowStatus { - SHADOW_SUCCESS = 0, /**< @brief Shadow function success. */ - SHADOW_FAIL, /**< @brief Shadow function encountered error. */ - SHADOW_BAD_PARAMETER, /**< @brief Input parameter is invalid. */ - SHADOW_BUFFER_TOO_SMALL, /**< @brief The provided buffer is too small. */ - SHADOW_THINGNAME_PARSE_FAILED, /**< @brief Could not parse the thing name. */ - SHADOW_MESSAGE_TYPE_PARSE_FAILED, /**< @brief Could not parse the shadow type. */ - SHADOW_ROOT_PARSE_FAILED, /**< @brief Could not parse the classic or named shadow root. */ - SHADOW_SHADOWNAME_PARSE_FAILED /**< @brief Could not parse the shadow name (in the case of a named shadow topic). */ + SHADOW_SUCCESS = 0, /**< @brief Shadow function success. */ + SHADOW_FAIL, /**< @brief Shadow function encountered error. */ + SHADOW_BAD_PARAMETER, /**< @brief Input parameter is invalid. */ + SHADOW_BUFFER_TOO_SMALL, /**< @brief The provided buffer is too small. */ + SHADOW_THINGNAME_PARSE_FAILED, /**< @brief Could not parse the thing name. + */ + SHADOW_MESSAGE_TYPE_PARSE_FAILED, /**< @brief Could not parse the shadow + type. */ + SHADOW_ROOT_PARSE_FAILED, /**< @brief Could not parse the classic or named + shadow root. */ + SHADOW_SHADOWNAME_PARSE_FAILED /**< @brief Could not parse the shadow name + (in the case of a named shadow topic). */ } ShadowStatus_t; /*------------------------ Shadow library constants -------------------------*/ @@ -115,125 +120,139 @@ typedef enum ShadowStatus /** * @ingroup shadow_constants * @brief The common prefix of all Shadow MQTT topics - * from here https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html. + * from here + * https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html. */ -#define SHADOW_PREFIX "$aws/things/" +#define SHADOW_PREFIX "$aws/things/" /** * @ingroup shadow_constants * @brief The length of #SHADOW_PREFIX. */ -#define SHADOW_PREFIX_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_PREFIX ) - 1U ) ) +#define SHADOW_PREFIX_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_PREFIX ) - 1U ) ) /** * @ingroup shadow_constants * @brief The root of all unnamed "Classic" Shadow MQTT topics - * from here https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html. + * from here + * https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html. */ -#define SHADOW_CLASSIC_ROOT "/shadow" +#define SHADOW_CLASSIC_ROOT "/shadow" /** * @ingroup shadow_constants * @brief The length of #SHADOW_CLASSIC_ROOT. */ -#define SHADOW_CLASSIC_ROOT_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_CLASSIC_ROOT ) - 1U ) ) +#define SHADOW_CLASSIC_ROOT_LENGTH \ + ( ( uint16_t ) ( sizeof( SHADOW_CLASSIC_ROOT ) - 1U ) ) /** * @ingroup shadow_constants * @brief The common root of all named Shadow MQTT topics - * from here https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html. + * from here + * https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html. */ -#define SHADOW_NAMED_ROOT "/shadow/name/" +#define SHADOW_NAMED_ROOT "/shadow/name/" /** * @ingroup shadow_constants * @brief The length of #SHADOW_NAMED_ROOT. */ -#define SHADOW_NAMED_ROOT_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_NAMED_ROOT ) - 1U ) ) +#define SHADOW_NAMED_ROOT_LENGTH \ + ( ( uint16_t ) ( sizeof( SHADOW_NAMED_ROOT ) - 1U ) ) /** * @ingroup shadow_constants - * @brief The string representing a Shadow "DELETE" operation in a Shadow MQTT topic. + * @brief The string representing a Shadow "DELETE" operation in a Shadow MQTT + * topic. */ -#define SHADOW_OP_DELETE "/delete" +#define SHADOW_OP_DELETE "/delete" /** * @ingroup shadow_constants * @brief The length of #SHADOW_OP_DELETE. */ -#define SHADOW_OP_DELETE_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_OP_DELETE ) - 1U ) ) +#define SHADOW_OP_DELETE_LENGTH \ + ( ( uint16_t ) ( sizeof( SHADOW_OP_DELETE ) - 1U ) ) /** * @ingroup shadow_constants - * @brief The string representing a Shadow "GET" operation in a Shadow MQTT topic. + * @brief The string representing a Shadow "GET" operation in a Shadow MQTT + * topic. */ -#define SHADOW_OP_GET "/get" +#define SHADOW_OP_GET "/get" /** * @ingroup shadow_constants * @brief The length of #SHADOW_OP_GET. */ -#define SHADOW_OP_GET_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_OP_GET ) - 1U ) ) +#define SHADOW_OP_GET_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_OP_GET ) - 1U ) ) /** * @ingroup shadow_constants - * @brief The string representing a Shadow "UPDATE" operation in a Shadow MQTT topic. + * @brief The string representing a Shadow "UPDATE" operation in a Shadow MQTT + * topic. */ -#define SHADOW_OP_UPDATE "/update" +#define SHADOW_OP_UPDATE "/update" /** * @ingroup shadow_constants * @brief The length of #SHADOW_OP_UPDATE. */ -#define SHADOW_OP_UPDATE_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_OP_UPDATE ) - 1U ) ) +#define SHADOW_OP_UPDATE_LENGTH \ + ( ( uint16_t ) ( sizeof( SHADOW_OP_UPDATE ) - 1U ) ) /** * @ingroup shadow_constants * @brief The suffix for a Shadow operation "accepted" topic. */ -#define SHADOW_SUFFIX_ACCEPTED "/accepted" +#define SHADOW_SUFFIX_ACCEPTED "/accepted" /** * @ingroup shadow_constants * @brief The length of #SHADOW_SUFFIX_ACCEPTED. */ -#define SHADOW_SUFFIX_ACCEPTED_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_SUFFIX_ACCEPTED ) - 1U ) ) +#define SHADOW_SUFFIX_ACCEPTED_LENGTH \ + ( ( uint16_t ) ( sizeof( SHADOW_SUFFIX_ACCEPTED ) - 1U ) ) /** * @ingroup shadow_constants * @brief The suffix for a Shadow operation "rejected" topic. */ -#define SHADOW_SUFFIX_REJECTED "/rejected" +#define SHADOW_SUFFIX_REJECTED "/rejected" /** * @ingroup shadow_constants * @brief The length of #SHADOW_SUFFIX_REJECTED. */ -#define SHADOW_SUFFIX_REJECTED_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_SUFFIX_REJECTED ) - 1U ) ) +#define SHADOW_SUFFIX_REJECTED_LENGTH \ + ( ( uint16_t ) ( sizeof( SHADOW_SUFFIX_REJECTED ) - 1U ) ) /** * @ingroup shadow_constants * @brief The suffix for a Shadow "delta" topic. */ -#define SHADOW_SUFFIX_DELTA "/delta" +#define SHADOW_SUFFIX_DELTA "/delta" /** * @ingroup shadow_constants * @brief The length of #SHADOW_SUFFIX_DELTA. */ -#define SHADOW_SUFFIX_DELTA_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_SUFFIX_DELTA ) - 1U ) ) +#define SHADOW_SUFFIX_DELTA_LENGTH \ + ( ( uint16_t ) ( sizeof( SHADOW_SUFFIX_DELTA ) - 1U ) ) /** * @ingroup shadow_constants * @brief The suffix for a Shadow "documents" topic. */ -#define SHADOW_SUFFIX_DOCUMENTS "/documents" +#define SHADOW_SUFFIX_DOCUMENTS "/documents" /** * @ingroup shadow_constants * @brief The length of #SHADOW_SUFFIX_DOCUMENTS. */ -#define SHADOW_SUFFIX_DOCUMENTS_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_SUFFIX_DOCUMENTS ) - 1U ) ) +#define SHADOW_SUFFIX_DOCUMENTS_LENGTH \ + ( ( uint16_t ) ( sizeof( SHADOW_SUFFIX_DOCUMENTS ) - 1U ) ) /** * @ingroup shadow_constants @@ -245,63 +264,68 @@ typedef enum ShadowStatus * @ingroup shadow_constants * @brief The length of null suffix. */ -#define SHADOW_SUFFIX_NULL_LENGTH ( 0U ) +#define SHADOW_SUFFIX_NULL_LENGTH ( 0U ) /** * @ingroup shadow_constants * @brief The maximum length of Thing Name. */ -#define SHADOW_THINGNAME_LENGTH_MAX ( 128U ) +#define SHADOW_THINGNAME_LENGTH_MAX ( 128U ) /** * @ingroup shadow_constants * @brief The maximum length of Shadow Name. */ -#define SHADOW_NAME_LENGTH_MAX ( 64U ) +#define SHADOW_NAME_LENGTH_MAX ( 64U ) /** * @ingroup shadow_constants * @brief The name string for the unnamed "Classic" shadow. */ -#define SHADOW_NAME_CLASSIC "" +#define SHADOW_NAME_CLASSIC "" /** * @ingroup shadow_constants * @brief The length of #SHADOW_NAME_CLASSIC. */ -#define SHADOW_NAME_CLASSIC_LENGTH ( ( uint16_t ) ( sizeof( SHADOW_NAME_CLASSIC ) - 1U ) ) +#define SHADOW_NAME_CLASSIC_LENGTH \ + ( ( uint16_t ) ( sizeof( SHADOW_NAME_CLASSIC ) - 1U ) ) /** * @ingroup shadow_constants * @brief Compute shadow topic length. * - * The format of shadow topic strings is defined at https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html + * The format of shadow topic strings is defined at + * https://docs.aws.amazon.com/iot/latest/developerguide/device-shadow-mqtt.html * - * A shadow topic string takes one of the two forms, in the case of an unnamed ("Classic") shadow: - * $aws/things/\/shadow/\ + * A shadow topic string takes one of the two forms, in the case of an unnamed + * ("Classic") shadow: $aws/things/\/shadow/\ * $aws/things/\/shadow/\/\ * * Or as follows, in the case of a named shadow: * $aws/things/\/shadow/name// * $aws/things/\/shadow/name///\ * - * The \, \, \ and \ segments correspond to the - * four input parameters of this macro. The \ part can be null. + * The \, \, \ and \ segments + * correspond to the four input parameters of this macro. The \ part + * can be null. * - * When thingName and shadow name are known to be "myThing" and "myShadow" at compile time, - * invoke the macro like this: - * (In this case, the length is a constant at compile time.) + * When thingName and shadow name are known to be "myThing" and "myShadow" at + * compile time, invoke the macro like this: (In this case, the length is a + * constant at compile time.) * - * SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, SHADOW_SUFFIX_DELTA_LENGTH, 7, 8 ) + * SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, SHADOW_SUFFIX_DELTA_LENGTH, 7, + * 8 ) * - * When thingName and shadowName are only known at run time, and held in variables myThingName - * and myShadowName, invoke the macro like this: + * When thingName and shadowName are only known at run time, and held in + * variables myThingName and myShadowName, invoke the macro like this: * * SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, SHADOW_SUFFIX_DELTA_LENGTH, * strlen( ( const char * ) myThingName ), * strlen( ( const char * ) myShadowName ) ) * - * To compute an unnamed ("Classic") shadow length, the shadowName length passed must be zero. + * To compute an unnamed ("Classic") shadow length, the shadowName length passed + * must be zero. * * @param[in] operationLength Can be one of: * - #SHADOW_OP_UPDATE_LENGTH @@ -313,176 +337,255 @@ typedef enum ShadowStatus * - #SHADOW_SUFFIX_REJECTED_LENGTH * - #SHADOW_SUFFIX_DELTA_LENGTH * - #SHADOW_SUFFIX_DOCUMENTS_LENGTH - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ -#define SHADOW_TOPIC_LEN( operationLength, suffixLength, thingNameLength, shadowNameLength ) \ - ( operationLength + suffixLength + thingNameLength + shadowNameLength + \ - SHADOW_PREFIX_LENGTH + \ - ( ( shadowNameLength > 0 ) ? SHADOW_NAMED_ROOT_LENGTH : SHADOW_CLASSIC_ROOT_LENGTH ) ) +#define SHADOW_TOPIC_LEN( operationLength, \ + suffixLength, \ + thingNameLength, \ + shadowNameLength ) \ + ( operationLength + suffixLength + thingNameLength + shadowNameLength + \ + SHADOW_PREFIX_LENGTH + \ + ( ( shadowNameLength > 0 ) ? SHADOW_NAMED_ROOT_LENGTH \ + : SHADOW_CLASSIC_ROOT_LENGTH ) ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/update" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/update" or * "$aws/things//shadow/name//update". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_UPDATE( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, SHADOW_SUFFIX_NULL_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, \ + SHADOW_SUFFIX_NULL_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/update/accepted" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/update/accepted" or * "$aws/things//shadow/name//update/accepted". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_UPDATE_ACC( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, SHADOW_SUFFIX_ACCEPTED_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, \ + SHADOW_SUFFIX_ACCEPTED_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/update/rejected" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/update/rejected" or * "$aws/things//shadow/name//update/rejected". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_UPDATE_REJ( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, SHADOW_SUFFIX_REJECTED_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, \ + SHADOW_SUFFIX_REJECTED_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/update/documents" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/update/documents" or * "$aws/things//shadow/name//update/documents". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_UPDATE_DOCS( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, SHADOW_SUFFIX_DOCUMENTS_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, \ + SHADOW_SUFFIX_DOCUMENTS_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/update/delta" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/update/delta" or * "$aws/things//shadow/name//update/delta". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_UPDATE_DELTA( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, SHADOW_SUFFIX_DELTA_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, \ + SHADOW_SUFFIX_DELTA_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/get" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/get" or * "$aws/things//shadow/name//get". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_GET( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_GET_LENGTH, SHADOW_SUFFIX_NULL_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_GET_LENGTH, \ + SHADOW_SUFFIX_NULL_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/get/accepted" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/get/accepted" or * "$aws/things//shadow/name//get/accepted". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_GET_ACC( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_GET_LENGTH, SHADOW_SUFFIX_ACCEPTED_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_GET_LENGTH, \ + SHADOW_SUFFIX_ACCEPTED_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/get/rejected" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/get/rejected" or * "$aws/things//shadow/name//get/rejected". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_GET_REJ( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_GET_LENGTH, SHADOW_SUFFIX_REJECTED_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_GET_LENGTH, \ + SHADOW_SUFFIX_REJECTED_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/delete" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/delete" or * "$aws/things//shadow/name//delete". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_DELETE( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_DELETE_LENGTH, SHADOW_SUFFIX_NULL_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_DELETE_LENGTH, \ + SHADOW_SUFFIX_NULL_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/delete/accepted" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/delete/accepted" or * "$aws/things//shadow/name//delete/accepted". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_DELETE_ACC( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_DELETE_LENGTH, SHADOW_SUFFIX_ACCEPTED_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_DELETE_LENGTH, \ + SHADOW_SUFFIX_ACCEPTED_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Compute the length of shadow topic "$aws/things//shadow/delete/rejected" or + * @brief Compute the length of shadow topic + * "$aws/things//shadow/delete/rejected" or * "$aws/things//shadow/name//delete/rejected". * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_DELETE_REJ( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_DELETE_LENGTH, SHADOW_SUFFIX_REJECTED_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_DELETE_LENGTH, \ + SHADOW_SUFFIX_REJECTED_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants * @brief Compute the length of the longest shadow topic. * - * @param[in] thingNameLength Length of the thingName excluding the ending NULL. - * @param[in] shadowNameLength Length of the shadowName excluding the ending NULL. Zero for "Classic" shadow. + * @param[in] thingNameLength Length of the thingName excluding the ending + * NULL. + * @param[in] shadowNameLength Length of the shadowName excluding the ending + * NULL. Zero for "Classic" shadow. * * @return Length of the shadow topic in bytes. */ #define SHADOW_TOPIC_LEN_MAX( thingNameLength, shadowNameLength ) \ - SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, SHADOW_SUFFIX_DOCUMENTS_LENGTH, thingNameLength, shadowNameLength ) + SHADOW_TOPIC_LEN( SHADOW_OP_UPDATE_LENGTH, \ + SHADOW_SUFFIX_DOCUMENTS_LENGTH, \ + thingNameLength, \ + shadowNameLength ) /** * @ingroup shadow_constants - * @brief Assemble constant shadow topic strings when Thing Name is known at compile time. + * @brief Assemble constant shadow topic strings when Thing Name is known at + * compile time. * - * When thingName is known to be "myThing" at compile time, invoke the macro like this: + * When thingName is known to be "myThing" at compile time, invoke the macro + * like this: * * SHADOW_TOPIC_STR( SHADOW_OP_UPDATE, SHADOW_SUFFIX_DELTA, "myThing" ) * @@ -501,79 +604,106 @@ typedef enum ShadowStatus * - #SHADOW_SUFFIX_DOCUMENTS * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ -#define SHADOW_TOPIC_STR( thingName, shadowName, operation, suffix ) \ - ( ( sizeof( shadowName ) > 1 ) ? \ - ( SHADOW_PREFIX thingName SHADOW_NAMED_ROOT shadowName operation suffix ) : \ - ( SHADOW_PREFIX thingName SHADOW_CLASSIC_ROOT operation suffix ) ) +#define SHADOW_TOPIC_STR( thingName, shadowName, operation, suffix ) \ + ( ( sizeof( shadowName ) > 1 ) \ + ? ( SHADOW_PREFIX thingName SHADOW_NAMED_ROOT shadowName operation \ + suffix ) \ + : ( SHADOW_PREFIX thingName SHADOW_CLASSIC_ROOT operation suffix ) ) /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/update" or + * @brief Assemble shadow topic string "$aws/things//shadow/update" + * or * "$aws/things//shadow/name//update". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_UPDATE( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_UPDATE, SHADOW_SUFFIX_NULL ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_UPDATE, \ + SHADOW_SUFFIX_NULL ) /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/update/accepted" or + * @brief Assemble shadow topic string + * "$aws/things//shadow/update/accepted" or * "$aws/things//shadow/name//update/accepted". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_UPDATE_ACC( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_UPDATE, SHADOW_SUFFIX_ACCEPTED ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_UPDATE, \ + SHADOW_SUFFIX_ACCEPTED ) /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/update/rejected" or + * @brief Assemble shadow topic string + * "$aws/things//shadow/update/rejected" or * "$aws/things//shadow/name//update/rejected". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_UPDATE_REJ( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_UPDATE, SHADOW_SUFFIX_REJECTED ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_UPDATE, \ + SHADOW_SUFFIX_REJECTED ) /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/update/documents" or + * @brief Assemble shadow topic string + * "$aws/things//shadow/update/documents" or * "$aws/things//shadow/name//update/documents". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_UPDATE_DOCS( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_UPDATE, SHADOW_SUFFIX_DOCUMENTS ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_UPDATE, \ + SHADOW_SUFFIX_DOCUMENTS ) /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/update/delta" or + * @brief Assemble shadow topic string + * "$aws/things//shadow/update/delta" or * "$aws/things//shadow/name//update/delta". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_UPDATE_DELTA( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_UPDATE, SHADOW_SUFFIX_DELTA ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_UPDATE, \ + SHADOW_SUFFIX_DELTA ) /** * @ingroup shadow_constants @@ -581,7 +711,8 @@ typedef enum ShadowStatus * "$aws/things//shadow/name//get". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ @@ -590,78 +721,104 @@ typedef enum ShadowStatus /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/get/accepted" or + * @brief Assemble shadow topic string + * "$aws/things//shadow/get/accepted" or * "$aws/things//shadow/name//get/accepted". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_GET_ACC( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_GET, SHADOW_SUFFIX_ACCEPTED ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_GET, \ + SHADOW_SUFFIX_ACCEPTED ) /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/get/rejected" or + * @brief Assemble shadow topic string + * "$aws/things//shadow/get/rejected" or * "$aws/things//shadow/name//get/rejected". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_GET_REJ( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_GET, SHADOW_SUFFIX_REJECTED ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_GET, \ + SHADOW_SUFFIX_REJECTED ) /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/delete" or + * @brief Assemble shadow topic string "$aws/things//shadow/delete" + * or * "$aws/things//shadow/name//delete". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_DELETE( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_DELETE, SHADOW_SUFFIX_NULL ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_DELETE, \ + SHADOW_SUFFIX_NULL ) /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/delete/accepted" or + * @brief Assemble shadow topic string + * "$aws/things//shadow/delete/accepted" or * "$aws/things//shadow/name//delete/accepted". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_DELETE_ACC( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_DELETE, SHADOW_SUFFIX_ACCEPTED ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_DELETE, \ + SHADOW_SUFFIX_ACCEPTED ) /** * @ingroup shadow_constants - * @brief Assemble shadow topic string "$aws/things//shadow/delete/rejected". or + * @brief Assemble shadow topic string + * "$aws/things//shadow/delete/rejected". or * "$aws/things//shadow/name//delete/rejected". * * @param[in] thingName Thing Name. - * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") shadow. + * @param[in] shadowName Shadow Name. Empty string for an unnamed ("Classic") + * shadow. * * @return Topic string. */ #define SHADOW_TOPIC_STR_DELETE_REJ( thingName, shadowName ) \ - SHADOW_TOPIC_STR( thingName, shadowName, SHADOW_OP_DELETE, SHADOW_SUFFIX_REJECTED ) + SHADOW_TOPIC_STR( thingName, \ + shadowName, \ + SHADOW_OP_DELETE, \ + SHADOW_SUFFIX_REJECTED ) /*------------------------ Shadow library functions -------------------------*/ /** - * @brief Assemble shadow topic string when Thing Name or Shadow Name is only known at run time. - * If both the Thing Name and Shadow Name are known at compile time, use + * @brief Assemble shadow topic string when Thing Name or Shadow Name is only + * known at run time. If both the Thing Name and Shadow Name are known at + * compile time, use * @link #SHADOW_TOPIC_STR SHADOW_TOPIC_STR_* @endlink macros instead. * - * @param[in] topicType Indicates what topic will be written into the buffer pointed to by pTopicBuffer. - * can be one of: + * @param[in] topicType Indicates what topic will be written into the buffer + * pointed to by pTopicBuffer. can be one of: * - ShadowTopicStringTypeGet * - ShadowTopicStringTypeGetAccepted * - ShadowTopicStringTypeGetRejected @@ -673,17 +830,23 @@ typedef enum ShadowStatus * - ShadowTopicStringTypeUpdateRejected * - ShadowTopicStringTypeUpdateDocuments * - ShadowTopicStringTypeUpdateDelta - * @param[in] pThingName Thing Name string. No need to be null terminated. Must not be NULL. - * @param[in] thingNameLength Length of Thing Name string pointed to by pThingName. Must not be zero. - * @param[in] pShadowName Shadow Name string. No need to be null terminated. Must not be NULL. Empty string for classic shadow. - * @param[in] shadowNameLength Length of Shadow Name string pointed to by pShadowName. Zero for classic shadow. + * @param[in] pThingName Thing Name string. No need to be null terminated. Must + * not be NULL. + * @param[in] thingNameLength Length of Thing Name string pointed to by + * pThingName. Must not be zero. + * @param[in] pShadowName Shadow Name string. No need to be null terminated. + * Must not be NULL. Empty string for classic shadow. + * @param[in] shadowNameLength Length of Shadow Name string pointed to by + * pShadowName. Zero for classic shadow. * @param[out] pTopicBuffer Pointer to buffer for returning the topic string. - * Caller is responsible for supplying memory pointed to by pTopicBuffer. - * This function does not fill in the terminating null character. The app - * can supply a buffer that does not have space for holding the null character. - * @param[in] bufferSize Length of pTopicBuffer. This function will return error if - * bufferSize is less than the length of the assembled topic string. - * @param[out] pOutLength Pointer to caller-supplied memory for returning the length of the topic string. + * Caller is responsible for supplying memory pointed to by + * pTopicBuffer. This function does not fill in the terminating null character. + * The app can supply a buffer that does not have space for holding the null + * character. + * @param[in] bufferSize Length of pTopicBuffer. This function will return + * error if bufferSize is less than the length of the assembled topic string. + * @param[out] pOutLength Pointer to caller-supplied memory for returning the + * length of the topic string. * @return One of the following: * - SHADOW_SUCCESS if successful. * - An error code if failed to assemble. @@ -715,7 +878,8 @@ typedef enum ShadowStatus * * if( shadowStatus == SHADOW_SUCCESS ) * { - * // The assembled topic string is put in pTopicBuffer with the length outLength. + * // The assembled topic string is put in pTopicBuffer with the length + * outLength. * } * * @endcode @@ -733,36 +897,43 @@ ShadowStatus_t Shadow_AssembleTopicString( ShadowTopicStringType_t topicType, /** * @brief Given the topic string of an incoming message, determine whether it is - * related to a device shadow; if it is, return information about the type of - * device shadow message, and pointers to the Thing Name and Shadow Name inside of - * the topic string. See #ShadowMessageType_t for the list of message types. - * Those types correspond to Device Shadow Topics. - * - * @note When this function returns, the pointer pThingName points at the first character - * of the \ segment inside of the topic string. Likewise, the pointer pShadowName - * points at the first character of the \ segment inside of the topic string - * (if the topic is for a named shadow, not the "Classic" shadow.) - * Caller is responsible for keeping the memory holding the topic string around while - * accessing the Thing Name through pThingName and the Shadow Name through pShadowName. - * - * @param[in] pTopic Pointer to the MQTT topic string. Does not have to be null-terminated. + * related to a device shadow; if it is, return information about the + * type of device shadow message, and pointers to the Thing Name and Shadow Name + * inside of the topic string. See #ShadowMessageType_t for the list of message + * types. Those types correspond to Device Shadow Topics. + * + * @note When this function returns, the pointer pThingName points at the first + * character of the \ segment inside of the topic string. Likewise, + * the pointer pShadowName points at the first character of the \ + * segment inside of the topic string (if the topic is for a named shadow, not + * the "Classic" shadow.) Caller is responsible for keeping the memory holding + * the topic string around while accessing the Thing Name through pThingName and + * the Shadow Name through pShadowName. + * + * @param[in] pTopic Pointer to the MQTT topic string. Does not have to be + * null-terminated. * @param[in] topicLength Length of the MQTT topic string. - * @param[out] pMessageType Pointer to caller-supplied memory for returning the type of the shadow message. - * @param[out] pThingName Points to the 1st character of Thing Name inside of the topic string, and can be - * null if caller does not need to know the Thing Name contained in the topic string. - * @param[out] pThingNameLength Pointer to caller-supplied memory for returning the length of the Thing Name, - * and can be null if caller does not need to know the Thing Name contained in the topic string. - * @param[out] pShadowName Points to the 1st character of Shadow Name inside of the topic string, and can be - * null if caller does not need to know the Shadow Name contained in the topic string. Null is - * returned if the shadow is Classic. - * @param[out] pShadowNameLength Pointer to caller-supplied memory for returning the length of the Shadow Name, - * and can be null if caller does not need to know the Shadow Name contained in the topic string. - * A value of 0 is returned if the shadow is Classic. + * @param[out] pMessageType Pointer to caller-supplied memory for returning the + * type of the shadow message. + * @param[out] pThingName Points to the 1st character of Thing Name inside of + * the topic string, and can be null if caller does not need to know the Thing + * Name contained in the topic string. + * @param[out] pThingNameLength Pointer to caller-supplied memory for returning + * the length of the Thing Name, and can be null if caller does not need to know + * the Thing Name contained in the topic string. + * @param[out] pShadowName Points to the 1st character of Shadow Name inside of + * the topic string, and can be null if caller does not need to know the Shadow + * Name contained in the topic string. Null is returned if the shadow is + * Classic. + * @param[out] pShadowNameLength Pointer to caller-supplied memory for returning + * the length of the Shadow Name, and can be null if caller does not need to + * know the Shadow Name contained in the topic string. A value of 0 is returned + * if the shadow is Classic. * @return One of the following: * - #SHADOW_SUCCESS if the message is related to a device shadow; - * - An error code defined in #ShadowStatus_t if the message is not related to a device shadow, - * if any input parameter is invalid, or if the function fails to - * parse the topic string. + * - An error code defined in #ShadowStatus_t if the message is not + * related to a device shadow, if any input parameter is invalid, or if the + * function fails to parse the topic string. * * Example * @code{c} @@ -786,7 +957,8 @@ ShadowStatus_t Shadow_AssembleTopicString( ShadowTopicStringType_t topicType, * * if( shadowStatus == SHADOW_SUCCESS ) * { - * // It is a device shadow message. And the type of the message has been returned in messageType. + * // It is a device shadow message. And the type of the message has been + * returned in messageType. * // Now we can act on the message. * } * @@ -811,10 +983,14 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, * See @ref #SHADOW_TOPIC_LEN for documentation of common behavior. */ #define SHADOW_TOPIC_LENGTH( operationLength, suffixLength, thingNameLength ) \ - SHADOW_TOPIC_LEN( operationLength, suffixLength, thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) + SHADOW_TOPIC_LEN( operationLength, \ + suffixLength, \ + thingNameLength, \ + SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/update". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/update". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_UPDATE in new designs. * * See @ref #SHADOW_TOPIC_LEN_UPDATE for documentation of common behavior. @@ -823,7 +999,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_UPDATE( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/update/accepted". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/update/accepted". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_UPDATE_ACC in new designs. * * See @ref #SHADOW_TOPIC_LEN_UPDATE_ACC for documentation of common behavior. @@ -832,7 +1009,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_UPDATE_ACC( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/update/rejected". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/update/rejected". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_UPDATE_REJ in new designs. * * See @ref #SHADOW_TOPIC_LEN_UPDATE_REJ for documentation of common behavior. @@ -841,7 +1019,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_UPDATE_REJ( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/update/documents". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/update/documents". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_UPDATE_DOCS in new designs. * * See @ref #SHADOW_TOPIC_LEN_UPDATE_DOCS for documentation of common behavior. @@ -850,7 +1029,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_UPDATE_DOCS( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/update/delta". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/update/delta". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_UPDATE_DELTA in new designs. * * See @ref #SHADOW_TOPIC_LEN_UPDATE_DELTA for documentation of common behavior. @@ -859,7 +1039,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_UPDATE_DELTA( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/get". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/get". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_GET in new designs. * * See @ref #SHADOW_TOPIC_LEN_GET for documentation of common behavior. @@ -868,7 +1049,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_GET( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/get/accepted". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/get/accepted". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_GET_ACC in new designs. * * See @ref #SHADOW_TOPIC_LEN_GET_ACC for documentation of common behavior. @@ -877,7 +1059,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_GET_ACC( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/get/rejected". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/get/rejected". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_GET_REJ in new designs. * * See @ref #SHADOW_TOPIC_LEN_GET_REJ for documentation of common behavior. @@ -886,7 +1069,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_GET_REJ( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/delete". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/delete". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_DELETE in new designs. * * See @ref #SHADOW_TOPIC_LEN_DELETE for documentation of common behavior. @@ -895,7 +1079,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_DELETE( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/delete/accepted". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/delete/accepted". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_DELETE_ACC in new designs. * * See @ref #SHADOW_TOPIC_LEN_DELETE_ACC for documentation of common behavior. @@ -904,7 +1089,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_DELETE_ACC( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Compute the length of unnamed "Classic" shadow topic "$aws/things//shadow/delete/rejected". + * @brief Compute the length of unnamed "Classic" shadow topic + * "$aws/things//shadow/delete/rejected". * @deprecated Please use @ref #SHADOW_TOPIC_LEN_DELETE_REJ in new designs. * * See @ref #SHADOW_TOPIC_LEN_DELETE_REJ for documentation of common behavior. @@ -922,7 +1108,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_LEN_MAX( thingNameLength, SHADOW_NAME_CLASSIC_LENGTH ) /** - * @brief Assemble constant unnamed "Classic" shadow topic strings when Thing Name is known at compile time. + * @brief Assemble constant unnamed "Classic" shadow topic strings when Thing + * Name is known at compile time. * @deprecated Please use @ref #SHADOW_TOPIC_STR in new designs. * * See @ref #SHADOW_TOPIC_STR for documentation of common behavior. @@ -931,7 +1118,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR( thingName, SHADOW_NAME_CLASSIC, operation, suffix ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/update". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/update". * @deprecated Please use @ref #SHADOW_TOPIC_STR_UPDATE in new designs. * * See @ref #SHADOW_TOPIC_STR_UPDATE for documentation of common behavior. @@ -940,7 +1128,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_UPDATE( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/update/accepted". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/update/accepted". * @deprecated Please use @ref #SHADOW_TOPIC_STR_UPDATE_ACC in new designs. * * See @ref #SHADOW_TOPIC_STR_UPDATE_ACC for documentation of common behavior. @@ -949,7 +1138,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_UPDATE_ACC( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/update/rejected". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/update/rejected". * @deprecated Please use @ref #SHADOW_TOPIC_STR_UPDATE_REJ in new designs. * * See @ref #SHADOW_TOPIC_STR_UPDATE_REJ for documentation of common behavior. @@ -958,7 +1148,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_UPDATE_REJ( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/update/documents". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/update/documents". * @deprecated Please use @ref #SHADOW_TOPIC_STR_UPDATE_DOCS in new designs. * * See @ref #SHADOW_TOPIC_STR_UPDATE_DOCS for documentation of common behavior. @@ -967,7 +1158,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_UPDATE_DOCS( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/update/delta". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/update/delta". * @deprecated Please use @ref #SHADOW_TOPIC_STR_UPDATE_DELTA in new designs. * * See @ref #SHADOW_TOPIC_STR_UPDATE_DELTA for documentation of common behavior. @@ -976,7 +1168,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_UPDATE_DELTA( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/get". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/get". * @deprecated Please use @ref #SHADOW_TOPIC_STR_GET in new designs. * * See @ref #SHADOW_TOPIC_STR_GET for documentation of common behavior. @@ -985,7 +1178,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_GET( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble shadow topic string "$aws/things//shadow/get/accepted". + * @brief Assemble shadow topic string + * "$aws/things//shadow/get/accepted". * @deprecated Please use @ref #SHADOW_TOPIC_STR_GET_ACC in new designs. * * See @ref #SHADOW_TOPIC_STR_GET_ACC for documentation of common behavior. @@ -994,7 +1188,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_GET_ACC( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/get/rejected". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/get/rejected". * @deprecated Please use @ref #SHADOW_TOPIC_STR_GET_REJ in new designs. * * See @ref #SHADOW_TOPIC_STR_GET_REJ for documentation of common behavior. @@ -1003,7 +1198,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_GET_REJ( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/delete". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/delete". * @deprecated Please use @ref #SHADOW_TOPIC_STR_DELETE in new designs. * * See @ref #SHADOW_TOPIC_STR_DELETE for documentation of common behavior. @@ -1012,7 +1208,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_DELETE( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/delete/accepted". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/delete/accepted". * @deprecated Please use @ref #SHADOW_TOPIC_STR_DELETE_ACC in new designs. * * See @ref #SHADOW_TOPIC_STR_DELETE_ACC for documentation of common behavior. @@ -1021,7 +1218,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_DELETE_ACC( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed "Classic" shadow topic string "$aws/things//shadow/delete/rejected". + * @brief Assemble unnamed "Classic" shadow topic string + * "$aws/things//shadow/delete/rejected". * @deprecated Please use @ref #SHADOW_TOPIC_STR_DELETE_REJ in new designs. * * See @ref #SHADOW_TOPIC_STR_DELETE_REJ for documentation of common behavior. @@ -1030,8 +1228,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, SHADOW_TOPIC_STR_DELETE_REJ( thingName, SHADOW_NAME_CLASSIC ) /** - * @brief Assemble unnamed ("Classic") shadow topic string when Thing Name is only known at run time. - * If the Thing Name is known at compile time, use + * @brief Assemble unnamed ("Classic") shadow topic string when Thing Name is + * only known at run time. If the Thing Name is known at compile time, use * @link #SHADOW_TOPIC_STRING SHADOW_TOPIC_STRING @endlink macro instead. * * @deprecated Please use @ref Shadow_AssembleTopicString in new designs. @@ -1039,17 +1237,28 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, * See @ref Shadow_AssembleTopicString for documentation of common behavior. */ /* @[declare_shadow_gettopicstring] */ -#define Shadow_GetTopicString( topicType, pThingName, thingNameLength, pTopicBuffer, bufferSize, pOutLength ) \ - Shadow_AssembleTopicString( topicType, pThingName, thingNameLength, SHADOW_NAME_CLASSIC, 0, \ - pTopicBuffer, bufferSize, pOutLength ) +#define Shadow_GetTopicString( topicType, \ + pThingName, \ + thingNameLength, \ + pTopicBuffer, \ + bufferSize, \ + pOutLength ) \ + Shadow_AssembleTopicString( topicType, \ + pThingName, \ + thingNameLength, \ + SHADOW_NAME_CLASSIC, \ + 0, \ + pTopicBuffer, \ + bufferSize, \ + pOutLength ) /* @[declare_shadow_gettopicstring] */ /** - * @brief Given the topic string of an incoming message, determine whether it is related to - * an unnamed ("Classic") device shadow; if it is, return information about the type - * of device shadow message, and a pointers to the Thing Name inside of - * the topic string. See #ShadowMessageType_t for the list of message types. - * Those types correspond to Device Shadow Topics. + * @brief Given the topic string of an incoming message, determine whether it is + * related to an unnamed ("Classic") device shadow; if it is, return information + * about the type of device shadow message, and a pointers to the Thing Name + * inside of the topic string. See #ShadowMessageType_t for the list of message + * types. Those types correspond to Device Shadow Topics. * * @deprecated Please use @ref Shadow_MatchTopicString in new designs. * @@ -1065,7 +1274,7 @@ ShadowStatus_t Shadow_MatchTopic( const char * pTopic, /* *INDENT-OFF* */ #ifdef __cplusplus - } +} #endif /* *INDENT-ON* */ diff --git a/source/include/shadow_config_defaults.h b/source/include/shadow_config_defaults.h index bbe02a93..94f107f7 100644 --- a/source/include/shadow_config_defaults.h +++ b/source/include/shadow_config_defaults.h @@ -4,22 +4,23 @@ * * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ /** @@ -30,8 +31,8 @@ * @note This file SHOULD NOT be modified. If custom values are needed for * any configuration macro, a shadow_config.h file should be provided to * the Shadow library to override the default values defined in this file. - * To use the custom config file, the SHADOW_DO_NOT_USE_CUSTOM_CONFIG preprocessor - * macro SHOULD NOT be set. + * To use the custom config file, the SHADOW_DO_NOT_USE_CUSTOM_CONFIG + * preprocessor macro SHOULD NOT be set. */ #ifndef SHADOW_CONFIG_DEFAULTS_H_ @@ -41,14 +42,14 @@ * documentation only. */ /** - * @brief Define this macro to build the Shadow library without the custom config - * file shadow_config.h. + * @brief Define this macro to build the Shadow library without the custom + * config file shadow_config.h. * * Without the custom config, the Shadow library builds with * default values of config macros defined in shadow_config_defaults.h file. * - * If a custom config is provided, then SHADOW_DO_NOT_USE_CUSTOM_CONFIG should not - * be defined. + * If a custom config is provided, then SHADOW_DO_NOT_USE_CUSTOM_CONFIG should + * not be defined. */ #ifdef DOXYGEN #define SHADOW_DO_NOT_USE_CUSTOM_CONFIG @@ -58,17 +59,19 @@ * @brief Macro that is called in the Shadow library for logging "Error" level * messages. * - * To enable error level logging in the Shadow library, this macro should be mapped to the - * application-specific logging implementation that supports error logging. + * To enable error level logging in the Shadow library, this macro should be + * mapped to the application-specific logging implementation that supports error + * logging. * - * @note This logging macro is called in the Shadow library with parameters wrapped in - * double parentheses to be ISO C89/C90 standard compliant. For a reference - * POSIX implementation of the logging macros, refer to shadow_config.h files, and the - * logging-stack in demos folder of the - * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C). + * @note This logging macro is called in the Shadow library with parameters + * wrapped in double parentheses to be ISO C89/C90 standard compliant. For a + * reference POSIX implementation of the logging macros, refer to + * shadow_config.h files, and the logging-stack in demos folder of the [AWS IoT + * Embedded C SDK + * repository](https://github.com/aws/aws-iot-device-sdk-embedded-C). * - * Default value: Error logging is turned off, and no code is generated for calls - * to the macro in the Shadow library on compilation. + * Default value: Error logging is turned off, and no code is generated + * for calls to the macro in the Shadow library on compilation. */ #ifndef LogError #define LogError( message ) @@ -78,17 +81,19 @@ * @brief Macro that is called in the Shadow library for logging "Warning" level * messages. * - * To enable warning level logging in the Shadow library, this macro should be mapped to the - * application-specific logging implementation that supports warning logging. + * To enable warning level logging in the Shadow library, this macro should be + * mapped to the application-specific logging implementation that supports + * warning logging. * - * @note This logging macro is called in the Shadow library with parameters wrapped in - * double parentheses to be ISO C89/C90 standard compliant. For a reference - * POSIX implementation of the logging macros, refer to shadow_config.h files, and the - * logging-stack in demos folder of the - * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C). + * @note This logging macro is called in the Shadow library with parameters + * wrapped in double parentheses to be ISO C89/C90 standard compliant. For a + * reference POSIX implementation of the logging macros, refer to + * shadow_config.h files, and the logging-stack in demos folder of the [AWS IoT + * Embedded C SDK + * repository](https://github.com/aws/aws-iot-device-sdk-embedded-C). * - * Default value: Warning logs are turned off, and no code is generated for calls - * to the macro in the Shadow library on compilation. + * Default value: Warning logs are turned off, and no code is generated + * for calls to the macro in the Shadow library on compilation. */ #ifndef LogWarn #define LogWarn( message ) @@ -98,17 +103,19 @@ * @brief Macro that is called in the Shadow library for logging "Info" level * messages. * - * To enable info level logging in the Shadow library, this macro should be mapped to the - * application-specific logging implementation that supports info logging. + * To enable info level logging in the Shadow library, this macro should be + * mapped to the application-specific logging implementation that supports info + * logging. * - * @note This logging macro is called in the Shadow library with parameters wrapped in - * double parentheses to be ISO C89/C90 standard compliant. For a reference - * POSIX implementation of the logging macros, refer to shadow_config.h files, and the - * logging-stack in demos folder of the - * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C). + * @note This logging macro is called in the Shadow library with parameters + * wrapped in double parentheses to be ISO C89/C90 standard compliant. For a + * reference POSIX implementation of the logging macros, refer to + * shadow_config.h files, and the logging-stack in demos folder of the [AWS IoT + * Embedded C SDK + * repository](https://github.com/aws/aws-iot-device-sdk-embedded-C). * - * Default value: Info logging is turned off, and no code is generated for calls - * to the macro in the Shadow library on compilation. + * Default value: Info logging is turned off, and no code is generated + * for calls to the macro in the Shadow library on compilation. */ #ifndef LogInfo #define LogInfo( message ) @@ -118,17 +125,19 @@ * @brief Macro that is called in the Shadow library for logging "Debug" level * messages. * - * To enable debug level logging from Shadow library, this macro should be mapped to the - * application-specific logging implementation that supports debug logging. + * To enable debug level logging from Shadow library, this macro should be + * mapped to the application-specific logging implementation that supports debug + * logging. * - * @note This logging macro is called in the Shadow library with parameters wrapped in - * double parentheses to be ISO C89/C90 standard compliant. For a reference - * POSIX implementation of the logging macros, refer to shadow_config.h files, and the - * logging-stack in demos folder of the - * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C). + * @note This logging macro is called in the Shadow library with parameters + * wrapped in double parentheses to be ISO C89/C90 standard compliant. For a + * reference POSIX implementation of the logging macros, refer to + * shadow_config.h files, and the logging-stack in demos folder of the [AWS IoT + * Embedded C SDK + * repository](https://github.com/aws/aws-iot-device-sdk-embedded-C). * - * Default value: Debug logging is turned off, and no code is generated for calls - * to the macro in the Shadow library on compilation. + * Default value: Debug logging is turned off, and no code is generated + * for calls to the macro in the Shadow library on compilation. */ #ifndef LogDebug #define LogDebug( message ) diff --git a/source/shadow.c b/source/shadow.c index 71a4b01d..787ab2b3 100644 --- a/source/shadow.c +++ b/source/shadow.c @@ -4,22 +4,23 @@ * * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ /** @@ -33,136 +34,150 @@ /* Shadow includes. */ #include "shadow.h" - /** * @brief Maximum shadow name length. - * Refer to https://docs.aws.amazon.com/general/latest/gr/iot-core.html#device-shadow-limits + * Refer to + * https://docs.aws.amazon.com/general/latest/gr/iot-core.html#device-shadow-limits * for more details about the Device Shadow limits. */ -#define SHADOW_NAME_MAX_LENGTH ( 64U ) +#define SHADOW_NAME_MAX_LENGTH ( 64U ) /** * @brief Maximum thing name length. - * Refer to https://docs.aws.amazon.com/general/latest/gr/iot-core.html#device-shadow-limits + * Refer to + * https://docs.aws.amazon.com/general/latest/gr/iot-core.html#device-shadow-limits * for more details about the Device Shadow limits. */ -#define SHADOW_THINGNAME_MAX_LENGTH ( 128U ) +#define SHADOW_THINGNAME_MAX_LENGTH ( 128U ) /** * @brief The string representing "/shadow/update/accepted". */ -#define SHADOW_OP_UPDATE_ACCEPTED SHADOW_OP_UPDATE SHADOW_SUFFIX_ACCEPTED +#define SHADOW_OP_UPDATE_ACCEPTED SHADOW_OP_UPDATE SHADOW_SUFFIX_ACCEPTED /** * @brief The string representing "/shadow/update/rejected". */ -#define SHADOW_OP_UPDATE_REJECTED SHADOW_OP_UPDATE SHADOW_SUFFIX_REJECTED +#define SHADOW_OP_UPDATE_REJECTED SHADOW_OP_UPDATE SHADOW_SUFFIX_REJECTED /** * @brief The string representing "/shadow/update/delta". */ -#define SHADOW_OP_UPDATE_DELTA SHADOW_OP_UPDATE SHADOW_SUFFIX_DELTA +#define SHADOW_OP_UPDATE_DELTA SHADOW_OP_UPDATE SHADOW_SUFFIX_DELTA /** * @brief The string representing "/shadow/update/document". */ -#define SHADOW_OP_UPDATE_DOCUMENTS SHADOW_OP_UPDATE SHADOW_SUFFIX_DOCUMENTS +#define SHADOW_OP_UPDATE_DOCUMENTS SHADOW_OP_UPDATE SHADOW_SUFFIX_DOCUMENTS /** * @brief The string representing "/shadow/delete/accepted". */ -#define SHADOW_OP_DELETE_ACCEPTED SHADOW_OP_DELETE SHADOW_SUFFIX_ACCEPTED +#define SHADOW_OP_DELETE_ACCEPTED SHADOW_OP_DELETE SHADOW_SUFFIX_ACCEPTED /** * @brief The string representing "/shadow/delete/accepted". */ -#define SHADOW_OP_DELETE_REJECTED SHADOW_OP_DELETE SHADOW_SUFFIX_REJECTED +#define SHADOW_OP_DELETE_REJECTED SHADOW_OP_DELETE SHADOW_SUFFIX_REJECTED /** * @brief The string representing "/shadow/get/accepted". */ -#define SHADOW_OP_GET_ACCEPTED SHADOW_OP_GET SHADOW_SUFFIX_ACCEPTED +#define SHADOW_OP_GET_ACCEPTED SHADOW_OP_GET SHADOW_SUFFIX_ACCEPTED /** * @brief The string representing "/shadow/get/accepted". */ -#define SHADOW_OP_GET_REJECTED SHADOW_OP_GET SHADOW_SUFFIX_REJECTED +#define SHADOW_OP_GET_REJECTED SHADOW_OP_GET SHADOW_SUFFIX_REJECTED /** * @brief The length of "/shadow/update/accepted". */ -#define SHADOW_OP_UPDATE_ACCEPTED_LENGTH ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_ACCEPTED_LENGTH ) +#define SHADOW_OP_UPDATE_ACCEPTED_LENGTH \ + ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_ACCEPTED_LENGTH ) /** * @brief The length of "/shadow/update/rejected". */ -#define SHADOW_OP_UPDATE_REJECTED_LENGTH ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_REJECTED_LENGTH ) +#define SHADOW_OP_UPDATE_REJECTED_LENGTH \ + ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_REJECTED_LENGTH ) /** * @brief The length of "/shadow/update/document". */ -#define SHADOW_OP_UPDATE_DOCUMENTS_LENGTH ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_DOCUMENTS_LENGTH ) +#define SHADOW_OP_UPDATE_DOCUMENTS_LENGTH \ + ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_DOCUMENTS_LENGTH ) /** * @brief The length of "/shadow/update/rejected". */ -#define SHADOW_OP_UPDATE_DELTA_LENGTH ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_DELTA_LENGTH ) +#define SHADOW_OP_UPDATE_DELTA_LENGTH \ + ( SHADOW_OP_UPDATE_LENGTH + SHADOW_SUFFIX_DELTA_LENGTH ) /** * @brief The length of "/shadow/get/accepted". */ -#define SHADOW_OP_GET_ACCEPTED_LENGTH ( SHADOW_OP_GET_LENGTH + SHADOW_SUFFIX_ACCEPTED_LENGTH ) +#define SHADOW_OP_GET_ACCEPTED_LENGTH \ + ( SHADOW_OP_GET_LENGTH + SHADOW_SUFFIX_ACCEPTED_LENGTH ) /** * @brief The length of "/shadow/get/rejected". */ -#define SHADOW_OP_GET_REJECTED_LENGTH ( SHADOW_OP_GET_LENGTH + SHADOW_SUFFIX_REJECTED_LENGTH ) +#define SHADOW_OP_GET_REJECTED_LENGTH \ + ( SHADOW_OP_GET_LENGTH + SHADOW_SUFFIX_REJECTED_LENGTH ) /** * @brief The length of "/shadow/get/accepted". */ -#define SHADOW_OP_DELETE_ACCEPTED_LENGTH ( SHADOW_OP_DELETE_LENGTH + SHADOW_SUFFIX_ACCEPTED_LENGTH ) +#define SHADOW_OP_DELETE_ACCEPTED_LENGTH \ + ( SHADOW_OP_DELETE_LENGTH + SHADOW_SUFFIX_ACCEPTED_LENGTH ) /** * @brief The length of "/shadow/delete/rejected". */ -#define SHADOW_OP_DELETE_REJECTED_LENGTH ( SHADOW_OP_DELETE_LENGTH + SHADOW_SUFFIX_REJECTED_LENGTH ) +#define SHADOW_OP_DELETE_REJECTED_LENGTH \ + ( SHADOW_OP_DELETE_LENGTH + SHADOW_SUFFIX_REJECTED_LENGTH ) /** * @brief Check if Shadow_MatchTopicString has valid parameters. * * @param[in] pTopic Pointer to the topic string. * @param[in] topicLength Length of pTopic. - * @param[in] pMessageType Pointer to caller-supplied memory for returning the type of the shadow message. + * @param[in] pMessageType Pointer to caller-supplied memory for returning the + * type of the shadow message. * * @return Return SHADOW_SUCCESS if the parameters are valid; * return SHADOW_BAD_PARAMETER if not. */ -static ShadowStatus_t validateMatchTopicParameters( const char * pTopic, - uint16_t topicLength, - const ShadowMessageType_t * pMessageType ); +static ShadowStatus_t validateMatchTopicParameters( + const char * pTopic, + uint16_t topicLength, + const ShadowMessageType_t * pMessageType ); /** * @brief Check if Shadow_AssembleTopicString has valid parameters. * * @param[in] topicType Shadow topic type. * @param[in] pThingName Thing Name string. - * @param[in] thingNameLength Length of Thing Name string pointed to by pThingName. + * @param[in] thingNameLength Length of Thing Name string pointed to by + * pThingName. * @param[in] pShadowName Shadow Name string. - * @param[in] shadowNameLength Length of Shadow Name string pointed to by pShadowName. + * @param[in] shadowNameLength Length of Shadow Name string pointed to by + * pShadowName. * @param[in] pTopicBuffer Pointer to the topic buffer. * @param[in] pOutLength Pointer to the length of the topic created. * * @return Return SHADOW_SUCCESS if the parameters are valid; * return SHADOW_BAD_PARAMETER if not. */ -static ShadowStatus_t validateAssembleTopicParameters( ShadowTopicStringType_t topicType, - const char * pThingName, - uint8_t thingNameLength, - const char * pShadowName, - uint8_t shadowNameLength, - const char * pTopicBuffer, - const uint16_t * pOutLength ); +static ShadowStatus_t validateAssembleTopicParameters( + ShadowTopicStringType_t topicType, + const char * pThingName, + uint8_t thingNameLength, + const char * pShadowName, + uint8_t shadowNameLength, + const char * pTopicBuffer, + const uint16_t * pOutLength ); /** * @brief Determine if the string contains the substring. @@ -185,8 +200,10 @@ static ShadowStatus_t containsSubString( const char * pString, * * @param[in] pString Pointer to the starting of a name. * @param[in] stringLength Length of pString. - * @param[in] maxAllowedLength Maximum allowed length of the Thing or Shadow name. - * @param[out] pNameLength Pointer to caller-supplied memory for returning the length of the Thing or Shadow Name. + * @param[in] maxAllowedLength Maximum allowed length of the Thing or Shadow + * name. + * @param[out] pNameLength Pointer to caller-supplied memory for returning the + * length of the Thing or Shadow Name. * * @return Return SHADOW_SUCCESS if it is valid; * return SHADOW_FAIL if it is not. @@ -201,22 +218,26 @@ static ShadowStatus_t validateName( const char * pString, * * @param[in] pString Pointer to the string. * @param[in] stringLength Length of pString. - * @param[out] pMessageType Pointer to caller-supplied memory for returning the type of the shadow message. + * @param[out] pMessageType Pointer to caller-supplied memory for returning the + * type of the shadow message. * * @return Return SHADOW_SUCCESS if successfully extracted; * return SHADOW_MESSAGE_TYPE_PARSE_FAILED if failed. */ -static ShadowStatus_t extractShadowMessageType( const char * pString, - uint16_t stringLength, - ShadowMessageType_t * pMessageType ); +static ShadowStatus_t extractShadowMessageType( + const char * pString, + uint16_t stringLength, + ShadowMessageType_t * pMessageType ); /** * @brief Extract the Thing name from a topic string. * * @param[in] pTopic Pointer to the topic string. * @param[in] topicLength Length of pTopic. - * @param[in,out] pConsumedTopicLength Pointer to caller-supplied memory for returning the consumed topic length. - * @param[out] pThingNameLength Pointer to caller-supplied memory for returning the Thing name length. + * @param[in,out] pConsumedTopicLength Pointer to caller-supplied memory for + * returning the consumed topic length. + * @param[out] pThingNameLength Pointer to caller-supplied memory for returning + * the Thing name length. * * @return Return SHADOW_SUCCESS if successfully extracted; * return SHADOW_THINGNAME_PARSE_FAILED if Thing name parsing fails. @@ -227,12 +248,15 @@ static ShadowStatus_t extractThingName( const char * pTopic, uint8_t * pThingNameLength ); /** - * @brief Extract the classic shadow root OR the named shadow root and shadow name from a topic string. + * @brief Extract the classic shadow root OR the named shadow root and shadow + * name from a topic string. * * @param[in] pTopic Pointer to the topic string. * @param[in] topicLength Length of pTopic. - * @param[in,out] pConsumedTopicLength Pointer to caller-supplied memory for returning the consumed topic length. - * @param[out] pShadowNameLength Pointer to caller-supplied memory for returning the shadow name length. + * @param[in,out] pConsumedTopicLength Pointer to caller-supplied memory for + * returning the consumed topic length. + * @param[out] pShadowNameLength Pointer to caller-supplied memory for returning + * the shadow name length. * * @return Return SHADOW_SUCCESS if successfully extracted; * return SHADOW_ROOT_PARSE_FAILED shadow root parsing fails. @@ -250,7 +274,8 @@ static ShadowStatus_t extractShadowRootAndName( const char * pTopic, * * @return The shadow operation string for the given shadow type. */ -static const char * getShadowOperationString( ShadowTopicStringType_t topicType ); +static const char * getShadowOperationString( + ShadowTopicStringType_t topicType ); /** * @brief Get the shadow operation string length for a given shadow topic type. @@ -269,7 +294,8 @@ static uint16_t getShadowOperationLength( ShadowTopicStringType_t topicType ); * @param[in] thingNameLength The length of the Thing name. * @param[in] pShadowName Pointer to the Shadow name. * @param[in] shadowNameLength The length of the Shadow name. - * @param[out] pTopicBuffer Pointer to caller-supplied memory for returning the constructed shadow topic string. + * @param[out] pTopicBuffer Pointer to caller-supplied memory for returning the + * constructed shadow topic string. */ static void createShadowTopicString( ShadowTopicStringType_t topicType, const char * pThingName, @@ -280,18 +306,19 @@ static void createShadowTopicString( ShadowTopicStringType_t topicType, /*-----------------------------------------------------------*/ -static ShadowStatus_t validateMatchTopicParameters( const char * pTopic, - uint16_t topicLength, - const ShadowMessageType_t * pMessageType ) +static ShadowStatus_t validateMatchTopicParameters( + const char * pTopic, + uint16_t topicLength, + const ShadowMessageType_t * pMessageType ) { ShadowStatus_t shadowStatus = SHADOW_SUCCESS; - if( ( pTopic == NULL ) || - ( topicLength == 0U ) || + if( ( pTopic == NULL ) || ( topicLength == 0U ) || ( pMessageType == NULL ) ) { shadowStatus = SHADOW_BAD_PARAMETER; - LogError( ( "Invalid input parameters pTopic: %p, topicLength: %u, pMessageType: %p.", + LogError( ( "Invalid input parameters pTopic: %p, topicLength: %u, " + "pMessageType: %p.", ( const void * ) pTopic, ( unsigned int ) topicLength, ( const void * ) pMessageType ) ); @@ -302,42 +329,44 @@ static ShadowStatus_t validateMatchTopicParameters( const char * pTopic, /*-----------------------------------------------------------*/ -static ShadowStatus_t validateAssembleTopicParameters( ShadowTopicStringType_t topicType, - const char * pThingName, - uint8_t thingNameLength, - const char * pShadowName, - uint8_t shadowNameLength, - const char * pTopicBuffer, - const uint16_t * pOutLength ) +static ShadowStatus_t validateAssembleTopicParameters( + ShadowTopicStringType_t topicType, + const char * pThingName, + uint8_t thingNameLength, + const char * pShadowName, + uint8_t shadowNameLength, + const char * pTopicBuffer, + const uint16_t * pOutLength ) { ShadowStatus_t shadowStatus = SHADOW_BAD_PARAMETER; - if( ( pTopicBuffer == NULL ) || - ( pThingName == NULL ) || + if( ( pTopicBuffer == NULL ) || ( pThingName == NULL ) || ( thingNameLength == 0U ) || ( ( pShadowName == NULL ) && ( shadowNameLength > 0U ) ) || - ( topicType >= ShadowTopicStringTypeMaxNum ) || - ( pOutLength == NULL ) ) + ( topicType >= ShadowTopicStringTypeMaxNum ) || ( pOutLength == NULL ) ) { - LogError( ( "Invalid input parameters pTopicBuffer: %p, pThingName: %p, thingNameLength: %u,\ + LogError( + ( "Invalid input parameters pTopicBuffer: %p, pThingName: %p, thingNameLength: %u,\ pShadowName: %p, shadowNameLength: %u, topicType: %d, pOutLength: %p.", - ( const void * ) pTopicBuffer, - ( const void * ) pThingName, - ( unsigned int ) thingNameLength, - ( const void * ) pShadowName, - ( unsigned int ) shadowNameLength, - ( int ) topicType, - ( const void * ) pOutLength ) ); + ( const void * ) pTopicBuffer, + ( const void * ) pThingName, + ( unsigned int ) thingNameLength, + ( const void * ) pShadowName, + ( unsigned int ) shadowNameLength, + ( int ) topicType, + ( const void * ) pOutLength ) ); } else if( thingNameLength > SHADOW_THINGNAME_MAX_LENGTH ) { - LogError( ( "Invalid thingNamelength. Thing name length of %u exceeds maximum allowed length %u.", + LogError( ( "Invalid thingNamelength. Thing name length of %u exceeds " + "maximum allowed length %u.", ( unsigned int ) thingNameLength, ( unsigned int ) SHADOW_THINGNAME_MAX_LENGTH ) ); } else if( shadowNameLength > SHADOW_NAME_MAX_LENGTH ) { - LogError( ( "Invalid shadowNameLength. Shadow name length of %u exceeds maximum allowed length %u.", + LogError( ( "Invalid shadowNameLength. Shadow name length of %u " + "exceeds maximum allowed length %u.", ( unsigned int ) shadowNameLength, ( unsigned int ) SHADOW_NAME_MAX_LENGTH ) ); } @@ -364,7 +393,8 @@ static ShadowStatus_t containsSubString( const char * pString, if( stringLength >= subStringLength ) { /* We are only checking up to subStringLength characters in the original - * string. The string may be longer and contain additional characters. */ + * string. The string may be longer and contain additional characters. + */ if( strncmp( pString, pSubString, ( size_t ) subStringLength ) == 0 ) { returnStatus = SHADOW_SUCCESS; @@ -399,13 +429,19 @@ static ShadowStatus_t validateName( const char * pString, { if( index == 0U ) { - LogDebug( ( "Not a Shadow topic. Unable to find a %s name in the topic.", - ( maxAllowedLength == SHADOW_THINGNAME_MAX_LENGTH ) ? "Thing" : "Shadow" ) ); + LogDebug( + ( "Not a Shadow topic. Unable to find a %s name in the topic.", + ( maxAllowedLength == SHADOW_THINGNAME_MAX_LENGTH ) + ? "Thing" + : "Shadow" ) ); } else if( index > maxAllowedLength ) { - LogDebug( ( "Not a Shadow topic. Extracted %s name length of %u exceeds maximum allowed length %u.", - ( maxAllowedLength == SHADOW_THINGNAME_MAX_LENGTH ) ? "Thing" : "Shadow", + LogDebug( ( "Not a Shadow topic. Extracted %s name length of %u " + "exceeds maximum allowed length %u.", + ( maxAllowedLength == SHADOW_THINGNAME_MAX_LENGTH ) + ? "Thing" + : "Shadow", ( unsigned int ) index, ( unsigned int ) maxAllowedLength ) ); } @@ -413,15 +449,19 @@ static ShadowStatus_t validateName( const char * pString, { /* Only accept names of greater than zero length. * The variable `index` will not exceed the 8 bit integer width here - * since it will be lesser than the 8 bit integer `maxAllowedLength`. */ + * since it will be lesser than the 8 bit integer + * `maxAllowedLength`. */ *pNameLength = ( uint8_t ) index; returnStatus = SHADOW_SUCCESS; } } else { - LogDebug( ( "Not a Shadow topic. Unable to find a %s name in the topic.", - ( maxAllowedLength == SHADOW_THINGNAME_MAX_LENGTH ) ? "Thing" : "Shadow" ) ); + LogDebug( + ( "Not a Shadow topic. Unable to find a %s name in the topic.", + ( maxAllowedLength == SHADOW_THINGNAME_MAX_LENGTH ) + ? "Thing" + : "Shadow" ) ); } return returnStatus; @@ -435,10 +475,11 @@ static ShadowStatus_t extractThingName( const char * pTopic, uint8_t * pThingNameLength ) { /* Extract thing name. */ - ShadowStatus_t shadowStatus = validateName( &( pTopic[ *pConsumedTopicLength ] ), - topicLength - *pConsumedTopicLength, - SHADOW_THINGNAME_MAX_LENGTH, - pThingNameLength ); + ShadowStatus_t + shadowStatus = validateName( &( pTopic[ *pConsumedTopicLength ] ), + topicLength - *pConsumedTopicLength, + SHADOW_THINGNAME_MAX_LENGTH, + pThingNameLength ); if( shadowStatus != SHADOW_SUCCESS ) { @@ -460,10 +501,11 @@ static ShadowStatus_t extractShadowRootAndName( const char * pTopic, uint8_t * pShadowNameLength ) { /* Look for the named shadow root */ - ShadowStatus_t shadowStatus = containsSubString( &( pTopic[ *pConsumedTopicLength ] ), - topicLength - *pConsumedTopicLength, - SHADOW_NAMED_ROOT, - SHADOW_NAMED_ROOT_LENGTH ); + ShadowStatus_t + shadowStatus = containsSubString( &( pTopic[ *pConsumedTopicLength ] ), + topicLength - *pConsumedTopicLength, + SHADOW_NAMED_ROOT, + SHADOW_NAMED_ROOT_LENGTH ); if( shadowStatus == SHADOW_SUCCESS ) { @@ -500,7 +542,10 @@ static ShadowStatus_t extractShadowRootAndName( const char * pTopic, else { shadowStatus = SHADOW_ROOT_PARSE_FAILED; - LogDebug( ( "Not a Shadow topic. Failed to parse shadow root in pTopic %.*s", topicLength, pTopic ) ); + LogDebug( ( "Not a Shadow topic. Failed to parse shadow root in " + "pTopic %.*s", + topicLength, + pTopic ) ); } } @@ -509,53 +554,41 @@ static ShadowStatus_t extractShadowRootAndName( const char * pTopic, /*-----------------------------------------------------------*/ -static ShadowStatus_t extractShadowMessageType( const char * pString, - uint16_t stringLength, - ShadowMessageType_t * pMessageType ) +static ShadowStatus_t extractShadowMessageType( + const char * pString, + uint16_t stringLength, + ShadowMessageType_t * pMessageType ) { uint32_t index = 0U; ShadowStatus_t returnStatus = SHADOW_FAIL; /* Lookup table for Shadow message string. */ - static const char * const pMessageStrings[ ShadowMessageTypeMaxNum ] = - { - SHADOW_OP_GET_ACCEPTED, - SHADOW_OP_GET_REJECTED, - SHADOW_OP_DELETE_ACCEPTED, - SHADOW_OP_DELETE_REJECTED, - SHADOW_OP_UPDATE_ACCEPTED, - SHADOW_OP_UPDATE_REJECTED, - SHADOW_OP_UPDATE_DOCUMENTS, - SHADOW_OP_UPDATE_DELTA + static const char * const pMessageStrings[ ShadowMessageTypeMaxNum ] = { + SHADOW_OP_GET_ACCEPTED, SHADOW_OP_GET_REJECTED, + SHADOW_OP_DELETE_ACCEPTED, SHADOW_OP_DELETE_REJECTED, + SHADOW_OP_UPDATE_ACCEPTED, SHADOW_OP_UPDATE_REJECTED, + SHADOW_OP_UPDATE_DOCUMENTS, SHADOW_OP_UPDATE_DELTA }; /* Lookup table for Shadow message string length. */ - static const uint16_t pMessageStringsLength[ ShadowMessageTypeMaxNum ] = - { - SHADOW_OP_GET_ACCEPTED_LENGTH, - SHADOW_OP_GET_REJECTED_LENGTH, - SHADOW_OP_DELETE_ACCEPTED_LENGTH, - SHADOW_OP_DELETE_REJECTED_LENGTH, - SHADOW_OP_UPDATE_ACCEPTED_LENGTH, - SHADOW_OP_UPDATE_REJECTED_LENGTH, - SHADOW_OP_UPDATE_DOCUMENTS_LENGTH, - SHADOW_OP_UPDATE_DELTA_LENGTH + static const uint16_t pMessageStringsLength[ ShadowMessageTypeMaxNum ] = { + SHADOW_OP_GET_ACCEPTED_LENGTH, SHADOW_OP_GET_REJECTED_LENGTH, + SHADOW_OP_DELETE_ACCEPTED_LENGTH, SHADOW_OP_DELETE_REJECTED_LENGTH, + SHADOW_OP_UPDATE_ACCEPTED_LENGTH, SHADOW_OP_UPDATE_REJECTED_LENGTH, + SHADOW_OP_UPDATE_DOCUMENTS_LENGTH, SHADOW_OP_UPDATE_DELTA_LENGTH }; /* Lookup table for Shadow message types. */ - static const ShadowMessageType_t pMessageTypes[ ShadowMessageTypeMaxNum ] = - { - ShadowMessageTypeGetAccepted, - ShadowMessageTypeGetRejected, - ShadowMessageTypeDeleteAccepted, - ShadowMessageTypeDeleteRejected, - ShadowMessageTypeUpdateAccepted, - ShadowMessageTypeUpdateRejected, - ShadowMessageTypeUpdateDocuments, - ShadowMessageTypeUpdateDelta + static const ShadowMessageType_t pMessageTypes[ ShadowMessageTypeMaxNum ] = { + ShadowMessageTypeGetAccepted, ShadowMessageTypeGetRejected, + ShadowMessageTypeDeleteAccepted, ShadowMessageTypeDeleteRejected, + ShadowMessageTypeUpdateAccepted, ShadowMessageTypeUpdateRejected, + ShadowMessageTypeUpdateDocuments, ShadowMessageTypeUpdateDelta }; - for( ; index < ( uint32_t ) ( sizeof( pMessageStrings ) / sizeof( pMessageStrings[ 0 ] ) ); index++ ) + for( ; index < ( uint32_t ) ( sizeof( pMessageStrings ) / + sizeof( pMessageStrings[ 0 ] ) ); + index++ ) { returnStatus = containsSubString( pString, stringLength, @@ -580,7 +613,10 @@ static ShadowStatus_t extractShadowMessageType( const char * pString, if( returnStatus != SHADOW_SUCCESS ) { - LogDebug( ( "Not a Shadow topic. Failed to match shadow message type in pString %.*s", stringLength, pString ) ); + LogDebug( ( "Not a Shadow topic. Failed to match shadow message type " + "in pString %.*s", + stringLength, + pString ) ); } return returnStatus; @@ -635,7 +671,8 @@ static const char * getShadowOperationString( ShadowTopicStringType_t topicType break; case ShadowTopicStringTypeUpdateDelta: - /* topicType >= ShadowTopicStringTypeMaxNum check is covered at entry of Shadow_AssembleTopicString. */ + /* topicType >= ShadowTopicStringTypeMaxNum check is covered at entry of + * Shadow_AssembleTopicString. */ default: shadowOperationString = SHADOW_OP_UPDATE_DELTA; break; @@ -693,7 +730,8 @@ static uint16_t getShadowOperationLength( ShadowTopicStringType_t topicType ) break; case ShadowTopicStringTypeUpdateDelta: - /* topicType >= ShadowTopicStringTypeMaxNum check is covered at entry of Shadow_AssembleTopicString. */ + /* topicType >= ShadowTopicStringTypeMaxNum check is covered at entry of + * Shadow_AssembleTopicString. */ default: shadowOperationLength = SHADOW_OP_UPDATE_DELTA_LENGTH; break; @@ -776,7 +814,9 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, uint8_t thingNameLength = 0; uint8_t shadowNameLength = 0; - shadowStatus = validateMatchTopicParameters( pTopic, topicLength, pMessageType ); + shadowStatus = validateMatchTopicParameters( pTopic, + topicLength, + pMessageType ); /* A shadow topic string takes one of the two forms. * Classic shadow: @@ -789,7 +829,8 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, * We need to match the following things: * 1. Prefix ($aws/things). * 2. Thing Name. - * 3. Classic shadow root (/shadow) OR Named shadow root (/shadow/name) and shadow name + * 3. Classic shadow root (/shadow) OR Named shadow root (/shadow/name) and + * shadow name * 4. Shadow operation and suffix. */ if( shadowStatus == SHADOW_SUCCESS ) @@ -806,7 +847,10 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, } else { - LogDebug( ( "Not a Shadow topic. Failed to parse shadow topic prefix in pTopic %.*s", topicLength, pTopic ) ); + LogDebug( ( "Not a Shadow topic. Failed to parse shadow topic " + "prefix in pTopic %.*s", + topicLength, + pTopic ) ); } } @@ -830,14 +874,18 @@ ShadowStatus_t Shadow_MatchTopicString( const char * pTopic, if( shadowStatus == SHADOW_SUCCESS ) { /* Extract shadow message type. */ - shadowStatus = extractShadowMessageType( &( pTopic[ consumedTopicLength ] ), - topicLength - consumedTopicLength, - pMessageType ); + shadowStatus = extractShadowMessageType( + &( pTopic[ consumedTopicLength ] ), + topicLength - consumedTopicLength, + pMessageType ); if( shadowStatus != SHADOW_SUCCESS ) { shadowStatus = SHADOW_MESSAGE_TYPE_PARSE_FAILED; - LogDebug( ( "Not a Shadow topic. Shadow message type is not in pTopic %.*s, failed to parse shadow message type.", topicLength, pTopic ) ); + LogDebug( ( "Not a Shadow topic. Shadow message type is not in " + "pTopic %.*s, failed to parse shadow message type.", + topicLength, + pTopic ) ); } } @@ -883,29 +931,37 @@ ShadowStatus_t Shadow_AssembleTopicString( ShadowTopicStringType_t topicType, { uint16_t generatedTopicStringLength = 0U; - ShadowStatus_t shadowStatus = validateAssembleTopicParameters( topicType, - pThingName, - thingNameLength, - pShadowName, - shadowNameLength, - pTopicBuffer, - pOutLength ); + ShadowStatus_t + shadowStatus = validateAssembleTopicParameters( topicType, + pThingName, + thingNameLength, + pShadowName, + shadowNameLength, + pTopicBuffer, + pOutLength ); if( shadowStatus == SHADOW_SUCCESS ) { - generatedTopicStringLength = SHADOW_PREFIX_LENGTH + /* Prefix ("$aws/things/"). */ - thingNameLength + /* Thing name. */ - ( ( shadowNameLength > 0U ) ? /* Handle named or classic shadow */ - ( SHADOW_NAMED_ROOT_LENGTH + shadowNameLength ) : - SHADOW_CLASSIC_ROOT_LENGTH ) + - getShadowOperationLength( topicType ); /* Shadow operation. */ + generatedTopicStringLength = SHADOW_PREFIX_LENGTH + /* Prefix + ("$aws/things/"). + */ + thingNameLength + /* Thing name. */ + ( ( shadowNameLength > 0U ) + ? /* Handle named or classic shadow + */ + ( SHADOW_NAMED_ROOT_LENGTH + + shadowNameLength ) + : SHADOW_CLASSIC_ROOT_LENGTH ) + + getShadowOperationLength( + topicType ); /* Shadow operation. */ if( bufferSize < generatedTopicStringLength ) { shadowStatus = SHADOW_BUFFER_TOO_SMALL; - LogError( ( "Input bufferSize too small, bufferSize %u, required %u.", - ( unsigned int ) bufferSize, - ( unsigned int ) generatedTopicStringLength ) ); + LogError( + ( "Input bufferSize too small, bufferSize %u, required %u.", + ( unsigned int ) bufferSize, + ( unsigned int ) generatedTopicStringLength ) ); } } @@ -937,12 +993,13 @@ ShadowStatus_t Shadow_MatchTopic( const char * pTopic, * output parameter Thing name length, whereas Shadow_MatchTopic takes a * pointer to a 16 bit integer. The maximum possible Thing name length is * 128 bytes and hence unsigned 8 bit integer is large enough to hold the - * Thing name length. Refer to #SHADOW_THINGNAME_MAX_LENGTH for more details. - * Passing a pointer to 16 bit integer directly to Shadow_MatchTopicString - * may create data inconsistencies depending on the byte ordering in the - * device platform. Hence, a local variable of 8 bit integer width is used for - * the call to Shadow_MatchTopicString, and its value is copied to the 16 bit - * integer pointer passed to Shadow_MatchTopic. */ + * Thing name length. Refer to #SHADOW_THINGNAME_MAX_LENGTH for more + * details. Passing a pointer to 16 bit integer directly to + * Shadow_MatchTopicString may create data inconsistencies depending on the + * byte ordering in the device platform. Hence, a local variable of 8 bit + * integer width is used for the call to Shadow_MatchTopicString, and its + * value is copied to the 16 bit integer pointer passed to + * Shadow_MatchTopic. */ uint8_t thingNameLength = 0U; ShadowStatus_t shadowStatus = Shadow_MatchTopicString( pTopic, topicLength, diff --git a/test/cbmc/proofs/Shadow_AssembleTopicString/Shadow_AssembleTopicString_harness.c b/test/cbmc/proofs/Shadow_AssembleTopicString/Shadow_AssembleTopicString_harness.c index 1c0488ad..d67ed151 100644 --- a/test/cbmc/proofs/Shadow_AssembleTopicString/Shadow_AssembleTopicString_harness.c +++ b/test/cbmc/proofs/Shadow_AssembleTopicString/Shadow_AssembleTopicString_harness.c @@ -4,22 +4,23 @@ * * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ /** diff --git a/test/cbmc/proofs/Shadow_MatchTopic/Shadow_MatchTopic_harness.c b/test/cbmc/proofs/Shadow_MatchTopic/Shadow_MatchTopic_harness.c index cc7200b3..88ae2d9c 100644 --- a/test/cbmc/proofs/Shadow_MatchTopic/Shadow_MatchTopic_harness.c +++ b/test/cbmc/proofs/Shadow_MatchTopic/Shadow_MatchTopic_harness.c @@ -4,22 +4,23 @@ * * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ /** diff --git a/test/cbmc/proofs/Shadow_MatchTopicString/Shadow_MatchTopicString_harness.c b/test/cbmc/proofs/Shadow_MatchTopicString/Shadow_MatchTopicString_harness.c index 9ab4982d..cbd0695f 100644 --- a/test/cbmc/proofs/Shadow_MatchTopicString/Shadow_MatchTopicString_harness.c +++ b/test/cbmc/proofs/Shadow_MatchTopicString/Shadow_MatchTopicString_harness.c @@ -4,22 +4,23 @@ * * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ /** diff --git a/test/include/shadow_config.h b/test/include/shadow_config.h index 499d00a7..71baf831 100644 --- a/test/include/shadow_config.h +++ b/test/include/shadow_config.h @@ -4,22 +4,23 @@ * * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ /** @@ -48,13 +49,25 @@ #define LogDebug( message ) #endif #else /* ! DISABLE_LOGGING */ - #define LogError( message ) printf( "Error: " ); printf message; printf( "\n" ) + #define LogError( message ) \ + printf( "Error: " ); \ + printf message; \ + printf( "\n" ) - #define LogWarn( message ) printf( "Warn: " ); printf message; printf( "\n" ) + #define LogWarn( message ) \ + printf( "Warn: " ); \ + printf message; \ + printf( "\n" ) - #define LogInfo( message ) printf( "Info: " ); printf message; printf( "\n" ) + #define LogInfo( message ) \ + printf( "Info: " ); \ + printf message; \ + printf( "\n" ) - #define LogDebug( message ) printf( "Debug: " ); printf message; printf( "\n" ) + #define LogDebug( message ) \ + printf( "Debug: " ); \ + printf message; \ + printf( "\n" ) #endif /* DISABLE_LOGGING */ #endif /* ifndef SHADOW_CONFIG_H_ */ diff --git a/test/unit-test/shadow_utest.c b/test/unit-test/shadow_utest.c index 53637cf3..15410f72 100644 --- a/test/unit-test/shadow_utest.c +++ b/test/unit-test/shadow_utest.c @@ -4,22 +4,23 @@ * * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. * */ @@ -38,463 +39,620 @@ /* Shadow include. */ #include "shadow.h" - /*-----------------------------------------------------------*/ /** * @brief The Thing Name shared among all the tests. */ -#define TEST_THING_NAME "TestThingName" +#define TEST_THING_NAME "TestThingName" /** * @brief The length of #TEST_THING_NAME. */ -#define TEST_THING_NAME_LENGTH ( sizeof( TEST_THING_NAME ) - 1 ) +#define TEST_THING_NAME_LENGTH ( sizeof( TEST_THING_NAME ) - 1 ) /** - * @brief The shadow topic string "update" shared among all Classic shadow test cases. + * @brief The shadow topic string "update" shared among all Classic shadow test + * cases. */ -#define TEST_CLASSIC_TOPIC_STRING_UPDATE "$aws/things/TestThingName/shadow/update" +#define TEST_CLASSIC_TOPIC_STRING_UPDATE \ + "$aws/things/TestThingName/shadow/update" /** - * @brief The shadow topic string "update/accepted" shared among all Classic shadow test cases. + * @brief The shadow topic string "update/accepted" shared among all Classic + * shadow test cases. */ -#define TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED "$aws/things/TestThingName/shadow/update/accepted" +#define TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED \ + "$aws/things/TestThingName/shadow/update/accepted" /** - * @brief The shadow topic string "update/rejected" shared among all Classic shadow test cases. + * @brief The shadow topic string "update/rejected" shared among all Classic + * shadow test cases. */ -#define TEST_CLASSIC_TOPIC_STRING_UPDATE_REJECTED "$aws/things/TestThingName/shadow/update/rejected" +#define TEST_CLASSIC_TOPIC_STRING_UPDATE_REJECTED \ + "$aws/things/TestThingName/shadow/update/rejected" /** - * @brief The shadow topic string "update/documents" shared among all Classic shadow test cases. + * @brief The shadow topic string "update/documents" shared among all Classic + * shadow test cases. */ -#define TEST_CLASSIC_TOPIC_STRING_UPDATE_DOCUMENTS "$aws/things/TestThingName/shadow/update/documents" +#define TEST_CLASSIC_TOPIC_STRING_UPDATE_DOCUMENTS \ + "$aws/things/TestThingName/shadow/update/documents" /** - * @brief The shadow topic string "update/delta" shared among all Classic shadow test cases. + * @brief The shadow topic string "update/delta" shared among all Classic shadow + * test cases. */ -#define TEST_CLASSIC_TOPIC_STRING_UPDATE_DELTA "$aws/things/TestThingName/shadow/update/delta" +#define TEST_CLASSIC_TOPIC_STRING_UPDATE_DELTA \ + "$aws/things/TestThingName/shadow/update/delta" /** - * @brief The shadow topic string "get" shared among all Classic shadow test cases. + * @brief The shadow topic string "get" shared among all Classic shadow test + * cases. */ -#define TEST_CLASSIC_TOPIC_STRING_GET "$aws/things/TestThingName/shadow/get" +#define TEST_CLASSIC_TOPIC_STRING_GET "$aws/things/TestThingName/shadow/get" /** - * @brief The shadow topic string "get/accepted" shared among all Classic shadow test cases. + * @brief The shadow topic string "get/accepted" shared among all Classic shadow + * test cases. */ -#define TEST_CLASSIC_TOPIC_STRING_GET_ACCEPTED "$aws/things/TestThingName/shadow/get/accepted" +#define TEST_CLASSIC_TOPIC_STRING_GET_ACCEPTED \ + "$aws/things/TestThingName/shadow/get/accepted" /** - * @brief The shadow topic string "get/rejected" shared among all Classic shadow test cases. + * @brief The shadow topic string "get/rejected" shared among all Classic shadow + * test cases. */ -#define TEST_CLASSIC_TOPIC_STRING_GET_REJECTED "$aws/things/TestThingName/shadow/get/rejected" +#define TEST_CLASSIC_TOPIC_STRING_GET_REJECTED \ + "$aws/things/TestThingName/shadow/get/rejected" /** - * @brief The shadow topic string "delete" shared among all Classic shadow test cases. + * @brief The shadow topic string "delete" shared among all Classic shadow test + * cases. */ -#define TEST_CLASSIC_TOPIC_STRING_DELETE "$aws/things/TestThingName/shadow/delete" +#define TEST_CLASSIC_TOPIC_STRING_DELETE \ + "$aws/things/TestThingName/shadow/delete" /** - * @brief The shadow topic string "delete/accepted" shared among all Classic shadow test cases. + * @brief The shadow topic string "delete/accepted" shared among all Classic + * shadow test cases. */ -#define TEST_CLASSIC_TOPIC_STRING_DELETE_ACCEPTED "$aws/things/TestThingName/shadow/delete/accepted" +#define TEST_CLASSIC_TOPIC_STRING_DELETE_ACCEPTED \ + "$aws/things/TestThingName/shadow/delete/accepted" /** - * @brief The shadow topic string "delete/rejected" shared among all Classic shadow test cases. + * @brief The shadow topic string "delete/rejected" shared among all Classic + * shadow test cases. */ -#define TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED "$aws/things/TestThingName/shadow/delete/rejected" +#define TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED \ + "$aws/things/TestThingName/shadow/delete/rejected" /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE shared among all + * Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED shared among + * all Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE_REJECTED shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE_REJECTED shared among + * all Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE_REJECTED ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE_REJECTED ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE_REJECTED \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE_REJECTED ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE_DOCUMENTS shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE_DOCUMENTS shared among + * all Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE_DOCUMENTS ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE_DOCUMENTS ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE_DOCUMENTS \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE_DOCUMENTS ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE_DELTA shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_UPDATE_DELTA shared among all + * Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE_DELTA ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE_DELTA ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_UPDATE_DELTA \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_UPDATE_DELTA ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_GET shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_GET shared among all Classic + * shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_GET ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_GET ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_GET \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_GET ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_GET_ACCEPTED shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_GET_ACCEPTED shared among all + * Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_GET_ACCEPTED ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_GET_ACCEPTED ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_GET_ACCEPTED \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_GET_ACCEPTED ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_GET_REJECTED shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_GET_REJECTED shared among all + * Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_GET_REJECTED ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_GET_REJECTED ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_GET_REJECTED \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_GET_REJECTED ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_DELETE shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_DELETE shared among all + * Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_DELETE ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_DELETE ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_DELETE \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_DELETE ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_DELETE_ACCEPTED shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_DELETE_ACCEPTED shared among + * all Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_DELETE_ACCEPTED ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_DELETE_ACCEPTED ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_DELETE_ACCEPTED \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_DELETE_ACCEPTED ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED shared among + * all Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_DELETE_REJECTED ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_DELETE_REJECTED \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED ) - 1U ) /** * @brief A topic string with an empty thing name. */ -#define TEST_TOPIC_STRING_EMPTY_THINGNAME "$aws/things/" +#define TEST_TOPIC_STRING_EMPTY_THINGNAME "$aws/things/" /** * @brief A topic string with an invalid thing name. */ -#define TEST_TOPIC_STRING_INVALID_THINGNAME "$aws/things//" +#define TEST_TOPIC_STRING_INVALID_THINGNAME "$aws/things//" /** * @brief A topic string with an un-terminated thing name */ -#define TEST_TOPIC_STRING_UNTERMINATED_THINGNAME "$aws/things/TestThingName" +#define TEST_TOPIC_STRING_UNTERMINATED_THINGNAME "$aws/things/TestThingName" /** * @brief A topic string with an empty shadow root. */ -#define TEST_TOPIC_STRING_EMPTY_SHADOW_ROOT "$aws/things/TestThingName/" +#define TEST_TOPIC_STRING_EMPTY_SHADOW_ROOT "$aws/things/TestThingName/" /** * @brief A topic string with an invalid shadow root. */ -#define TEST_TOPIC_STRING_INVALID_SHADOW_ROOT "$aws/things/TestThingName/invalid" +#define TEST_TOPIC_STRING_INVALID_SHADOW_ROOT \ + "$aws/things/TestThingName/invalid" /** * @brief A topic string with an empty shadow message type. */ -#define TEST_CLASSIC_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE "$aws/things/TestThingName/shadow" +#define TEST_CLASSIC_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE \ + "$aws/things/TestThingName/shadow" /** * @brief A topic string that is not related to Shadow. */ -#define TEST_CLASSIC_TOPIC_STRING_INVALID_SHADOW_RESPONSE "$aws/things/TestThingName/shadow/invalid/invalid" +#define TEST_CLASSIC_TOPIC_STRING_INVALID_SHADOW_RESPONSE \ + "$aws/things/TestThingName/shadow/invalid/invalid" /** * @brief A topic string that is not related to Shadow. */ -#define TEST_CLASSIC_TOPIC_STRING_INVALID_GET_REJECTED "$aws/things/TestThingName/shadow/get/rejected/gibberish" +#define TEST_CLASSIC_TOPIC_STRING_INVALID_GET_REJECTED \ + "$aws/things/TestThingName/shadow/get/rejected/gibberish" /** * @brief A topic string that is not related to Shadow. */ -#define TEST_TOPIC_STRING_INVALID_PREFIX "$aws/jobs/TestThingName/shadow/get/rejected" +#define TEST_TOPIC_STRING_INVALID_PREFIX \ + "$aws/jobs/TestThingName/shadow/get/rejected" /** - * @brief The length of #TEST_TOPIC_STRING_INVALID_PREFIX shared among all shadow test cases. + * @brief The length of #TEST_TOPIC_STRING_INVALID_PREFIX shared among all + * shadow test cases. */ -#define TEST_TOPIC_LENGTH_INVALID_PREFIX ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_INVALID_PREFIX ) - 1U ) +#define TEST_TOPIC_LENGTH_INVALID_PREFIX \ + ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_INVALID_PREFIX ) - 1U ) /** - * @brief The length of #TEST_TOPIC_STRING_EMPTY_THINGNAME shared among all shadow test cases. + * @brief The length of #TEST_TOPIC_STRING_EMPTY_THINGNAME shared among all + * shadow test cases. */ -#define TEST_TOPIC_LENGTH_EMPTY_THINGNAME ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_EMPTY_THINGNAME ) - 1U ) +#define TEST_TOPIC_LENGTH_EMPTY_THINGNAME \ + ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_EMPTY_THINGNAME ) - 1U ) /** - * @brief The length of #TEST_TOPIC_STRING_INVALID_THINGNAME shared among all shadow test cases. + * @brief The length of #TEST_TOPIC_STRING_INVALID_THINGNAME shared among all + * shadow test cases. */ -#define TEST_TOPIC_LENGTH_INVALID_THINGNAME ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_INVALID_THINGNAME ) - 1U ) +#define TEST_TOPIC_LENGTH_INVALID_THINGNAME \ + ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_INVALID_THINGNAME ) - 1U ) /** - * @brief The length of #TEST_TOPIC_STRING_UNTERMINATED_THINGNAME shared among all shadow test cases. + * @brief The length of #TEST_TOPIC_STRING_UNTERMINATED_THINGNAME shared among + * all shadow test cases. */ -#define TEST_TOPIC_LENGTH_UNTERMINATED_THINGNAME ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_UNTERMINATED_THINGNAME ) - 1U ) +#define TEST_TOPIC_LENGTH_UNTERMINATED_THINGNAME \ + ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_UNTERMINATED_THINGNAME ) - 1U ) /** - * @brief The length of #TEST_TOPIC_STRING_EMPTY_SHADOW_ROOT shared among all shadow test cases. + * @brief The length of #TEST_TOPIC_STRING_EMPTY_SHADOW_ROOT shared among all + * shadow test cases. */ -#define TEST_TOPIC_LENGTH_EMPTY_SHADOW_ROOT ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_EMPTY_SHADOW_ROOT ) - 1U ) +#define TEST_TOPIC_LENGTH_EMPTY_SHADOW_ROOT \ + ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_EMPTY_SHADOW_ROOT ) - 1U ) /** - * @brief The length of #TEST_TOPIC_STRING_INVALID_SHADOW_ROOT shared among all shadow test cases. + * @brief The length of #TEST_TOPIC_STRING_INVALID_SHADOW_ROOT shared among all + * shadow test cases. */ -#define TEST_TOPIC_LENGTH_INVALID_SHADOW_ROOT ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_INVALID_SHADOW_ROOT ) - 1U ) +#define TEST_TOPIC_LENGTH_INVALID_SHADOW_ROOT \ + ( ( uint16_t ) sizeof( TEST_TOPIC_STRING_INVALID_SHADOW_ROOT ) - 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE + * shared among all Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_EMPTY_SHADOW_MESSAGE_TYPE ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_EMPTY_SHADOW_MESSAGE_TYPE \ + ( ( uint16_t ) sizeof( \ + TEST_CLASSIC_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE ) - \ + 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_INVALID_SHADOW_RESPONSE shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_INVALID_SHADOW_RESPONSE + * shared among all Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_INVALID_SHADOW_RESPONSE ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_INVALID_SHADOW_RESPONSE ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_INVALID_SHADOW_RESPONSE \ + ( ( uint16_t ) sizeof( \ + TEST_CLASSIC_TOPIC_STRING_INVALID_SHADOW_RESPONSE ) - \ + 1U ) /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_INVALID_GET_REJECTED shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_INVALID_GET_REJECTED shared + * among all Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_LENGTH_INVALID_GET_REJECTED ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_INVALID_GET_REJECTED ) - 1U ) +#define TEST_CLASSIC_TOPIC_LENGTH_INVALID_GET_REJECTED \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_STRING_INVALID_GET_REJECTED ) - \ + 1U ) /** * @brief The init value for a topic buffer. */ -#define TEST_CLASSIC_TOPIC_BUFFER_INITIALIZE "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmno" +#define TEST_CLASSIC_TOPIC_BUFFER_INITIALIZE \ + "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmno" /** * @brief The init value for a topic buffer. */ -#define TEST_CLASSIC_TOPIC_BUFFER_MODIFIED "$aws/things/TestThingName/shadow/get/acceptedklmno" +#define TEST_CLASSIC_TOPIC_BUFFER_MODIFIED \ + "$aws/things/TestThingName/shadow/get/acceptedklmno" /** - * @brief The length of #TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED shared among all Classic shadow test cases. + * @brief The length of #TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED shared among + * all Classic shadow test cases. */ -#define TEST_CLASSIC_TOPIC_BUFFER_LENGTH ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_BUFFER_INITIALIZE ) - 1U ) - +#define TEST_CLASSIC_TOPIC_BUFFER_LENGTH \ + ( ( uint16_t ) sizeof( TEST_CLASSIC_TOPIC_BUFFER_INITIALIZE ) - 1U ) /** * @brief The Shadow Name shared among all the named shadow tests. */ -#define TEST_SHADOW_NAME "TestShadowName" +#define TEST_SHADOW_NAME "TestShadowName" /** * @brief The length of #TEST_SHADOW_NAME. */ -#define TEST_SHADOW_NAME_LENGTH ( sizeof( TEST_SHADOW_NAME ) - 1 ) +#define TEST_SHADOW_NAME_LENGTH ( sizeof( TEST_SHADOW_NAME ) - 1 ) /** - * @brief The shadow topic string "update" shared among all named shadow test cases. + * @brief The shadow topic string "update" shared among all named shadow test + * cases. */ -#define TEST_NAMED_TOPIC_STRING_UPDATE "$aws/things/TestThingName/shadow/name/TestShadowName/update" +#define TEST_NAMED_TOPIC_STRING_UPDATE \ + "$aws/things/TestThingName/shadow/name/TestShadowName/update" /** - * @brief The shadow topic string "update/accepted" shared among all named shadow test cases. + * @brief The shadow topic string "update/accepted" shared among all named + * shadow test cases. */ -#define TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED "$aws/things/TestThingName/shadow/name/TestShadowName/update/accepted" +#define TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED \ + "$aws/things/TestThingName/shadow/name/TestShadowName/update/accepted" /** - * @brief The shadow topic string "update/rejected" shared among all named shadow test cases. + * @brief The shadow topic string "update/rejected" shared among all named + * shadow test cases. */ -#define TEST_NAMED_TOPIC_STRING_UPDATE_REJECTED "$aws/things/TestThingName/shadow/name/TestShadowName/update/rejected" +#define TEST_NAMED_TOPIC_STRING_UPDATE_REJECTED \ + "$aws/things/TestThingName/shadow/name/TestShadowName/update/rejected" /** - * @brief The shadow topic string "update/documents" shared among all named shadow test cases. + * @brief The shadow topic string "update/documents" shared among all named + * shadow test cases. */ -#define TEST_NAMED_TOPIC_STRING_UPDATE_DOCUMENTS "$aws/things/TestThingName/shadow/name/TestShadowName/update/documents" +#define TEST_NAMED_TOPIC_STRING_UPDATE_DOCUMENTS \ + "$aws/things/TestThingName/shadow/name/TestShadowName/update/documents" /** - * @brief The shadow topic string "update/delta" shared among all named shadow test cases. + * @brief The shadow topic string "update/delta" shared among all named shadow + * test cases. */ -#define TEST_NAMED_TOPIC_STRING_UPDATE_DELTA "$aws/things/TestThingName/shadow/name/TestShadowName/update/delta" +#define TEST_NAMED_TOPIC_STRING_UPDATE_DELTA \ + "$aws/things/TestThingName/shadow/name/TestShadowName/update/delta" /** - * @brief The shadow topic string "get" shared among all named shadow test cases. + * @brief The shadow topic string "get" shared among all named shadow test + * cases. */ -#define TEST_NAMED_TOPIC_STRING_GET "$aws/things/TestThingName/shadow/name/TestShadowName/get" +#define TEST_NAMED_TOPIC_STRING_GET \ + "$aws/things/TestThingName/shadow/name/TestShadowName/get" /** - * @brief The shadow topic string "get/accepted" shared among all named shadow test cases. + * @brief The shadow topic string "get/accepted" shared among all named shadow + * test cases. */ -#define TEST_NAMED_TOPIC_STRING_GET_ACCEPTED "$aws/things/TestThingName/shadow/name/TestShadowName/get/accepted" +#define TEST_NAMED_TOPIC_STRING_GET_ACCEPTED \ + "$aws/things/TestThingName/shadow/name/TestShadowName/get/accepted" /** - * @brief The shadow topic string "get/rejected" shared among all named shadow test cases. + * @brief The shadow topic string "get/rejected" shared among all named shadow + * test cases. */ -#define TEST_NAMED_TOPIC_STRING_GET_REJECTED "$aws/things/TestThingName/shadow/name/TestShadowName/get/rejected" +#define TEST_NAMED_TOPIC_STRING_GET_REJECTED \ + "$aws/things/TestThingName/shadow/name/TestShadowName/get/rejected" /** - * @brief The shadow topic string "delete" shared among all named shadow test cases. + * @brief The shadow topic string "delete" shared among all named shadow test + * cases. */ -#define TEST_NAMED_TOPIC_STRING_DELETE "$aws/things/TestThingName/shadow/name/TestShadowName/delete" +#define TEST_NAMED_TOPIC_STRING_DELETE \ + "$aws/things/TestThingName/shadow/name/TestShadowName/delete" /** - * @brief The shadow topic string "delete/accepted" shared among all named shadow test cases. + * @brief The shadow topic string "delete/accepted" shared among all named + * shadow test cases. */ -#define TEST_NAMED_TOPIC_STRING_DELETE_ACCEPTED "$aws/things/TestThingName/shadow/name/TestShadowName/delete/accepted" +#define TEST_NAMED_TOPIC_STRING_DELETE_ACCEPTED \ + "$aws/things/TestThingName/shadow/name/TestShadowName/delete/accepted" /** - * @brief The shadow topic string "delete/rejected" shared among all named shadow test cases. + * @brief The shadow topic string "delete/rejected" shared among all named + * shadow test cases. */ -#define TEST_NAMED_TOPIC_STRING_DELETE_REJECTED "$aws/things/TestThingName/shadow/name/TestShadowName/delete/rejected" +#define TEST_NAMED_TOPIC_STRING_DELETE_REJECTED \ + "$aws/things/TestThingName/shadow/name/TestShadowName/delete/rejected" /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE shared among all named + * shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_UPDATE ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_UPDATE \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED shared among + * all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE_REJECTED shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE_REJECTED shared among + * all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_UPDATE_REJECTED ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE_REJECTED ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_UPDATE_REJECTED \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE_REJECTED ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE_DOCUMENTS shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE_DOCUMENTS shared among + * all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_UPDATE_DOCUMENTS ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE_DOCUMENTS ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_UPDATE_DOCUMENTS \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE_DOCUMENTS ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE_DELTA shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_UPDATE_DELTA shared among all + * named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_UPDATE_DELTA ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE_DELTA ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_UPDATE_DELTA \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UPDATE_DELTA ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_GET shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_GET shared among all named + * shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_GET ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_GET ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_GET \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_GET ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_GET_ACCEPTED shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_GET_ACCEPTED shared among all + * named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_GET_ACCEPTED ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_GET_ACCEPTED ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_GET_ACCEPTED \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_GET_ACCEPTED ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_GET_REJECTED shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_GET_REJECTED shared among all + * named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_GET_REJECTED ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_GET_REJECTED ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_GET_REJECTED \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_GET_REJECTED ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_DELETE shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_DELETE shared among all named + * shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_DELETE ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_DELETE ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_DELETE \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_DELETE ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_DELETE_ACCEPTED shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_DELETE_ACCEPTED shared among + * all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_DELETE_ACCEPTED ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_DELETE_ACCEPTED ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_DELETE_ACCEPTED \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_DELETE_ACCEPTED ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_DELETE_REJECTED shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_DELETE_REJECTED shared among + * all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_DELETE_REJECTED ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_DELETE_REJECTED ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_DELETE_REJECTED \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_DELETE_REJECTED ) - 1U ) /** * @brief A topic string with an empty shadow name. */ -#define TEST_NAMED_TOPIC_STRING_EMPTY_SHADOWNAME "$aws/things/TestThingName/shadow/name/" +#define TEST_NAMED_TOPIC_STRING_EMPTY_SHADOWNAME \ + "$aws/things/TestThingName/shadow/name/" /** * @brief A topic string with an invalid shadow name. */ -#define TEST_NAMED_TOPIC_STRING_INVALID_SHADOWNAME "$aws/things/TestThingName/shadow/name//" +#define TEST_NAMED_TOPIC_STRING_INVALID_SHADOWNAME \ + "$aws/things/TestThingName/shadow/name//" /** * @brief A topic string with an un-terminated shadow name */ -#define TEST_NAMED_TOPIC_STRING_UNTERMINATED_SHADOWNAME "$aws/things/TestThingName/shadow/name/TestShadowName" +#define TEST_NAMED_TOPIC_STRING_UNTERMINATED_SHADOWNAME \ + "$aws/things/TestThingName/shadow/name/TestShadowName" /** * @brief A topic string with an empty shadow message type. */ -#define TEST_NAMED_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE "$aws/things/TestThingName/shadow/name/TestShadowName/" +#define TEST_NAMED_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE \ + "$aws/things/TestThingName/shadow/name/TestShadowName/" /** * @brief A topic string that is not related to Shadow. */ -#define TEST_NAMED_TOPIC_STRING_INVALID_SHADOW_RESPONSE "$aws/things/TestThingName/shadow/name/TestShadowName/invalid/invalid" +#define TEST_NAMED_TOPIC_STRING_INVALID_SHADOW_RESPONSE \ + "$aws/things/TestThingName/shadow/name/TestShadowName/invalid/invalid" /** * @brief A topic string that is not related to Shadow. */ -#define TEST_NAMED_TOPIC_STRING_INVALID_GET_REJECTED "$aws/things/TestThingName/shadow/name/TestShadowName/get/rejected/gibberish" +#define TEST_NAMED_TOPIC_STRING_INVALID_GET_REJECTED \ + "$aws/things/TestThingName/shadow/name/TestShadowName/get/rejected/" \ + "gibberish" /** * @brief A topic string that exceeds the maximum Thing name length. */ -#define TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_THING_NAME "$aws/things/TestThingName12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890/shadow/name/TestShadowName/delete/rejected" +#define TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_THING_NAME \ + "$aws/things/" \ + "TestThingName12345678901234567890123456789012345678901234567890123456789" \ + "012345678901234567890123456789012345678901234567890123456789012345678901" \ + "234567890/shadow/name/TestShadowName/delete/rejected" /** * @brief A topic string that exceeds the maximum Shadow name length. */ -#define TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_SHADOW_NAME "$aws/things/TestThingName/shadow/name/TestShadowName123456789012345678901234567890123456789012345678901234567890/delete/rejected" +#define TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_SHADOW_NAME \ + "$aws/things/TestThingName/shadow/name/" \ + "TestShadowName1234567890123456789012345678901234567890123456789012345678" \ + "90/delete/rejected" /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_EMPTY_SHADOWNAME shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_EMPTY_SHADOWNAME shared among + * all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_EMPTY_SHADOWNAME ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_EMPTY_SHADOWNAME ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_EMPTY_SHADOWNAME \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_EMPTY_SHADOWNAME ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_INVALID_SHADOWNAME shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_INVALID_SHADOWNAME shared among + * all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_INVALID_SHADOWNAME ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_INVALID_SHADOWNAME ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_INVALID_SHADOWNAME \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_INVALID_SHADOWNAME ) - 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_UNTERMINATED_SHADOWNAME shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_UNTERMINATED_SHADOWNAME shared + * among all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_UNTERMINATED_SHADOWNAME ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UNTERMINATED_SHADOWNAME ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_UNTERMINATED_SHADOWNAME \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_UNTERMINATED_SHADOWNAME ) - \ + 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE + * shared among all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_EMPTY_SHADOW_MESSAGE_TYPE ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_EMPTY_SHADOW_MESSAGE_TYPE \ + ( ( uint16_t ) sizeof( \ + TEST_NAMED_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE ) - \ + 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_INVALID_SHADOW_RESPONSE shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_INVALID_SHADOW_RESPONSE shared + * among all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_INVALID_SHADOW_RESPONSE ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_INVALID_SHADOW_RESPONSE ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_INVALID_SHADOW_RESPONSE \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_INVALID_SHADOW_RESPONSE ) - \ + 1U ) /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_INVALID_GET_REJECTED shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_INVALID_GET_REJECTED shared + * among all named shadow test cases. */ -#define TEST_NAMED_TOPIC_LENGTH_INVALID_GET_REJECTED ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_INVALID_GET_REJECTED ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_INVALID_GET_REJECTED \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_INVALID_GET_REJECTED ) - 1U ) /** * @brief The length of #TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_THING_NAME. */ -#define TEST_NAMED_TOPIC_LENGTH_EXCEEDS_MAX_THING_NAME ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_THING_NAME ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_EXCEEDS_MAX_THING_NAME \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_THING_NAME ) - \ + 1U ) /** * @brief The length of #TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_SHADOW_NAME. */ -#define TEST_NAMED_TOPIC_LENGTH_EXCEEDS_MAX_SHADOW_NAME ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_SHADOW_NAME ) - 1U ) +#define TEST_NAMED_TOPIC_LENGTH_EXCEEDS_MAX_SHADOW_NAME \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_SHADOW_NAME ) - \ + 1U ) /** * @brief The init value for a topic buffer. */ -#define TEST_NAMED_TOPIC_BUFFER_INITIALIZE "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz123456789" +#define TEST_NAMED_TOPIC_BUFFER_INITIALIZE \ + "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789abcdefghijklmnopqrstuvwxyz123456789" /** * @brief The init value for a topic buffer. */ -#define TEST_NAMED_TOPIC_BUFFER_MODIFIED "$aws/things/TestThingName/shadow/name/TestShadowName/get/accepted56789" +#define TEST_NAMED_TOPIC_BUFFER_MODIFIED \ + "$aws/things/TestThingName/shadow/name/TestShadowName/get/accepted56789" /** - * @brief The length of #TEST_NAMED_TOPIC_STRING_DELETE_REJECTED shared among all named shadow test cases. + * @brief The length of #TEST_NAMED_TOPIC_STRING_DELETE_REJECTED shared among + * all named shadow test cases. */ -#define TEST_NAMED_TOPIC_BUFFER_LENGTH ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_BUFFER_INITIALIZE ) - 1U ) +#define TEST_NAMED_TOPIC_BUFFER_LENGTH \ + ( ( uint16_t ) sizeof( TEST_NAMED_TOPIC_BUFFER_INITIALIZE ) - 1U ) /** * @brief Maximum shadow name length. - * Refer to https://docs.aws.amazon.com/general/latest/gr/iot-core.html#device-shadow-limits + * Refer to + * https://docs.aws.amazon.com/general/latest/gr/iot-core.html#device-shadow-limits * for more details about the Device Shadow limits. */ -#define SHADOW_NAME_MAX_LENGTH ( 64U ) +#define SHADOW_NAME_MAX_LENGTH ( 64U ) /** * @brief Maximum thing name length. - * Refer to https://docs.aws.amazon.com/general/latest/gr/iot-core.html#device-shadow-limits + * Refer to + * https://docs.aws.amazon.com/general/latest/gr/iot-core.html#device-shadow-limits * for more details about the Device Shadow limits. */ -#define SHADOW_THINGNAME_MAX_LENGTH ( 128U ) +#define SHADOW_THINGNAME_MAX_LENGTH ( 128U ) /*-----------------------------------------------------------*/ @@ -527,18 +685,31 @@ int suiteTearDown( int numFailures ) */ void test_Shadow_Classic_MacrosString( void ) { - /* Test Classic shadow topic strings through the deprecated legacy macros, to verify the legacy macros. */ - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE, SHADOW_TOPIC_STRING_UPDATE( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED, SHADOW_TOPIC_STRING_UPDATE_ACCEPTED( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE_REJECTED, SHADOW_TOPIC_STRING_UPDATE_REJECTED( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE_DOCUMENTS, SHADOW_TOPIC_STRING_UPDATE_DOCUMENTS( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE_DELTA, SHADOW_TOPIC_STRING_UPDATE_DELTA( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_GET, SHADOW_TOPIC_STRING_GET( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_GET_ACCEPTED, SHADOW_TOPIC_STRING_GET_ACCEPTED( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_GET_REJECTED, SHADOW_TOPIC_STRING_GET_REJECTED( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_DELETE, SHADOW_TOPIC_STRING_DELETE( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_DELETE_ACCEPTED, SHADOW_TOPIC_STRING_DELETE_ACCEPTED( TEST_THING_NAME ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED, SHADOW_TOPIC_STRING_DELETE_REJECTED( TEST_THING_NAME ) ); + /* Test Classic shadow topic strings through the deprecated legacy macros, + * to verify the legacy macros. */ + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE, + SHADOW_TOPIC_STRING_UPDATE( TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED, + SHADOW_TOPIC_STRING_UPDATE_ACCEPTED( TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE_REJECTED, + SHADOW_TOPIC_STRING_UPDATE_REJECTED( TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE_DOCUMENTS, + SHADOW_TOPIC_STRING_UPDATE_DOCUMENTS( + TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_UPDATE_DELTA, + SHADOW_TOPIC_STRING_UPDATE_DELTA( TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_GET, + SHADOW_TOPIC_STRING_GET( TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_GET_ACCEPTED, + SHADOW_TOPIC_STRING_GET_ACCEPTED( TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_GET_REJECTED, + SHADOW_TOPIC_STRING_GET_REJECTED( TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_DELETE, + SHADOW_TOPIC_STRING_DELETE( TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_DELETE_ACCEPTED, + SHADOW_TOPIC_STRING_DELETE_ACCEPTED( TEST_THING_NAME ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED, + SHADOW_TOPIC_STRING_DELETE_REJECTED( TEST_THING_NAME ) ); } /** @@ -546,80 +717,150 @@ void test_Shadow_Classic_MacrosString( void ) */ void test_Shadow_Named_MacrosString( void ) { - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE, SHADOW_TOPIC_STR_UPDATE( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED, SHADOW_TOPIC_STR_UPDATE_ACC( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE_REJECTED, SHADOW_TOPIC_STR_UPDATE_REJ( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE_DOCUMENTS, SHADOW_TOPIC_STR_UPDATE_DOCS( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE_DELTA, SHADOW_TOPIC_STR_UPDATE_DELTA( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_GET, SHADOW_TOPIC_STR_GET( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_GET_ACCEPTED, SHADOW_TOPIC_STR_GET_ACC( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_GET_REJECTED, SHADOW_TOPIC_STR_GET_REJ( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_DELETE, SHADOW_TOPIC_STR_DELETE( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_DELETE_ACCEPTED, SHADOW_TOPIC_STR_DELETE_ACC( TEST_THING_NAME, TEST_SHADOW_NAME ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_DELETE_REJECTED, SHADOW_TOPIC_STR_DELETE_REJ( TEST_THING_NAME, TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE, + SHADOW_TOPIC_STR_UPDATE( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED, + SHADOW_TOPIC_STR_UPDATE_ACC( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE_REJECTED, + SHADOW_TOPIC_STR_UPDATE_REJ( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE_DOCUMENTS, + SHADOW_TOPIC_STR_UPDATE_DOCS( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_UPDATE_DELTA, + SHADOW_TOPIC_STR_UPDATE_DELTA( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_GET, + SHADOW_TOPIC_STR_GET( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_GET_ACCEPTED, + SHADOW_TOPIC_STR_GET_ACC( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_GET_REJECTED, + SHADOW_TOPIC_STR_GET_REJ( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_DELETE, + SHADOW_TOPIC_STR_DELETE( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_DELETE_ACCEPTED, + SHADOW_TOPIC_STR_DELETE_ACC( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_STRING_DELETE_REJECTED, + SHADOW_TOPIC_STR_DELETE_REJ( TEST_THING_NAME, + TEST_SHADOW_NAME ) ); } /*-----------------------------------------------------------*/ /** - * @brief Tests the macros generate the expected strings length for Classic shadows. + * @brief Tests the macros generate the expected strings length for Classic + * shadows. */ void test_Shadow_Classic_MacrosLength( void ) { - /* Test Classic shadow topic lengths through the deprecated legacy macros, to verify the legacy macros. */ - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE, SHADOW_TOPIC_LENGTH_UPDATE( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED, SHADOW_TOPIC_LENGTH_UPDATE_ACCEPTED( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE_REJECTED, SHADOW_TOPIC_LENGTH_UPDATE_REJECTED( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE_DOCUMENTS, SHADOW_TOPIC_LENGTH_UPDATE_DOCUMENTS( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE_DELTA, SHADOW_TOPIC_LENGTH_UPDATE_DELTA( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_GET, SHADOW_TOPIC_LENGTH_GET( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_GET_ACCEPTED, SHADOW_TOPIC_LENGTH_GET_ACCEPTED( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_GET_REJECTED, SHADOW_TOPIC_LENGTH_GET_REJECTED( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_DELETE, SHADOW_TOPIC_LENGTH_DELETE( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_DELETE_ACCEPTED, SHADOW_TOPIC_LENGTH_DELETE_ACCEPTED( TEST_THING_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_DELETE_REJECTED, SHADOW_TOPIC_LENGTH_DELETE_REJECTED( TEST_THING_NAME_LENGTH ) ); + /* Test Classic shadow topic lengths through the deprecated legacy macros, + * to verify the legacy macros. */ + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE, + SHADOW_TOPIC_LENGTH_UPDATE( TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED, + SHADOW_TOPIC_LENGTH_UPDATE_ACCEPTED( + TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE_REJECTED, + SHADOW_TOPIC_LENGTH_UPDATE_REJECTED( + TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE_DOCUMENTS, + SHADOW_TOPIC_LENGTH_UPDATE_DOCUMENTS( + TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_UPDATE_DELTA, + SHADOW_TOPIC_LENGTH_UPDATE_DELTA( + TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_GET, + SHADOW_TOPIC_LENGTH_GET( TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_GET_ACCEPTED, + SHADOW_TOPIC_LENGTH_GET_ACCEPTED( + TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_GET_REJECTED, + SHADOW_TOPIC_LENGTH_GET_REJECTED( + TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_DELETE, + SHADOW_TOPIC_LENGTH_DELETE( TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_DELETE_ACCEPTED, + SHADOW_TOPIC_LENGTH_DELETE_ACCEPTED( + TEST_THING_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_CLASSIC_TOPIC_LENGTH_DELETE_REJECTED, + SHADOW_TOPIC_LENGTH_DELETE_REJECTED( + TEST_THING_NAME_LENGTH ) ); } /** - * @brief Tests the macros generate the expected strings length for named shadows. + * @brief Tests the macros generate the expected strings length for named + * shadows. */ void test_Shadow_Named_MacrosLength( void ) { - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_UPDATE, SHADOW_TOPIC_LEN_UPDATE( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED, SHADOW_TOPIC_LEN_UPDATE_ACC( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_UPDATE_REJECTED, SHADOW_TOPIC_LEN_UPDATE_REJ( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_UPDATE_DOCUMENTS, SHADOW_TOPIC_LEN_UPDATE_DOCS( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_UPDATE_DELTA, SHADOW_TOPIC_LEN_UPDATE_DELTA( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_GET, SHADOW_TOPIC_LEN_GET( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_GET_ACCEPTED, SHADOW_TOPIC_LEN_GET_ACC( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_GET_REJECTED, SHADOW_TOPIC_LEN_GET_REJ( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_DELETE, SHADOW_TOPIC_LEN_DELETE( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_DELETE_ACCEPTED, SHADOW_TOPIC_LEN_DELETE_ACC( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); - TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_DELETE_REJECTED, SHADOW_TOPIC_LEN_DELETE_REJ( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_UPDATE, + SHADOW_TOPIC_LEN_UPDATE( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED, + SHADOW_TOPIC_LEN_UPDATE_ACC( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_UPDATE_REJECTED, + SHADOW_TOPIC_LEN_UPDATE_REJ( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_UPDATE_DOCUMENTS, + SHADOW_TOPIC_LEN_UPDATE_DOCS( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( + TEST_NAMED_TOPIC_LENGTH_UPDATE_DELTA, + SHADOW_TOPIC_LEN_UPDATE_DELTA( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_GET, + SHADOW_TOPIC_LEN_GET( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_GET_ACCEPTED, + SHADOW_TOPIC_LEN_GET_ACC( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_GET_REJECTED, + SHADOW_TOPIC_LEN_GET_REJ( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_DELETE, + SHADOW_TOPIC_LEN_DELETE( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_DELETE_ACCEPTED, + SHADOW_TOPIC_LEN_DELETE_ACC( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); + TEST_ASSERT_EQUAL( TEST_NAMED_TOPIC_LENGTH_DELETE_REJECTED, + SHADOW_TOPIC_LEN_DELETE_REJ( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ); } /*-----------------------------------------------------------*/ /** - * @brief Tests the behavior of Shadow_AssembleTopicString() for Classic shadows, - * with valid parameters. Tests Classic shadows through the deprecated legacy API macro - * Shadow_GetTopicString(), to verify the legacy macro. + * @brief Tests the behavior of Shadow_AssembleTopicString() for Classic + * shadows, with valid parameters. Tests Classic shadows through the deprecated + * legacy API macro Shadow_GetTopicString(), to verify the legacy macro. */ void test_Shadow_AssembleTopicString_Classic_Happy_Path( void ) { ShadowStatus_t shadowStatus = SHADOW_SUCCESS; uint16_t outLength = 0U; - char topicBufferExceeded[ TEST_CLASSIC_TOPIC_BUFFER_LENGTH ] = TEST_CLASSIC_TOPIC_BUFFER_INITIALIZE; + char topicBufferExceeded[ TEST_CLASSIC_TOPIC_BUFFER_LENGTH ] = + TEST_CLASSIC_TOPIC_BUFFER_INITIALIZE; uint16_t bufferSizeExceeded = TEST_CLASSIC_TOPIC_BUFFER_LENGTH; - char topicBufferGetAccepted[ SHADOW_TOPIC_LENGTH_GET_ACCEPTED( TEST_THING_NAME_LENGTH ) ] = { 0 }; + char topicBufferGetAccepted[ SHADOW_TOPIC_LENGTH_GET_ACCEPTED( + TEST_THING_NAME_LENGTH ) ] = { 0 }; uint16_t bufferSizeGetAccepted = TEST_CLASSIC_TOPIC_LENGTH_GET_ACCEPTED; - char topicBuffer[ SHADOW_TOPIC_LENGTH_MAX( TEST_THING_NAME_LENGTH ) ] = { 0 }; + char topicBuffer[ SHADOW_TOPIC_LENGTH_MAX( TEST_THING_NAME_LENGTH ) ] = { + 0 + }; uint16_t bufferSize = SHADOW_TOPIC_LENGTH_MAX( TEST_THING_NAME_LENGTH ); uint16_t index = 0U; /* Lookup table for Shadow message string. */ - static const uint16_t expectedBuffersSize[ ShadowTopicStringTypeMaxNum ] = - { + static const uint16_t expectedBuffersSize[ ShadowTopicStringTypeMaxNum ] = { TEST_CLASSIC_TOPIC_LENGTH_UPDATE, TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED, TEST_CLASSIC_TOPIC_LENGTH_UPDATE_REJECTED, @@ -634,8 +875,7 @@ void test_Shadow_AssembleTopicString_Classic_Happy_Path( void ) }; /* Lookup table for Shadow message string. */ - static const char * const expectedBuffers[ ShadowTopicStringTypeMaxNum ] = - { + static const char * const expectedBuffers[ ShadowTopicStringTypeMaxNum ] = { TEST_CLASSIC_TOPIC_STRING_UPDATE, TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED, TEST_CLASSIC_TOPIC_STRING_UPDATE_REJECTED, @@ -649,23 +889,23 @@ void test_Shadow_AssembleTopicString_Classic_Happy_Path( void ) TEST_CLASSIC_TOPIC_STRING_DELETE_REJECTED }; - static const ShadowTopicStringType_t topicTypes[ ShadowTopicStringTypeMaxNum ] = - { - ShadowTopicStringTypeUpdate, - ShadowTopicStringTypeUpdateAccepted, - ShadowTopicStringTypeUpdateRejected, - ShadowTopicStringTypeUpdateDocuments, - ShadowTopicStringTypeUpdateDelta, - ShadowTopicStringTypeGet, - ShadowTopicStringTypeGetAccepted, - ShadowTopicStringTypeGetRejected, - ShadowTopicStringTypeDelete, - ShadowTopicStringTypeDeleteAccepted, - ShadowTopicStringTypeDeleteRejected - }; - - /* Call Shadow_GetTopicString() with valid parameters but bufferSize exceeds topic string length - * and verify result. */ + static const ShadowTopicStringType_t + topicTypes[ ShadowTopicStringTypeMaxNum ] = { + ShadowTopicStringTypeUpdate, + ShadowTopicStringTypeUpdateAccepted, + ShadowTopicStringTypeUpdateRejected, + ShadowTopicStringTypeUpdateDocuments, + ShadowTopicStringTypeUpdateDelta, + ShadowTopicStringTypeGet, + ShadowTopicStringTypeGetAccepted, + ShadowTopicStringTypeGetRejected, + ShadowTopicStringTypeDelete, + ShadowTopicStringTypeDeleteAccepted, + ShadowTopicStringTypeDeleteRejected + }; + + /* Call Shadow_GetTopicString() with valid parameters but bufferSize exceeds + * topic string length and verify result. */ shadowStatus = Shadow_GetTopicString( ShadowTopicStringTypeGetAccepted, TEST_THING_NAME, TEST_THING_NAME_LENGTH, @@ -679,8 +919,8 @@ void test_Shadow_AssembleTopicString_Classic_Happy_Path( void ) topicBufferExceeded, bufferSizeExceeded ); - /* Call Shadow_GetTopicString() with valid parameters, bufferSize = expected outLength - * and verify result. */ + /* Call Shadow_GetTopicString() with valid parameters, bufferSize = expected + * outLength and verify result. */ shadowStatus = Shadow_GetTopicString( ShadowTopicStringTypeGetAccepted, TEST_THING_NAME, TEST_THING_NAME_LENGTH, @@ -694,8 +934,8 @@ void test_Shadow_AssembleTopicString_Classic_Happy_Path( void ) for( index = 0U; index < ShadowTopicStringTypeMaxNum; index++ ) { - /* Call Shadow_GetTopicString() with valid parameters with all types of topic string - * and verify result. */ + /* Call Shadow_GetTopicString() with valid parameters with all types of + * topic string and verify result. */ shadowStatus = Shadow_GetTopicString( topicTypes[ index ], TEST_THING_NAME, TEST_THING_NAME_LENGTH, @@ -709,7 +949,8 @@ void test_Shadow_AssembleTopicString_Classic_Happy_Path( void ) } /* Call Shadow_AssembleTopicString() with valid parameters. - * Use classic shadow by passing NULL for shadow name and 0 for shadow name length. */ + * Use classic shadow by passing NULL for shadow name and 0 for shadow name + * length. */ shadowStatus = Shadow_AssembleTopicString( ShadowTopicStringTypeGetAccepted, TEST_THING_NAME, TEST_THING_NAME_LENGTH, @@ -725,23 +966,28 @@ void test_Shadow_AssembleTopicString_Classic_Happy_Path( void ) } /** - * @brief Tests the behavior of Shadow_AssembleTopicString() for named shadows, with valid parameters. + * @brief Tests the behavior of Shadow_AssembleTopicString() for named shadows, + * with valid parameters. */ void test_Shadow_AssembleTopicString_Named_Happy_Path( void ) { ShadowStatus_t shadowStatus = SHADOW_SUCCESS; uint16_t outLength = 0U; - char topicBufferExceeded[ TEST_NAMED_TOPIC_BUFFER_LENGTH ] = TEST_NAMED_TOPIC_BUFFER_INITIALIZE; + char topicBufferExceeded + [ TEST_NAMED_TOPIC_BUFFER_LENGTH ] = TEST_NAMED_TOPIC_BUFFER_INITIALIZE; uint16_t bufferSizeExceeded = TEST_NAMED_TOPIC_BUFFER_LENGTH; - char topicBufferGetAccepted[ SHADOW_TOPIC_LEN_GET_ACC( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ] = { 0 }; + char topicBufferGetAccepted[ SHADOW_TOPIC_LEN_GET_ACC( + TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ] = { 0 }; uint16_t bufferSizeGetAccepted = TEST_NAMED_TOPIC_LENGTH_GET_ACCEPTED; - char topicBuffer[ SHADOW_TOPIC_LEN_MAX( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ) ] = { 0 }; - uint16_t bufferSize = SHADOW_TOPIC_LEN_MAX( TEST_THING_NAME_LENGTH, TEST_SHADOW_NAME_LENGTH ); + char topicBuffer[ SHADOW_TOPIC_LEN_MAX( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ) ] = { 0 }; + uint16_t bufferSize = SHADOW_TOPIC_LEN_MAX( TEST_THING_NAME_LENGTH, + TEST_SHADOW_NAME_LENGTH ); uint16_t index = 0U; /* Lookup table for Shadow message string. */ - static const uint16_t expectedBuffersSize[ ShadowTopicStringTypeMaxNum ] = - { + static const uint16_t expectedBuffersSize[ ShadowTopicStringTypeMaxNum ] = { TEST_NAMED_TOPIC_LENGTH_UPDATE, TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED, TEST_NAMED_TOPIC_LENGTH_UPDATE_REJECTED, @@ -756,8 +1002,7 @@ void test_Shadow_AssembleTopicString_Named_Happy_Path( void ) }; /* Lookup table for Shadow message string. */ - static const char * const expectedBuffers[ ShadowTopicStringTypeMaxNum ] = - { + static const char * const expectedBuffers[ ShadowTopicStringTypeMaxNum ] = { TEST_NAMED_TOPIC_STRING_UPDATE, TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED, TEST_NAMED_TOPIC_STRING_UPDATE_REJECTED, @@ -771,23 +1016,23 @@ void test_Shadow_AssembleTopicString_Named_Happy_Path( void ) TEST_NAMED_TOPIC_STRING_DELETE_REJECTED }; - static const ShadowTopicStringType_t topicTypes[ ShadowTopicStringTypeMaxNum ] = - { - ShadowTopicStringTypeUpdate, - ShadowTopicStringTypeUpdateAccepted, - ShadowTopicStringTypeUpdateRejected, - ShadowTopicStringTypeUpdateDocuments, - ShadowTopicStringTypeUpdateDelta, - ShadowTopicStringTypeGet, - ShadowTopicStringTypeGetAccepted, - ShadowTopicStringTypeGetRejected, - ShadowTopicStringTypeDelete, - ShadowTopicStringTypeDeleteAccepted, - ShadowTopicStringTypeDeleteRejected - }; - - /* Call Shadow_AssembleTopicString() with valid parameters but bufferSize exceeds topic string length - * and verify result. */ + static const ShadowTopicStringType_t + topicTypes[ ShadowTopicStringTypeMaxNum ] = { + ShadowTopicStringTypeUpdate, + ShadowTopicStringTypeUpdateAccepted, + ShadowTopicStringTypeUpdateRejected, + ShadowTopicStringTypeUpdateDocuments, + ShadowTopicStringTypeUpdateDelta, + ShadowTopicStringTypeGet, + ShadowTopicStringTypeGetAccepted, + ShadowTopicStringTypeGetRejected, + ShadowTopicStringTypeDelete, + ShadowTopicStringTypeDeleteAccepted, + ShadowTopicStringTypeDeleteRejected + }; + + /* Call Shadow_AssembleTopicString() with valid parameters but bufferSize + * exceeds topic string length and verify result. */ shadowStatus = Shadow_AssembleTopicString( ShadowTopicStringTypeGetAccepted, TEST_THING_NAME, TEST_THING_NAME_LENGTH, @@ -803,8 +1048,8 @@ void test_Shadow_AssembleTopicString_Named_Happy_Path( void ) topicBufferExceeded, bufferSizeExceeded ); - /* Call Shadow_AssembleTopicString() with valid parameters, bufferSize = expected outLength - * and verify result. */ + /* Call Shadow_AssembleTopicString() with valid parameters, bufferSize = + * expected outLength and verify result. */ shadowStatus = Shadow_AssembleTopicString( ShadowTopicStringTypeGetAccepted, TEST_THING_NAME, TEST_THING_NAME_LENGTH, @@ -820,8 +1065,8 @@ void test_Shadow_AssembleTopicString_Named_Happy_Path( void ) for( index = 0U; index < ShadowTopicStringTypeMaxNum; index++ ) { - /* Call Shadow_AssembleTopicString() with valid parameters with all types of topic string - * and verify result. */ + /* Call Shadow_AssembleTopicString() with valid parameters with all + * types of topic string and verify result. */ shadowStatus = Shadow_AssembleTopicString( topicTypes[ index ], TEST_THING_NAME, TEST_THING_NAME_LENGTH, @@ -840,7 +1085,8 @@ void test_Shadow_AssembleTopicString_Named_Happy_Path( void ) /*-----------------------------------------------------------*/ /** - * @brief Tests the behavior of Shadow_AssembleTopicString() with invalid parameters + * @brief Tests the behavior of Shadow_AssembleTopicString() with invalid + * parameters */ void test_Shadow_AssembleTopicString_Invalid_Parameters( void ) { @@ -968,8 +1214,9 @@ void test_Shadow_AssembleTopicString_Invalid_Parameters( void ) /*-----------------------------------------------------------*/ /** - * @brief Tests the behavior of Shadow_MatchTopicString() for classic shadow with valid parameters. Tests Classic - * shadows through the deprecated legacy API Shadow_MatchTopic(). + * @brief Tests the behavior of Shadow_MatchTopicString() for classic shadow + * with valid parameters. Tests Classic shadows through the deprecated legacy + * API Shadow_MatchTopic(). */ void test_Shadow_MatchTopicString_Classic_Happy_Path( void ) { @@ -977,7 +1224,8 @@ void test_Shadow_MatchTopicString_Classic_Happy_Path( void ) ShadowMessageType_t messageType = ShadowMessageTypeMaxNum; const char * pThingName = NULL; uint16_t thingNameLength = 0U; - const char topicBuffer[ TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED ] = TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED; + const char topicBuffer[ TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED ] = + TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED; uint16_t bufferSize = TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED; /* Call Shadow_MatchTopic() with valid parameters and verify result. */ @@ -990,7 +1238,9 @@ void test_Shadow_MatchTopicString_Classic_Happy_Path( void ) TEST_ASSERT_EQUAL_INT( SHADOW_SUCCESS, shadowStatus ); TEST_ASSERT_EQUAL_INT( TEST_THING_NAME_LENGTH, thingNameLength ); TEST_ASSERT_EQUAL_INT( ShadowMessageTypeUpdateAccepted, messageType ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, pThingName, TEST_THING_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, + pThingName, + TEST_THING_NAME_LENGTH ); shadowStatus = Shadow_MatchTopic( &( topicBuffer[ 0 ] ), bufferSize, @@ -1008,7 +1258,9 @@ void test_Shadow_MatchTopicString_Classic_Happy_Path( void ) NULL ); TEST_ASSERT_EQUAL_INT( SHADOW_SUCCESS, shadowStatus ); TEST_ASSERT_EQUAL_INT( ShadowMessageTypeUpdateAccepted, messageType ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, pThingName, TEST_THING_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, + pThingName, + TEST_THING_NAME_LENGTH ); shadowStatus = Shadow_MatchTopic( &( topicBuffer[ 0 ] ), bufferSize, @@ -1020,7 +1272,8 @@ void test_Shadow_MatchTopicString_Classic_Happy_Path( void ) } /** - * @brief Tests the behavior of Shadow_MatchTopicString() for named shadows with valid parameters. + * @brief Tests the behavior of Shadow_MatchTopicString() for named shadows with + * valid parameters. */ void test_Shadow_MatchTopicString_Named_Happy_Path( void ) { @@ -1030,10 +1283,12 @@ void test_Shadow_MatchTopicString_Named_Happy_Path( void ) uint8_t thingNameLength = 0U; const char * pShadowName = NULL; uint8_t shadowNameLength = 0U; - const char topicBuffer[ TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED ] = TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED; + const char topicBuffer[ TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED ] = + TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED; uint16_t bufferSize = TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED; - /* Call Shadow_MatchTopicString() with valid parameters and verify result. */ + /* Call Shadow_MatchTopicString() with valid parameters and verify result. + */ shadowStatus = Shadow_MatchTopicString( &( topicBuffer[ 0 ] ), bufferSize, &messageType, @@ -1045,9 +1300,13 @@ void test_Shadow_MatchTopicString_Named_Happy_Path( void ) TEST_ASSERT_EQUAL_INT( SHADOW_SUCCESS, shadowStatus ); TEST_ASSERT_EQUAL_INT( TEST_THING_NAME_LENGTH, thingNameLength ); TEST_ASSERT_EQUAL_INT( ShadowMessageTypeUpdateAccepted, messageType ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, pThingName, TEST_THING_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, + pThingName, + TEST_THING_NAME_LENGTH ); TEST_ASSERT_EQUAL_INT( TEST_SHADOW_NAME_LENGTH, shadowNameLength ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_SHADOW_NAME, pShadowName, TEST_SHADOW_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_SHADOW_NAME, + pShadowName, + TEST_SHADOW_NAME_LENGTH ); shadowStatus = Shadow_MatchTopicString( &( topicBuffer[ 0 ] ), bufferSize, @@ -1059,9 +1318,13 @@ void test_Shadow_MatchTopicString_Named_Happy_Path( void ) TEST_ASSERT_EQUAL_INT( SHADOW_SUCCESS, shadowStatus ); TEST_ASSERT_EQUAL_INT( ShadowMessageTypeUpdateAccepted, messageType ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, pThingName, TEST_THING_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, + pThingName, + TEST_THING_NAME_LENGTH ); TEST_ASSERT_EQUAL_INT( TEST_SHADOW_NAME_LENGTH, shadowNameLength ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_SHADOW_NAME, pShadowName, TEST_SHADOW_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_SHADOW_NAME, + pShadowName, + TEST_SHADOW_NAME_LENGTH ); shadowStatus = Shadow_MatchTopicString( &( topicBuffer[ 0 ] ), bufferSize, @@ -1073,7 +1336,9 @@ void test_Shadow_MatchTopicString_Named_Happy_Path( void ) TEST_ASSERT_EQUAL_INT( SHADOW_SUCCESS, shadowStatus ); TEST_ASSERT_EQUAL_INT( TEST_THING_NAME_LENGTH, thingNameLength ); TEST_ASSERT_EQUAL_INT( ShadowMessageTypeUpdateAccepted, messageType ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, pThingName, TEST_THING_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, + pThingName, + TEST_THING_NAME_LENGTH ); TEST_ASSERT_EQUAL_INT( TEST_SHADOW_NAME_LENGTH, shadowNameLength ); shadowStatus = Shadow_MatchTopicString( &( topicBuffer[ 0 ] ), @@ -1086,8 +1351,12 @@ void test_Shadow_MatchTopicString_Named_Happy_Path( void ) TEST_ASSERT_EQUAL_INT( SHADOW_SUCCESS, shadowStatus ); TEST_ASSERT_EQUAL_INT( TEST_THING_NAME_LENGTH, thingNameLength ); TEST_ASSERT_EQUAL_INT( ShadowMessageTypeUpdateAccepted, messageType ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, pThingName, TEST_THING_NAME_LENGTH ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_SHADOW_NAME, pShadowName, TEST_SHADOW_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, + pThingName, + TEST_THING_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_SHADOW_NAME, + pShadowName, + TEST_SHADOW_NAME_LENGTH ); shadowStatus = Shadow_MatchTopicString( &( topicBuffer[ 0 ] ), bufferSize, @@ -1099,7 +1368,9 @@ void test_Shadow_MatchTopicString_Named_Happy_Path( void ) TEST_ASSERT_EQUAL_INT( SHADOW_SUCCESS, shadowStatus ); TEST_ASSERT_EQUAL_INT( TEST_THING_NAME_LENGTH, thingNameLength ); TEST_ASSERT_EQUAL_INT( ShadowMessageTypeUpdateAccepted, messageType ); - TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, pThingName, TEST_THING_NAME_LENGTH ); + TEST_ASSERT_EQUAL_STRING_LEN( TEST_THING_NAME, + pThingName, + TEST_THING_NAME_LENGTH ); } /*-----------------------------------------------------------*/ @@ -1116,9 +1387,11 @@ void test_Shadow_MatchTopicString_Invalid_Parameters( void ) uint8_t thingNameLength = 0U; const char * pShadowName = NULL; uint8_t shadowNameLength = 0U; - const char classicTopicBuffer[ TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED ] = TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED; + const char classicTopicBuffer[ TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED ] = + TEST_CLASSIC_TOPIC_STRING_UPDATE_ACCEPTED; uint16_t classicBufferSize = TEST_CLASSIC_TOPIC_LENGTH_UPDATE_ACCEPTED; - const char namedTopicBuffer[ TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED ] = TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED; + const char namedTopicBuffer[ TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED ] = + TEST_NAMED_TOPIC_STRING_UPDATE_ACCEPTED; uint16_t namedBufferSize = TEST_NAMED_TOPIC_LENGTH_UPDATE_ACCEPTED; /* Call Shadow_MatchTopicString() with various combinations of @@ -1177,22 +1450,24 @@ void test_Shadow_MatchTopicString_Invalid_Parameters( void ) &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_THINGNAME_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_TOPIC_STRING_UNTERMINATED_THINGNAME, - TEST_TOPIC_LENGTH_UNTERMINATED_THINGNAME, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_TOPIC_STRING_UNTERMINATED_THINGNAME, + TEST_TOPIC_LENGTH_UNTERMINATED_THINGNAME, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_THINGNAME_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_THING_NAME, - TEST_NAMED_TOPIC_LENGTH_EXCEEDS_MAX_THING_NAME, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_THING_NAME, + TEST_NAMED_TOPIC_LENGTH_EXCEEDS_MAX_THING_NAME, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_THINGNAME_PARSE_FAILED, shadowStatus ); shadowStatus = Shadow_MatchTopicString( TEST_TOPIC_STRING_EMPTY_SHADOW_ROOT, @@ -1204,103 +1479,114 @@ void test_Shadow_MatchTopicString_Invalid_Parameters( void ) &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_ROOT_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_TOPIC_STRING_INVALID_SHADOW_ROOT, - TEST_TOPIC_LENGTH_INVALID_SHADOW_ROOT, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_TOPIC_STRING_INVALID_SHADOW_ROOT, + TEST_TOPIC_LENGTH_INVALID_SHADOW_ROOT, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_ROOT_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_NAMED_TOPIC_STRING_EMPTY_SHADOWNAME, - TEST_NAMED_TOPIC_LENGTH_EMPTY_SHADOWNAME, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_NAMED_TOPIC_STRING_EMPTY_SHADOWNAME, + TEST_NAMED_TOPIC_LENGTH_EMPTY_SHADOWNAME, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_SHADOWNAME_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_NAMED_TOPIC_STRING_INVALID_SHADOWNAME, - TEST_NAMED_TOPIC_LENGTH_INVALID_SHADOWNAME, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_NAMED_TOPIC_STRING_INVALID_SHADOWNAME, + TEST_NAMED_TOPIC_LENGTH_INVALID_SHADOWNAME, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_SHADOWNAME_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_NAMED_TOPIC_STRING_UNTERMINATED_SHADOWNAME, - TEST_NAMED_TOPIC_LENGTH_UNTERMINATED_SHADOWNAME, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_NAMED_TOPIC_STRING_UNTERMINATED_SHADOWNAME, + TEST_NAMED_TOPIC_LENGTH_UNTERMINATED_SHADOWNAME, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_SHADOWNAME_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_SHADOW_NAME, - TEST_NAMED_TOPIC_LENGTH_EXCEEDS_MAX_SHADOW_NAME, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_NAMED_TOPIC_STRING_EXCEEDS_MAX_SHADOW_NAME, + TEST_NAMED_TOPIC_LENGTH_EXCEEDS_MAX_SHADOW_NAME, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_SHADOWNAME_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_CLASSIC_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE, - TEST_CLASSIC_TOPIC_LENGTH_EMPTY_SHADOW_MESSAGE_TYPE, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_CLASSIC_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE, + TEST_CLASSIC_TOPIC_LENGTH_EMPTY_SHADOW_MESSAGE_TYPE, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_MESSAGE_TYPE_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_NAMED_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE, - TEST_NAMED_TOPIC_LENGTH_EMPTY_SHADOW_MESSAGE_TYPE, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_NAMED_TOPIC_STRING_EMPTY_SHADOW_MESSAGE_TYPE, + TEST_NAMED_TOPIC_LENGTH_EMPTY_SHADOW_MESSAGE_TYPE, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_MESSAGE_TYPE_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_CLASSIC_TOPIC_STRING_INVALID_SHADOW_RESPONSE, - TEST_CLASSIC_TOPIC_LENGTH_INVALID_SHADOW_RESPONSE, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_CLASSIC_TOPIC_STRING_INVALID_SHADOW_RESPONSE, + TEST_CLASSIC_TOPIC_LENGTH_INVALID_SHADOW_RESPONSE, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_MESSAGE_TYPE_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_NAMED_TOPIC_STRING_INVALID_SHADOW_RESPONSE, - TEST_NAMED_TOPIC_LENGTH_INVALID_SHADOW_RESPONSE, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_NAMED_TOPIC_STRING_INVALID_SHADOW_RESPONSE, + TEST_NAMED_TOPIC_LENGTH_INVALID_SHADOW_RESPONSE, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_MESSAGE_TYPE_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_CLASSIC_TOPIC_STRING_INVALID_GET_REJECTED, - TEST_CLASSIC_TOPIC_LENGTH_INVALID_GET_REJECTED, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_CLASSIC_TOPIC_STRING_INVALID_GET_REJECTED, + TEST_CLASSIC_TOPIC_LENGTH_INVALID_GET_REJECTED, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_MESSAGE_TYPE_PARSE_FAILED, shadowStatus ); - shadowStatus = Shadow_MatchTopicString( TEST_NAMED_TOPIC_STRING_INVALID_GET_REJECTED, - TEST_NAMED_TOPIC_LENGTH_INVALID_GET_REJECTED, - &messageType, - &pThingName, - &thingNameLength, - &pShadowName, - &shadowNameLength ); + shadowStatus = Shadow_MatchTopicString( + TEST_NAMED_TOPIC_STRING_INVALID_GET_REJECTED, + TEST_NAMED_TOPIC_LENGTH_INVALID_GET_REJECTED, + &messageType, + &pThingName, + &thingNameLength, + &pShadowName, + &shadowNameLength ); TEST_ASSERT_EQUAL_INT( SHADOW_MESSAGE_TYPE_PARSE_FAILED, shadowStatus ); shadowStatus = Shadow_MatchTopicString( classicTopicBuffer,