From 180ed6cc89e6b6b0da00157a9c64e7606152f791 Mon Sep 17 00:00:00 2001 From: gaurav-aws Date: Tue, 23 Jul 2019 18:20:06 +0000 Subject: Cosmetic changes in the MQTT demo - Fix warnings in the MQTT code. - Update comments in the iot_config.h. git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@2702 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../FreeRTOS_IoT_Libraries/mqtt/FreeRTOSIPConfig.h | 2 +- .../Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj | 2 +- .../Demo/FreeRTOS_IoT_Libraries/mqtt/iot_config.h | 65 ++++++++++++++-------- .../Demo/FreeRTOS_IoT_Libraries/mqtt/main.c | 4 +- .../c_sdk/standard/mqtt/src/iot_mqtt_operation.c | 5 +- .../standard/mqtt/src/iot_mqtt_subscription.c | 31 +++++------ 6 files changed, 63 insertions(+), 46 deletions(-) (limited to 'FreeRTOS-Plus') diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/FreeRTOSIPConfig.h b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/FreeRTOSIPConfig.h index 563f0cb09..4729ef107 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/FreeRTOSIPConfig.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/FreeRTOSIPConfig.h @@ -146,7 +146,7 @@ stack will revert to using the static IP address even when ipconfigUSE_DHCP is set to 1 if a valid configuration cannot be obtained from a DHCP server for any reason. The static configuration used is that passed into the stack by the FreeRTOS_IPInit() function call. */ -#define ipconfigUSE_DHCP 0 +#define ipconfigUSE_DHCP 1 /* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at increasing time intervals until either a reply is received from a DHCP server diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj index 329a1129b..f2157c813 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj +++ b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/WIN32.vcxproj @@ -71,7 +71,7 @@ true false EditAndContinue - /wd4210 /wd4127 /wd4214 /wd4201 /wd4244 /wd4310 %(AdditionalOptions) + /wd4210 /wd4127 /wd4214 /wd4201 /wd4244 /wd4310 /wd4200 %(AdditionalOptions) true NotUsing false diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/iot_config.h b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/iot_config.h index a326f471e..1f9568618 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/iot_config.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/iot_config.h @@ -28,27 +28,29 @@ #include "FreeRTOS.h" #include "platform/iot_platform_types_freertos.h" //_RB_Makes common config file FreeRTOS specific -/* - * Set this to the number of recyclable tasks for the task pool to cache. +/** + * @brief The number of recyclable jobs for the task pool to cache. * - * Caching dynamically allocated tasks (recyclable tasks) helps the application - * to limit the number of allocations at runtime. Caching recyclable tasks may + * Caching dynamically allocated jobs (recyclable jobs) helps the application + * to limit the number of allocations at runtime. Caching recyclable jobs may * help making the application more responsive and predictable, by removing a * potential for memory allocation failures, but it may also have negative * repercussions on the amount of memory available at any given time. It is up - * to the application developer to strike the correct balance these competing - * needs. The task pool will cache when the application calling - * IotTaskPool_RecycleJob. Any recycled tasks in excess of + * to the application developer to strike the correct balance among these + * competing needs. The task pool will cache a job when the application calls + * IotTaskPool_RecycleJob on a job which was created using + * IotTaskPool_CreateRecyclableJob API. Any recycled jobs in excess of * IOT_TASKPOOL_JOBS_RECYCLE_LIMIT will be destroyed and its memory will be - * release. + * released. * * Default value (if undefined): 8 */ -#define IOT_TASKPOOL_JOBS_RECYCLE_LIMIT 8 +#define IOT_TASKPOOL_JOBS_RECYCLE_LIMIT 8 -/* +/** + * @brief Enable/Disable asserts for the task pool library. + * * Set this to 1 to perform sanity checks when using the task pool library. - * * Asserts are useful for debugging, but should be disabled in production code. * If this is set to 1, IotTaskPool_Assert can be defined to set the assertion * function; otherwise, the standard library's assert function will be used. @@ -57,10 +59,10 @@ * Recommended values: 1 when debugging; 0 in production code. * Default value (if undefined): 0 */ -#define IOT_TASKPOOL_ENABLE_ASSERTS 1 +#define IOT_TASKPOOL_ENABLE_ASSERTS 1 -/* - * Set the log level of the task pool library. +/** + * @brief Set the log level of the task pool library. * * Log messages from the task pool library at or below this setting will be * printed. @@ -69,22 +71,37 @@ * Default value (if undefined): IOT_LOG_LEVEL_GLOBAL; if that is undefined, * then IOT_LOG_NONE. */ -#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_INFO +#define IOT_LOG_LEVEL_TASKPOOL IOT_LOG_INFO -/* - * +/** + * @brief The number of worker tasks in the task pool. + * + * The minimal version of the of task pool library only supports one task pool + * and the number of the worker tasks is fixed at the compile time. */ -#define IOT_TASKPOOL_NUMBER_OF_WORKERS 3 +#define IOT_TASKPOOL_NUMBER_OF_WORKERS 3 -/* - * +/** + * @brief The stack size (in bytes) for each worker task in the task pool. + * + * The minimal version of the of task pool library only supports one task pool + * and the configuration of each worker task fixed at the compile time. */ -#define IOT_TASKPOOL_WORKER_STACK_SIZE_BYTES 2048 +#define IOT_TASKPOOL_WORKER_STACK_SIZE_BYTES 2048 -/* How long the MQTT library will wait for PINGRESPs or PUBACKs. */ -#define IOT_MQTT_RESPONSE_WAIT_MS ( 10000 ) +/** + * @brief The amount of time the MQTT library waits for responses (PINGRESPs or + * PUBACKs) from the MQTT broker. + */ +#define IOT_MQTT_RESPONSE_WAIT_MS ( 10000 ) -#define AWS_IOT_MQTT_ENABLE_METRICS 0 +/** + * @brief Enable/Disable anonymous metrics collection when using AWS IoT. + * + * This demo does not support TLS and so does not work with AWS IoT. Therefore, + * the metric collection must be disabled. + */ +#define AWS_IOT_MQTT_ENABLE_METRICS 0 /* Include the common configuration file for FreeRTOS. */ #include "iot_config_common.h" diff --git a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/main.c b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/main.c index 5b0f4e132..5b6c054fb 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/main.c @@ -65,8 +65,8 @@ environment. mainCREATE_SIMPLE_MQTT_EXAMPLE_TASKS: TBD */ -#define mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS 1 -#define mainCREATE_SIMPLE_MQTT_EXAMPLE_TASKS 0 +#define mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS 0 +#define mainCREATE_SIMPLE_MQTT_EXAMPLE_TASKS 1 /* Simple UDP client and server task parameters. */ #define mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY ) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries/c_sdk/standard/mqtt/src/iot_mqtt_operation.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries/c_sdk/standard/mqtt/src/iot_mqtt_operation.c index bfe08d7b2..9e4ec282e 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries/c_sdk/standard/mqtt/src/iot_mqtt_operation.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries/c_sdk/standard/mqtt/src/iot_mqtt_operation.c @@ -1105,7 +1105,10 @@ _mqttOperation_t * _IotMqtt_FindOperation( _mqttConnection_t * pMqttConnection, IotTaskPoolError_t taskPoolStatus = IOT_TASKPOOL_SUCCESS; _mqttOperation_t * pResult = NULL; IotLink_t * pResultLink = NULL; - _operationMatchParam_t param = { .type = type, .pPacketIdentifier = pPacketIdentifier }; + _operationMatchParam_t param = { 0 }; + + param.type = type; + param.pPacketIdentifier = pPacketIdentifier; if( pPacketIdentifier != NULL ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c index 99664de05..59caccc7f 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c @@ -406,12 +406,11 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection, void ( * callbackFunction )( void *, IotMqttCallbackParam_t * ) = NULL; - _topicMatchParams_t topicMatchParams = - { - .pTopicName = pCallbackParam->u.message.info.pTopicName, - .topicNameLength = pCallbackParam->u.message.info.topicNameLength, - .exactMatchOnly = false - }; + _topicMatchParams_t topicMatchParams = { 0 }; + + topicMatchParams.pTopicName = pCallbackParam->u.message.info.pTopicName; + topicMatchParams.topicNameLength = pCallbackParam->u.message.info.topicNameLength; + topicMatchParams.exactMatchOnly = false; /* Prevent any other thread from modifying the subscription list while this * function is searching. */ @@ -508,11 +507,10 @@ void _IotMqtt_RemoveSubscriptionByPacket( _mqttConnection_t * pMqttConnection, uint16_t packetIdentifier, int32_t order ) { - const _packetMatchParams_t packetMatchParams = - { - .packetIdentifier = packetIdentifier, - .order = order - }; + _packetMatchParams_t packetMatchParams = { 0 }; + + packetMatchParams.packetIdentifier = packetIdentifier; + packetMatchParams.order = order; IotMutex_Lock( &( pMqttConnection->subscriptionMutex ) ); IotListDouble_RemoveAllMatches( &( pMqttConnection->subscriptionList ), @@ -593,12 +591,11 @@ bool IotMqtt_IsSubscribed( IotMqttConnection_t mqttConnection, bool status = false; _mqttSubscription_t * pSubscription = NULL; IotLink_t * pSubscriptionLink = NULL; - _topicMatchParams_t topicMatchParams = - { - .pTopicName = pTopicFilter, - .topicNameLength = topicFilterLength, - .exactMatchOnly = true - }; + _topicMatchParams_t topicMatchParams = { 0 }; + + topicMatchParams.pTopicName = pTopicFilter; + topicMatchParams.topicNameLength = topicFilterLength; + topicMatchParams.exactMatchOnly = false; /* Prevent any other thread from modifying the subscription list while this * function is running. */ -- cgit v1.2.1