]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries/c_sdk/standard/mqtt/include/iot_mqtt_agent_config_defaults.h
Correct an err in queue.c introduced when previously updating behaviour when queue...
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-IoT-Libraries / c_sdk / standard / mqtt / include / iot_mqtt_agent_config_defaults.h
1 /*\r
2  * Amazon FreeRTOS MQTT V2.0.0\r
3  * Copyright (C) 2018 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 /**\r
27  * @file iot_mqtt_agent_config_defaults.h\r
28  * @brief MQTT agent default config options.\r
29  *\r
30  * Ensures that the config options for MQTT agent are set to sensible\r
31  * default values if the user does not provide one.\r
32  */\r
33 \r
34 #ifndef _AWS_MQTT_AGENT_CONFIG_DEFAULTS_H_\r
35 #define _AWS_MQTT_AGENT_CONFIG_DEFAULTS_H_\r
36 \r
37 /* FreeRTOS includes. */\r
38 #include "FreeRTOS.h"\r
39 #include "task.h"\r
40 \r
41 /**\r
42  * @brief Controls whether or not to report usage metrics to the\r
43  * AWS IoT broker.\r
44  *\r
45  * If mqttconfigENABLE_METRICS is set to 1, a string containing\r
46  * metric information will be included in the "username" field of\r
47  * the MQTT connect messages.\r
48  */\r
49 #ifndef mqttconfigENABLE_METRICS\r
50     #define mqttconfigENABLE_METRICS    ( 1 )\r
51 #endif\r
52 \r
53 /**\r
54  * @brief The maximum time interval in seconds allowed to elapse between 2 consecutive\r
55  * control packets.\r
56  */\r
57 #ifndef mqttconfigKEEP_ALIVE_INTERVAL_SECONDS\r
58     #define mqttconfigKEEP_ALIVE_INTERVAL_SECONDS    ( 1200 )\r
59 #endif\r
60 \r
61 /**\r
62  * @brief Defines the frequency at which the client should send Keep Alive messages.\r
63  *\r
64  * Even though the maximum time allowed between 2 consecutive control packets\r
65  * is defined by the mqttconfigKEEP_ALIVE_INTERVAL_SECONDS macro, the user\r
66  * can and should send Keep Alive messages at a slightly faster rate to ensure\r
67  * that the connection is not closed by the server because of network delays.\r
68  * This macro defines the interval of inactivity after which a keep alive messages\r
69  * is sent.\r
70  */\r
71 #ifndef mqttconfigKEEP_ALIVE_ACTUAL_INTERVAL_TICKS\r
72     #define mqttconfigKEEP_ALIVE_ACTUAL_INTERVAL_TICKS    ( 5000 )\r
73 #endif\r
74 \r
75 /**\r
76  * @brief The maximum interval in ticks to wait for PINGRESP.\r
77  *\r
78  * If PINGRESP is not received within this much time after sending PINGREQ,\r
79  * the client assumes that the PINGREQ timed out.\r
80  */\r
81 #ifndef mqttconfigKEEP_ALIVE_TIMEOUT_TICKS\r
82     #define mqttconfigKEEP_ALIVE_TIMEOUT_TICKS    ( 1000 )\r
83 #endif\r
84 \r
85 /**\r
86  * @brief The maximum time in ticks for which the MQTT task is permitted to block.\r
87  *\r
88  * The MQTT task blocks until the user initiates any action or until it receives\r
89  * any data from the broker. This macro controls the maximum time the MQTT task can\r
90  * block. It should be set to a small number for the platforms which do not have any\r
91  * mechanism to wake up the MQTT task whenever data is received on a connected socket.\r
92  * This ensures that the MQTT task keeps waking up frequently and processes the publish\r
93  * messages received from the broker, if any.\r
94  *\r
95  * If the platform's secure_sockets layer supports SOCKETS_SO_WAKEUP_CALLBACK i.e.\r
96  * the MQTT task can wake up whenever data is received on a connected socket, this\r
97  * value should be set to maximum value:\r
98  * #define  #define mqttconfigMQTT_TASK_MAX_BLOCK_TICKS    ( ~( ( uint32_t ) 0 ) )\r
99  *\r
100  * If the platform's secure_sockets layer does not support SOCKETS_SO_WAKEUP_CALLBACK\r
101  * i.e. the MQTT task cannot wake up whenever data is received on a connected socket,\r
102  * this value should be set to a small number:\r
103  * #define mqttconfigMQTT_TASK_MAX_BLOCK_TICKS             ( 100 )\r
104  */\r
105 #ifndef mqttconfigMQTT_TASK_MAX_BLOCK_TICKS\r
106     #error "mqttconfigMQTT_TASK_MAX_BLOCK_TICKS must be defined in iot_mqtt_agent_config.h."\r
107 #endif\r
108 \r
109 /**\r
110  * @defgroup MQTTTask MQTT task configuration parameters.\r
111  */\r
112 /** @{ */\r
113 #ifndef mqttconfigMQTT_TASK_STACK_DEPTH\r
114     #define mqttconfigMQTT_TASK_STACK_DEPTH    ( configMINIMAL_STACK_SIZE * 4 )\r
115 #endif\r
116 \r
117 #ifndef mqttconfigMQTT_TASK_PRIORITY\r
118     #define mqttconfigMQTT_TASK_PRIORITY    ( tskIDLE_PRIORITY )\r
119 #endif\r
120 /** @} */\r
121 \r
122 /**\r
123  * @brief Maximum number of MQTT clients that can exist simultaneously.\r
124  */\r
125 #ifndef mqttconfigMAX_BROKERS\r
126     #define mqttconfigMAX_BROKERS    ( 1 )\r
127 #endif\r
128 \r
129 /**\r
130  * @brief Maximum number of parallel operations per client.\r
131  */\r
132 #ifndef mqttconfigMAX_PARALLEL_OPS\r
133     #define mqttconfigMAX_PARALLEL_OPS    ( 5 )\r
134 #endif\r
135 \r
136 /**\r
137  * @brief Time in milliseconds after which the TCP send operation should timeout.\r
138  */\r
139 #ifndef mqttconfigTCP_SEND_TIMEOUT_MS\r
140     #define mqttconfigTCP_SEND_TIMEOUT_MS    ( 2000 )\r
141 #endif\r
142 \r
143 /**\r
144  * @brief Length of the buffer used to receive data.\r
145  */\r
146 #ifndef mqttconfigRX_BUFFER_SIZE\r
147     #define mqttconfigRX_BUFFER_SIZE    ( 1024 )\r
148 #endif\r
149 \r
150 /**\r
151  * @defgroup BufferPoolInterface The functions used by the MQTT client to get and return buffers.\r
152  *\r
153  * The MQTT client needs buffers for both transmitting and receiving messages.\r
154  * Whenever it needs a buffer, it invokes mqttconfigGET_FREE_BUFFER_FXN function to get\r
155  * a buffer and after it is done it invokes mqttconfigRETURN_BUFFER_FXN to return the\r
156  * buffer. By default, BUFFERPOOL_GetFreeBuffer and BUFFERPOOL_ReturnBuffer functions are\r
157  * used to get and return buffers from the central buffer pool. The user can change the\r
158  * buffer management functions for MQTT client by defining mqttconfigGET_FREE_BUFFER_FXN\r
159  * and mqttconfigRETURN_BUFFER_FXN macros. The user should implement the two functions\r
160  * having signatures same as BUFFERPOOL_GetFreeBuffer and BUFFERPOOL_ReturnBuffer and then\r
161  * define the macros in BufferPoolConfig.h:\r
162  * @code\r
163  * uint8_t* UserDefined_GetFreeBuffer( uint32_t *pulBufferLength );\r
164  * void UserDefined_ReturnBuffer( uint8_t * const pucBuffer );\r
165  *\r
166  * #define mqttconfigGET_FREE_BUFFER_FXN       UserDefined_GetFreeBuffer\r
167  * #define mqttconfigRETURN_BUFFER_FXN         UserDefined_ReturnBuffer\r
168  * @endcode\r
169  */\r
170 /** @{ */\r
171 #ifndef mqttconfigGET_FREE_BUFFER_FXN\r
172     #define mqttconfigGET_FREE_BUFFER_FXN    BUFFERPOOL_GetFreeBuffer\r
173 #endif\r
174 \r
175 #ifndef mqttconfigRETURN_BUFFER_FXN\r
176     #define mqttconfigRETURN_BUFFER_FXN    BUFFERPOOL_ReturnBuffer\r
177 #endif\r
178 /** @} */\r
179 \r
180 #endif /* _AWS_MQTT_AGENT_CONFIG_DEFAULTS_H_ */\r