core_mqtt_config_defaults.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. {
  41. #endif
  42. /* *INDENT-ON* */
  43. #include "RyanMqttPlatform.h"
  44. /* The macro definition for MQTT_DO_NOT_USE_CUSTOM_CONFIG is for Doxygen
  45. * documentation only. */
  46. /**
  47. * @brief Define this macro to build the MQTT library without the custom config
  48. * file core_mqtt_config.h.
  49. *
  50. * Without the custom config, the MQTT library builds with
  51. * default values of config macros defined in core_mqtt_config_defaults.h file.
  52. *
  53. * If a custom config is provided, then MQTT_DO_NOT_USE_CUSTOM_CONFIG should not
  54. * be defined.
  55. */
  56. #ifdef DOXYGEN
  57. #define MQTT_DO_NOT_USE_CUSTOM_CONFIG
  58. #endif
  59. /**
  60. * @brief Macro that is called in the MQTT library for logging "Error" level
  61. * messages.
  62. *
  63. * To enable error level logging in the MQTT library, this macro should be mapped to the
  64. * application-specific logging implementation that supports error logging.
  65. *
  66. * @note This logging macro is called in the MQTT library with parameters wrapped in
  67. * double parentheses to be ISO C89/C90 standard compliant. For a reference
  68. * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
  69. * logging-stack in demos folder of the
  70. * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C).
  71. *
  72. * <b>Default value</b>: Error logging is turned off, and no code is generated for calls
  73. * to the macro in the MQTT library on compilation.
  74. */
  75. #ifndef LogError
  76. #define LogError(message)
  77. #endif
  78. /**
  79. * @brief Macro that is called in the MQTT library for logging "Warning" level
  80. * messages.
  81. *
  82. * To enable warning level logging in the MQTT library, this macro should be mapped to the
  83. * application-specific logging implementation that supports warning logging.
  84. *
  85. * @note This logging macro is called in the MQTT library with parameters wrapped in
  86. * double parentheses to be ISO C89/C90 standard compliant. For a reference
  87. * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
  88. * logging-stack in demos folder of the
  89. * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
  90. *
  91. * <b>Default value</b>: Warning logs are turned off, and no code is generated for calls
  92. * to the macro in the MQTT library on compilation.
  93. */
  94. #ifndef LogWarn
  95. #define LogWarn(message)
  96. #endif
  97. /**
  98. * @brief Macro that is called in the MQTT library for logging "Info" level
  99. * messages.
  100. *
  101. * To enable info level logging in the MQTT library, this macro should be mapped to the
  102. * application-specific logging implementation that supports info logging.
  103. *
  104. * @note This logging macro is called in the MQTT library with parameters wrapped in
  105. * double parentheses to be ISO C89/C90 standard compliant. For a reference
  106. * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
  107. * logging-stack in demos folder of the
  108. * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
  109. *
  110. * <b>Default value</b>: Info logging is turned off, and no code is generated for calls
  111. * to the macro in the MQTT library on compilation.
  112. */
  113. #ifndef LogInfo
  114. #define LogInfo(message)
  115. #endif
  116. /**
  117. * @brief Macro that is called in the MQTT library for logging "Debug" level
  118. * messages.
  119. *
  120. * To enable debug level logging from MQTT library, this macro should be mapped to the
  121. * application-specific logging implementation that supports debug logging.
  122. *
  123. * @note This logging macro is called in the MQTT library with parameters wrapped in
  124. * double parentheses to be ISO C89/C90 standard compliant. For a reference
  125. * POSIX implementation of the logging macros, refer to core_mqtt_config.h files, and the
  126. * logging-stack in demos folder of the
  127. * [AWS IoT Embedded C SDK repository](https://github.com/aws/aws-iot-device-sdk-embedded-C/).
  128. *
  129. * <b>Default value</b>: Debug logging is turned off, and no code is generated for calls
  130. * to the macro in the MQTT library on compilation.
  131. */
  132. #ifndef LogDebug
  133. #define LogDebug(message)
  134. #endif
  135. /**
  136. * @transportstruct
  137. * @typedef NetworkContext_t
  138. * @brief The NetworkContext is an incomplete type. An implementation of this
  139. * interface must define struct NetworkContext for the system requirements.
  140. * This context is passed into the network interface functions.
  141. */
  142. /* @[define_networkcontext] */
  143. typedef struct NetworkContext NetworkContext_t;
  144. /**
  145. * @transportcallback
  146. * @brief Transport interface for receiving data on the network.
  147. *
  148. * @note It is HIGHLY RECOMMENDED that the transport receive
  149. * implementation does NOT block.
  150. * coreMQTT will continue to call the transport interface if it receives
  151. * a partial packet until it accumulates enough data to get the complete
  152. * MQTT packet.
  153. * A non‐blocking implementation is also essential so that the library's inbuilt
  154. * keep‐alive mechanism can work properly, given the user chooses to use
  155. * that over their own keep alive mechanism.
  156. *
  157. * @param[in] pNetworkContext Implementation-defined network context.
  158. * @param[in] pBuffer Buffer to receive the data into.
  159. * @param[in] bytesToRecv Number of bytes requested from the network.
  160. *
  161. * @return The number of bytes received or a negative value to indicate
  162. * error.
  163. *
  164. * @note If no data is available on the network to read and no error
  165. * has occurred, zero MUST be the return value. A zero return value
  166. * SHOULD represent that the read operation can be retried by calling
  167. * the API function. Zero MUST NOT be returned if a network disconnection
  168. * has occurred.
  169. */
  170. /* @[define_transportrecv] */
  171. typedef int32_t (*TransportRecv_t)(NetworkContext_t *pNetworkContext,
  172. void *pBuffer,
  173. size_t bytesToRecv);
  174. /* *INDENT-OFF* */
  175. #ifdef __cplusplus
  176. }
  177. #endif
  178. /* *INDENT-ON* */
  179. #endif /* ifndef CORE_MQTT_CONFIG_DEFAULTS_H_ */