diff --git a/demos/demo_runner/iot_demo_freertos.c b/demos/demo_runner/iot_demo_freertos.c index 73b4d2ff3..35864b340 100644 --- a/demos/demo_runner/iot_demo_freertos.c +++ b/demos/demo_runner/iot_demo_freertos.c @@ -41,7 +41,7 @@ #include "iot_init.h" /* Remove dependency to MQTT */ -#if ( defined( CONFIG_MQTT_DEMO_ENABLED ) || defined( CONFIG_SHADOW_DEMO_ENABLED ) || defined( CONFIG_DEFENDER_DEMO_ENABLED ) || defined( CONFIG_OTA_UPDATE_DEMO_ENABLED ) ) +#if ( defined( CONFIG_MQTT_DEMO_ENABLED ) || defined( CONFIG_SHADOW_DEMO_ENABLED ) || defined( CONFIG_DEFENDER_DEMO_ENABLED ) || defined( CONFIG_OTA_UPDATE_DEMO_ENABLED ) || defined( CONFIG_AIA_DEMO_ENABLED ) ) #define MQTT_DEMO_TYPE_ENABLED #endif diff --git a/demos/include/iot_demo_runner.h b/demos/include/iot_demo_runner.h index 4e189acca..e44c86b73 100644 --- a/demos/include/iot_demo_runner.h +++ b/demos/include/iot_demo_runner.h @@ -102,6 +102,16 @@ #define DEMO_entryFUNCTION RunHttpsSyncUploadDemo #elif defined( CONFIG_HTTPS_ASYNC_UPLOAD_DEMO_ENABLED ) #define DEMO_entryFUNCTION RunHttpsAsyncUploadDemo +#elif defined ( CONFIG_AIA_DEMO_ENABLED ) + #define DEMO_entryFUNCTION RunAiaDemo + #if defined ( democonfigAia_DEMO_TASK_STACK_SIZE ) + #undef democonfigDEMO_STACKSIZE + #define democonfigDEMO_STACKSIZE democonfigAia_DEMO_TASK_STACK_SIZE + #endif + #if defined( democonfigAia_DEMO_TASK_TASK_PRIORITY ) + #undef democonfigDEMO_PRIORITY + #define democonfigDEMO_PRIORITY democonfigAia_DEMO_TASK_TASK_PRIORITY + #endif #else /* if defined( CONFIG_MQTT_DEMO_ENABLED ) */ /* if no demo was defined there will be no entry point defined and we will not be able to run the demo */ #error "No demo to run. One demo should be enabled" diff --git a/libraries/3rdparty/mbedtls_config/aws_mbedtls_config.h b/libraries/3rdparty/mbedtls_config/aws_mbedtls_config.h index c7d8c76f7..00dc3cbdb 100644 --- a/libraries/3rdparty/mbedtls_config/aws_mbedtls_config.h +++ b/libraries/3rdparty/mbedtls_config/aws_mbedtls_config.h @@ -783,7 +783,7 @@ //#define MBEDTLS_ECP_DP_BP256R1_ENABLED //#define MBEDTLS_ECP_DP_BP384R1_ENABLED //#define MBEDTLS_ECP_DP_BP512R1_ENABLED -//#define MBEDTLS_ECP_DP_CURVE25519_ENABLED +#define MBEDTLS_ECP_DP_CURVE25519_ENABLED //#define MBEDTLS_ECP_DP_CURVE448_ENABLED /** @@ -2358,7 +2358,7 @@ * * This module enables mbedtls_strerror(). */ -//#define MBEDTLS_ERROR_C +#define MBEDTLS_ERROR_C /** * \def MBEDTLS_GCM_C @@ -2410,7 +2410,7 @@ * This module adds support for the Hashed Message Authentication Code * (HMAC)-based key derivation function (HKDF). */ -//#define MBEDTLS_HKDF_C +#define MBEDTLS_HKDF_C /** * \def MBEDTLS_HMAC_DRBG_C diff --git a/libraries/c_sdk/standard/serializer/src/iot_json_utils.c b/libraries/c_sdk/standard/serializer/src/iot_json_utils.c index 8dcbcd84f..e327d667f 100644 --- a/libraries/c_sdk/standard/serializer/src/iot_json_utils.c +++ b/libraries/c_sdk/standard/serializer/src/iot_json_utils.c @@ -37,6 +37,9 @@ /* JSON utilities include. */ #include "iot_json_utils.h" +#define IS_QUOTE( str, idx ) \ + ( ( str )[ ( idx ) ] == '"' && ( ( idx ) == 0 || ( str )[ ( idx ) - 1 ] != '\\' ) ) + /*-----------------------------------------------------------*/ bool IotJsonUtils_FindJsonValue( const char * pJsonDocument, @@ -50,6 +53,7 @@ bool IotJsonUtils_FindJsonValue( const char * pJsonDocument, size_t jsonValueLength = 0; char openCharacter = '\0', closeCharacter = '\0'; int nestingLevel = 0; + bool isWithinQuotes = false; /* Ensure the JSON document is long enough to contain the key/value pair. At * the very least, a JSON key/value pair must contain the key and the 6 @@ -215,20 +219,40 @@ bool IotJsonUtils_FindJsonValue( const char * pJsonDocument, /* Skip the opening character. */ i++; + /* If the end of the document is reached, this isn't a match. */ + if( i >= jsonDocumentLength ) + { + return false; + } + /* Add the length of all characters in the JSON object or array. This * includes the length of nested objects. */ while( pJsonDocument[ i ] != closeCharacter || - ( pJsonDocument[ i ] == closeCharacter && nestingLevel != 0 ) ) + ( pJsonDocument[ i ] == closeCharacter && ( nestingLevel != 0 || isWithinQuotes ) ) ) { - /* An opening character starts a nested object. */ - if( pJsonDocument[ i ] == openCharacter ) + /* Check if its a quote so as to avoid considering the + * nested levels for opening and closing characters within + * quotes. + */ + if( IS_QUOTE( pJsonDocument, i ) ) { - nestingLevel++; + /*Toggle the flag*/ + isWithinQuotes = !isWithinQuotes; } - /* A closing character ends a nested object. */ - else if( pJsonDocument[ i ] == closeCharacter ) + + /* Calculate the nesting levels only if not in quotes. */ + if( !isWithinQuotes ) { - nestingLevel--; + /* An opening character starts a nested object. */ + if( pJsonDocument[ i ] == openCharacter ) + { + nestingLevel++; + } + /* A closing character ends a nested object. */ + else if( pJsonDocument[ i ] == closeCharacter ) + { + nestingLevel--; + } } i++; diff --git a/vendors/pc/boards/windows/aws_demos/config_files/aws_demo_config.h b/vendors/pc/boards/windows/aws_demos/config_files/aws_demo_config.h index 46e09c9e1..c7f95c18d 100644 --- a/vendors/pc/boards/windows/aws_demos/config_files/aws_demo_config.h +++ b/vendors/pc/boards/windows/aws_demos/config_files/aws_demo_config.h @@ -54,6 +54,8 @@ #define democonfigSHADOW_DEMO_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 4 ) #define democonfigSHADOW_DEMO_TASK_PRIORITY ( tskIDLE_PRIORITY + 5 ) #define shadowDemoUPDATE_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 5 ) +#define democonfigAia_DEMO_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 20 ) +#define democonfigAia_DEMO_TASK_TASK_PRIORITY ( tskIDLE_PRIORITY + 5 ) #define democonfigMQTT_ECHO_TLS_NEGOTIATION_TIMEOUT pdMS_TO_TICKS( 12000 ) #define democonfigMQTT_ECHO_TASK_PRIORITY ( tskIDLE_PRIORITY )