core_mqtt_config_defaults.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * coreMQTT <DEVELOPMENT BRANCH>
  3. * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * SPDX-License-Identifier: MIT
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  8. * this software and associated documentation files (the "Software"), to deal in
  9. * the Software without restriction, including without limitation the rights to
  10. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  11. * the Software, and to permit persons to whom the Software is furnished to do so,
  12. * subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  19. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  20. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  21. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. /**
  25. * @file core_mqtt_config_defaults.h
  26. * @brief This represents the default values for the configuration macros
  27. * for the MQTT library.
  28. *
  29. * @note This file SHOULD NOT be modified. If custom values are needed for
  30. * any configuration macro, a core_mqtt_config.h file should be provided to
  31. * the MQTT library to override the default values defined in this file.
  32. * To use the custom config file, the MQTT_DO_NOT_USE_CUSTOM_CONFIG preprocessor
  33. * macro SHOULD NOT be set.
  34. */
  35. #ifndef CORE_MQTT_CONFIG_DEFAULTS_H_
  36. #define CORE_MQTT_CONFIG_DEFAULTS_H_
  37. /* *INDENT-OFF* */
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* *INDENT-ON* */
  42. /* MQTT_DO_NOT_USE_CUSTOM_CONFIG allows building the MQTT library
  43. * without a custom config. If a custom config is provided, the
  44. * MQTT_DO_NOT_USE_CUSTOM_CONFIG macro should not be defined. */
  45. #define MQTT_DO_NOT_USE_CUSTOM_CONFIG
  46. #ifndef MQTT_DO_NOT_USE_CUSTOM_CONFIG
  47. /* Include custom config file before other headers. */
  48. #include "core_mqtt_config.h"
  49. #endif
  50. /* The macro definition for MQTT_DO_NOT_USE_CUSTOM_CONFIG is for Doxygen
  51. * documentation only. */
  52. /**
  53. * @brief Define this macro to build the MQTT library without the custom config
  54. * file core_mqtt_config.h.
  55. *
  56. * Without the custom config, the MQTT library builds with
  57. * default values of config macros defined in core_mqtt_config_defaults.h file.
  58. *
  59. * If a custom config is provided, then MQTT_DO_NOT_USE_CUSTOM_CONFIG should not
  60. * be defined.
  61. */
  62. #ifdef DOXYGEN
  63. #define MQTT_DO_NOT_USE_CUSTOM_CONFIG
  64. #endif
  65. /**
  66. * @ingroup mqtt_constants
  67. * @brief Maximum number of vectors in subscribe and unsubscribe packet.
  68. */
  69. #ifndef MQTT_SUB_UNSUB_MAX_VECTORS
  70. #define MQTT_SUB_UNSUB_MAX_VECTORS ( 4U )
  71. #endif
  72. /**
  73. * @brief The number of retries for receiving CONNACK.
  74. *
  75. * The MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT will be used only when the
  76. * timeoutMs parameter of #MQTT_Connect is passed as 0 . The transport
  77. * receive for CONNACK will be retried MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT
  78. * times before timing out. A value of 0 for this config will cause the
  79. * transport receive for CONNACK to be invoked only once.
  80. *
  81. * <b>Possible values:</b> Any positive 16 bit integer. <br>
  82. * <b>Default value:</b> `5`
  83. */
  84. #ifndef MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT
  85. /* Default value for the CONNACK receive retries. */
  86. #define MQTT_MAX_CONNACK_RECEIVE_RETRY_COUNT ( 5U )
  87. #endif
  88. /**
  89. * @brief Maximum number of milliseconds to wait for a ping response to a ping
  90. * request as part of the keep-alive mechanism.
  91. *
  92. * If a ping response is not received before this timeout, then
  93. * #MQTT_ProcessLoop will return #MQTTKeepAliveTimeout.
  94. *
  95. * @note If this value is more than half of the keep alive interval, and the
  96. * server does not receive the previous ping request, then it is likely that the
  97. * server will disconnect the client before #MQTTKeepAliveTimeout can be returned.
  98. *
  99. * @note If a dummy implementation of the #MQTTGetCurrentTimeFunc_t timer function,
  100. * is supplied to the library, then the keep-alive mechanism is not supported by the
  101. * #MQTT_ProcessLoop API function. In that case, the value of #MQTT_PINGRESP_TIMEOUT_MS
  102. * is irrelevant to the behavior of the library.
  103. *
  104. * <b>Possible values:</b> Any positive integer up to SIZE_MAX. <br>
  105. * <b>Default value:</b> `5000`
  106. */
  107. #ifndef MQTT_PINGRESP_TIMEOUT_MS
  108. /* Wait 5 seconds by default for a ping response. */
  109. #define MQTT_PINGRESP_TIMEOUT_MS ( 5000U )
  110. #endif
  111. /**
  112. * @brief Maximum number of milliseconds of TX inactivity to wait
  113. * before initiating a PINGREQ
  114. *
  115. * @note If this value is less than the keep alive interval than
  116. * it will be used instead.
  117. *
  118. * <b>Possible values:</b> Any positive integer up to SIZE_MAX. <br>
  119. * <b>Default value:</b> '30000'
  120. */
  121. #ifndef PACKET_TX_TIMEOUT_MS
  122. #define PACKET_TX_TIMEOUT_MS ( 30000U )
  123. #endif
  124. /**
  125. * @brief Maximum number of milliseconds of RX inactivity to wait
  126. * before initiating a PINGREQ
  127. *
  128. * <b>Possible values:</b> Any positive integer up to SIZE_MAX. <br>
  129. * <b>Default value:</b> '30000'
  130. *
  131. */
  132. #ifndef PACKET_RX_TIMEOUT_MS
  133. #define PACKET_RX_TIMEOUT_MS ( 30000U )
  134. #endif
  135. /**
  136. * @brief The maximum duration between non-empty network reads while
  137. * receiving an MQTT packet via the #MQTT_ProcessLoop or #MQTT_ReceiveLoop
  138. * API functions.
  139. *
  140. * When an incoming MQTT packet is detected, the transport receive function
  141. * may be called multiple times until all of the expected number of bytes of the
  142. * packet are received. This timeout represents the maximum polling duration that
  143. * is allowed without any data reception from the network for the incoming packet.
  144. *
  145. * If the timeout expires, the #MQTT_ProcessLoop and #MQTT_ReceiveLoop functions
  146. * return #MQTTRecvFailed.
  147. *
  148. * @note If a dummy implementation of the #MQTTGetCurrentTimeFunc_t timer function,
  149. * is supplied to the library, then #MQTT_RECV_POLLING_TIMEOUT_MS MUST be set to 0.
  150. *
  151. * <b>Possible values:</b> Any positive 32 bit integer. Recommended to use a
  152. * small timeout value. <br>
  153. * <b>Default value:</b> `10`
  154. *
  155. */
  156. #ifndef MQTT_RECV_POLLING_TIMEOUT_MS
  157. #define MQTT_RECV_POLLING_TIMEOUT_MS ( 10U )
  158. #endif
  159. /**
  160. * @brief The maximum duration allowed to send an MQTT packet over the transport
  161. * interface.
  162. *
  163. * When sending an MQTT packet, the transport send or writev functions may be
  164. * called multiple times until all of the required number of bytes are sent.
  165. * This timeout represents the maximum duration that is allowed to send the MQTT
  166. * packet while calling the transport send or writev functions.
  167. *
  168. * If the timeout expires, #MQTTSendFailed will be returned by the public API
  169. * functions.
  170. *
  171. * @note If a dummy implementation of the #MQTTGetCurrentTimeFunc_t timer function,
  172. * is supplied to the library, then #MQTT_SEND_TIMEOUT_MS MUST be set to 0.
  173. *
  174. * <b>Possible values:</b> Any positive 32 bit integer. <br>
  175. * <b>Default value:</b> `20000`
  176. *
  177. */
  178. #ifndef MQTT_SEND_TIMEOUT_MS
  179. #define MQTT_SEND_TIMEOUT_MS ( 20000U )
  180. #endif
  181. #ifdef MQTT_SEND_RETRY_TIMEOUT_MS
  182. #error MQTT_SEND_RETRY_TIMEOUT_MS is deprecated. Instead use MQTT_SEND_TIMEOUT_MS.
  183. #endif
  184. /**
  185. * @brief Macro that is called in the MQTT library for logging "Error" level
  186. * messages.
  187. *
  188. * To enable error level logging in the MQTT library, this macro should be mapped to the
  189. * application-specific logging implementation that supports error logging.
  190. *
  191. * @note This logging macro is called in the MQTT library with parameters wrapped in
  192. * double parentheses to be ISO C89/C90 standard compliant. For a reference
  193. * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
  194. * logging-stack in demos folder of the
  195. * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C).
  196. *
  197. * <b>Default value</b>: Error logging is turned off, and no code is generated for calls
  198. * to the macro in the MQTT library on compilation.
  199. */
  200. #ifndef LogError
  201. #define LogError( message )
  202. #endif
  203. /**
  204. * @brief Macro that is called in the MQTT library for logging "Warning" level
  205. * messages.
  206. *
  207. * To enable warning level logging in the MQTT library, this macro should be mapped to the
  208. * application-specific logging implementation that supports warning logging.
  209. *
  210. * @note This logging macro is called in the MQTT library with parameters wrapped in
  211. * double parentheses to be ISO C89/C90 standard compliant. For a reference
  212. * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
  213. * logging-stack in demos folder of the
  214. * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
  215. *
  216. * <b>Default value</b>: Warning logs are turned off, and no code is generated for calls
  217. * to the macro in the MQTT library on compilation.
  218. */
  219. #ifndef LogWarn
  220. #define LogWarn( message )
  221. #endif
  222. /**
  223. * @brief Macro that is called in the MQTT library for logging "Info" level
  224. * messages.
  225. *
  226. * To enable info level logging in the MQTT library, this macro should be mapped to the
  227. * application-specific logging implementation that supports info logging.
  228. *
  229. * @note This logging macro is called in the MQTT library with parameters wrapped in
  230. * double parentheses to be ISO C89/C90 standard compliant. For a reference
  231. * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
  232. * logging-stack in demos folder of the
  233. * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
  234. *
  235. * <b>Default value</b>: Info logging is turned off, and no code is generated for calls
  236. * to the macro in the MQTT library on compilation.
  237. */
  238. #ifndef LogInfo
  239. #define LogInfo( message )
  240. #endif
  241. /**
  242. * @brief Macro that is called in the MQTT library for logging "Debug" level
  243. * messages.
  244. *
  245. * To enable debug level logging from MQTT library, this macro should be mapped to the
  246. * application-specific logging implementation that supports debug logging.
  247. *
  248. * @note This logging macro is called in the MQTT library with parameters wrapped in
  249. * double parentheses to be ISO C89/C90 standard compliant. For a reference
  250. * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
  251. * logging-stack in demos folder of the
  252. * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
  253. *
  254. * <b>Default value</b>: Debug logging is turned off, and no code is generated for calls
  255. * to the macro in the MQTT library on compilation.
  256. */
  257. #ifndef LogDebug
  258. #define LogDebug( message )
  259. #endif
  260. /* *INDENT-OFF* */
  261. #ifdef __cplusplus
  262. }
  263. #endif
  264. /* *INDENT-ON* */
  265. #endif /* ifndef CORE_MQTT_CONFIG_DEFAULTS_H_ */