]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/mqtt/iot_config_common.h
8d39bac4f47cb1658f4e5440630e0470ac245223
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_IoT_Libraries / mqtt / iot_config_common.h
1 /*\r
2  * Amazon FreeRTOS V201906.00 Major\r
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://aws.amazon.com/freertos\r
23  * http://www.FreeRTOS.org\r
24  */\r
25 \r
26 /* This file contains default configuration settings for the demos on FreeRTOS. */\r
27 \r
28 #ifndef IOT_CONFIG_COMMON_H_\r
29 #define IOT_CONFIG_COMMON_H_\r
30 \r
31 /* FreeRTOS include. */\r
32 #include "FreeRTOS.h" //_RB_Makes common config file FreeRTOS specific\r
33 \r
34 /* Use platform types on FreeRTOS. */\r
35 #include "platform/iot_platform_types_freertos.h" //_RB_Makes common config file FreeRTOS specific\r
36 \r
37 /* SDK version. */\r
38 #define IOT_SDK_VERSION    "4.0.0"\r
39 \r
40 /* This config file is for the demos; disable any test code. */\r
41 #define IOT_BUILD_TESTS    ( 0 )\r
42 \r
43 /* Logging puts function. */\r
44 #define IotLogging_Puts( str )                 configPRINTF( ( "%s\r\n", str ) )\r
45 \r
46 /* Enable asserts in libraries by default. */\r
47 #ifndef IOT_METRICS_ENABLE_ASSERTS\r
48     #define IOT_METRICS_ENABLE_ASSERTS         ( 1 )\r
49 #endif\r
50 #ifndef IOT_CONTAINERS_ENABLE_ASSERTS\r
51     #define IOT_CONTAINERS_ENABLE_ASSERTS      ( 1 )\r
52 #endif\r
53 #ifndef IOT_TASKPOOL_ENABLE_ASSERTS\r
54     #define IOT_TASKPOOL_ENABLE_ASSERTS        ( 1 )\r
55 #endif\r
56 #ifndef IOT_MQTT_ENABLE_ASSERTS\r
57     #define IOT_MQTT_ENABLE_ASSERTS            ( 1 )\r
58 #endif\r
59 #ifndef AWS_IOT_SHADOW_ENABLE_ASSERTS\r
60     #define AWS_IOT_SHADOW_ENABLE_ASSERTS      ( 1 )\r
61 #endif\r
62 #ifndef AWS_IOT_DEFENDER_ENABLE_ASSERTS\r
63     #define AWS_IOT_DEFENDER_ENABLE_ASSERTS    ( 1 )\r
64 #endif\r
65 #ifndef IOT_BLE_ENABLE_ASSERTS\r
66     #define IOT_BLE_ENABLE_ASSERTS             ( 1 )\r
67 #endif\r
68 \r
69 /* Assert functions. */\r
70 #define IotMetrics_Assert( expression )        configASSERT( expression )\r
71 #define IotContainers_Assert( expression )     configASSERT( expression )\r
72 #define IotTaskPool_Assert( expression )       configASSERT( expression )\r
73 #define IotMqtt_Assert( expression )           configASSERT( expression )\r
74 #define AwsIotShadow_Assert( expression )      configASSERT( expression )\r
75 #define AwsIotDefender_Assert( expression )    configASSERT( expression )\r
76 #define IotBle_Assert( expression )            configASSERT( expression )\r
77 \r
78 /* Control the usage of dynamic memory allocation. */\r
79 #ifndef IOT_STATIC_MEMORY_ONLY\r
80     #define IOT_STATIC_MEMORY_ONLY    ( 0 )\r
81 #endif\r
82 \r
83 /* Memory allocation configuration. Note that these functions will not be affected\r
84  * by IOT_STATIC_MEMORY_ONLY. */\r
85 #define IotNetwork_Malloc    pvPortMalloc\r
86 #define IotNetwork_Free      vPortFree\r
87 #define IotThreads_Malloc    pvPortMalloc\r
88 #define IotThreads_Free      vPortFree\r
89 #define IotLogging_Malloc    pvPortMalloc\r
90 #define IotLogging_Free      vPortFree\r
91 #define IotBle_Malloc        pvPortMalloc\r
92 #define IotBle_Free          vPortFree\r
93 /* #define IotLogging_StaticBufferSize */\r
94 \r
95 /* Memory allocation function configuration for the MQTT and Defender library.\r
96  * These libraries will be affected by IOT_STATIC_MEMORY_ONLY. */\r
97 #if IOT_STATIC_MEMORY_ONLY == 0\r
98     #define IotMetrics_MallocTcpConnection       pvPortMalloc\r
99     #define IotMetrics_FreeTcpConnection         vPortFree\r
100     #define IotMetrics_MallocIpAddress           pvPortMalloc\r
101     #define IotMetrics_FreeIpAddress             vPortFree\r
102 \r
103     #define IotTaskPool_MallocTaskPool           pvPortMalloc\r
104     #define IotTaskPool_FreeTaskPool             vPortFree\r
105     #define IotTaskPool_MallocJob                pvPortMalloc\r
106     #define IotTaskPool_FreeJob                  vPortFree\r
107     #define IotTaskPool_MallocTimerEvent         pvPortMalloc\r
108     #define IotTaskPool_FreeTimerEvent           vPortFree\r
109 \r
110     #define IotMqtt_MallocConnection             pvPortMalloc\r
111     #define IotMqtt_FreeConnection               vPortFree\r
112     #define IotMqtt_MallocMessage                pvPortMalloc\r
113     #define IotMqtt_FreeMessage                  vPortFree\r
114     #define IotMqtt_MallocOperation              pvPortMalloc\r
115     #define IotMqtt_FreeOperation                vPortFree\r
116     #define IotMqtt_MallocSubscription           pvPortMalloc\r
117     #define IotMqtt_FreeSubscription             vPortFree\r
118 \r
119     #define IotSerializer_MallocCborEncoder      pvPortMalloc\r
120     #define IotSerializer_FreeCborEncoder        vPortFree\r
121     #define IotSerializer_MallocCborParser       pvPortMalloc\r
122     #define IotSerializer_FreeCborParser         vPortFree\r
123     #define IotSerializer_MallocCborValue        pvPortMalloc\r
124     #define IotSerializer_FreeCborValue          vPortFree\r
125     #define IotSerializer_MallocDecoderObject    pvPortMalloc\r
126     #define IotSerializer_FreeDecoderObject      vPortFree\r
127 \r
128     #define AwsIotShadow_MallocOperation         pvPortMalloc\r
129     #define AwsIotShadow_FreeOperation           vPortFree\r
130     #define AwsIotShadow_MallocString            pvPortMalloc\r
131     #define AwsIotShadow_FreeString              vPortFree\r
132     #define AwsIotShadow_MallocSubscription      pvPortMalloc\r
133     #define AwsIotShadow_FreeSubscription        vPortFree\r
134 \r
135     #define AwsIotDefender_MallocReport          pvPortMalloc\r
136     #define AwsIotDefender_FreeReport            vPortFree\r
137     #define AwsIotDefender_MallocTopic           pvPortMalloc\r
138     #define AwsIotDefender_FreeTopic             vPortFree\r
139 #endif /* if IOT_STATIC_MEMORY_ONLY == 0 */\r
140 \r
141 /* Default platform thread stack size and priority. */\r
142 #ifndef IOT_THREAD_DEFAULT_STACK_SIZE\r
143     #define IOT_THREAD_DEFAULT_STACK_SIZE    2048\r
144 #endif\r
145 #ifndef IOT_THREAD_DEFAULT_PRIORITY\r
146     #define IOT_THREAD_DEFAULT_PRIORITY      tskIDLE_PRIORITY\r
147 #endif\r
148 \r
149 /* Platform network configuration. */\r
150 #ifndef IOT_NETWORK_RECEIVE_TASK_PRIORITY\r
151     #define IOT_NETWORK_RECEIVE_TASK_PRIORITY      ( tskIDLE_PRIORITY + 1 )\r
152 #endif\r
153 #ifndef IOT_NETWORK_RECEIVE_TASK_STACK_SIZE\r
154     #define IOT_NETWORK_RECEIVE_TASK_STACK_SIZE    IOT_THREAD_DEFAULT_STACK_SIZE\r
155 #endif\r
156 \r
157 /* Platform and SDK name for AWS IoT MQTT metrics. Only used when\r
158  * AWS_IOT_MQTT_ENABLE_METRICS is 1. */\r
159 #define IOT_SDK_NAME             "AmazonFreeRTOS"\r
160 #ifdef configPLATFORM_NAME\r
161     #define IOT_PLATFORM_NAME    configPLATFORM_NAME\r
162 #else\r
163     #define IOT_PLATFORM_NAME    "Unknown"\r
164 #endif\r
165 \r
166 /* Cloud endpoint to which the device connects to. */\r
167 #define IOT_CLOUD_ENDPOINT                    clientcredentialMQTT_BROKER_ENDPOINT\r
168 \r
169 /**\r
170  * @brief Unique identifier used to recognize a device by the cloud.\r
171  * This could be SHA-256 of the device certificate.\r
172  */\r
173 extern const char *getDeviceIdentifier( void );\r
174 #define IOT_DEVICE_IDENTIFIER                getDeviceIdentifier()\r
175 \r
176 /**\r
177  * @brief Metrics emitted by the device.\r
178  */\r
179 extern const char *getDeviceMetrics( void );\r
180 #define AWS_IOT_METRICS_USERNAME     getDeviceMetrics()\r
181 \r
182 /**\r
183  * @brief Length of the metrics emitted by device.\r
184  */\r
185 extern uint16_t getDeviceMetricsLength( void );\r
186 #define AWS_IOT_METRICS_USERNAME_LENGTH getDeviceMetricsLength()\r
187 \r
188 /* Define the data type of metrics connection id as same as Socket_t in aws_secure_socket.h */\r
189 #define IotMetricsConnectionId_t            void *\r
190 \r
191 /* Configuration for defender demo: set format to CBOR. */\r
192 #define AWS_IOT_DEFENDER_FORMAT             AWS_IOT_DEFENDER_FORMAT_CBOR\r
193 \r
194 /* Configuration for defender demo: use long tag for readable output. Please use short tag for the real application. */\r
195 #define AWS_IOT_DEFENDER_USE_LONG_TAG       ( 1 )\r
196 \r
197 /* Demo runner configuration. */\r
198 //_RB_#include "aws_demo_config.h"\r
199 \r
200 #endif /* ifndef IOT_CONFIG_COMMON_H_ */\r