iot_errors.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /**
  2. * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. /**@file
  41. *
  42. * @defgroup iot_error IoT SDK error codes
  43. * @{
  44. * @ingroup iot_sdk_common
  45. * @{
  46. * @brief Error codes for the nRF5x IoT SDK.
  47. *
  48. * @details
  49. * Error codes are 32-bit unsigned integers. The most significant 16 bits (MSB) are reserved for
  50. * identifying the module where the error occurred. The least significant 16 bits (LSB)
  51. * are used to provide the cause or nature of error. Each module is assigned a 16-bit
  52. * unsigned integer, which it will use to identify all errors that occurred in the module.
  53. * For example, if 0x8800 identifies a certain SDK module, all error codes from
  54. * 0x88000000 to 0x8800FFFF are reserved for this module.
  55. *
  56. * Note that common error reasons have been assigned values to make it
  57. * possible to decode error reasons easily. As an example, if a module is not initialized,
  58. * this error is assigned the error code 0x000A0. If an application encounters an error code
  59. * 0xZZZZ00A0, the application knows that it tried to access a certain module without
  60. * initializing it.
  61. *
  62. * Each module can define error codes that are not covered by
  63. * the common codes. These values must be defined in a range that does not conflict
  64. * with the common error values. Such module-specific error values might be used by
  65. * different modules to indicate errors of very different nature; so the same error code LSB
  66. * does not necessarily indicate the same error. If an error is already defined by the NRF
  67. * common error codes, however, these codes are reused.
  68. *
  69. * A specific range is also reserved for the application. The application can use this range
  70. * to define application-specific errors.
  71. *
  72. * The success code NRF_SUCCESS does not include a module identifier.
  73. */
  74. #ifndef IOT_ERRORS_H__
  75. #define IOT_ERRORS_H__
  76. #include "sdk_errors.h"
  77. #ifdef __cplusplus
  78. extern "C" {
  79. #endif
  80. /**
  81. * @defgroup sdk_iot_err_base Base defined for IoT SDK Modules
  82. * @{
  83. */
  84. #define IOT_ERR_BASE NRF_ERROR_IOT_ERR_BASE_START
  85. /* @} */
  86. /**
  87. * @defgroup sdk_iot_module_codes Module codes
  88. * @brief Codes reserved as identification for the module where the error occurred.
  89. * @{
  90. */
  91. #define BLE_6LOWPAN_ERR_BASE (IOT_ERR_BASE+0x0200)
  92. #define IOT_PBUFFER_ERR_BASE (IOT_ERR_BASE+0x1000)
  93. #define IOT_CONTEXT_MANAGER_ERR_BASE (IOT_ERR_BASE+0x1100)
  94. #define IOT_TIMER_ERR_BASE (IOT_ERR_BASE+0x1200)
  95. #define IOT_FILE_ERR_BASE (IOT_ERR_BASE+0x1300)
  96. #define IOT_DFU_ERR_BASE (IOT_ERR_BASE+0x1400)
  97. #define IOT_IPV6_ERR_BASE (IOT_ERR_BASE+0x2000)
  98. #define IOT_ICMP6_ERR_BASE (IOT_ERR_BASE+0x2100)
  99. #define IOT_UDP6_ERR_BASE (IOT_ERR_BASE+0x2200)
  100. #define IOT_COAP_ERR_BASE (IOT_ERR_BASE+0x2300)
  101. #define IOT_DNS6_ERR_BASE (IOT_ERR_BASE+0x2400)
  102. #define IOT_NTP_ERR_BASE (IOT_ERR_BASE+0x2500)
  103. #define IOT_LWM2M_ERR_BASE (IOT_ERR_BASE+0x2600)
  104. #define IOT_SOCKET_ERR_BASE (IOT_ERR_BASE+0x2700)
  105. #define IOT_TFTP_ERR_BASE (IOT_ERR_BASE+0x2800)
  106. #define IOT_MQTT_ERR_BASE (IOT_ERR_BASE+0x2900)
  107. #define IOT_TLS_ERR_BASE (IOT_ERR_BASE+0x2A00)
  108. #define IOT_TRICKLE_ERR_BASE (IOT_ERR_BASE+0x2C00)
  109. /* @} */
  110. /**
  111. * @defgroup iot_sdk_common_errors Common error codes
  112. * @brief Codes reserved as identification for common errors.
  113. * @{
  114. */
  115. #define SDK_ERR_MODULE_NOT_INITIALIZED (NRF_ERROR_SDK_COMMON_ERROR_BASE+0x0000)
  116. #define SDK_ERR_MUTEX_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE+0x0001)
  117. #define SDK_ERR_MUTEX_LOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE+0x0002)
  118. #define SDK_ERR_MUTEX_UNLOCK_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE+0x0003)
  119. #define SDK_ERR_MUTEX_COND_INIT_FAILED (NRF_ERROR_SDK_COMMON_ERROR_BASE+0x0004)
  120. #define SDK_ERR_MODULE_ALREADY_INITIALZED (NRF_ERROR_SDK_COMMON_ERROR_BASE+0x0005)
  121. #define SDK_ERR_API_NOT_IMPLEMENTED (NRF_ERROR_SDK_COMMON_ERROR_BASE+0x0010)
  122. #define SDK_ERR_FEATURE_NOT_ENABLED (NRF_ERROR_SDK_COMMON_ERROR_BASE+0x0011)
  123. #define SDK_ERR_RX_PKT_TRUNCATED (NRF_ERROR_SDK_COMMON_ERROR_BASE+0x0012)
  124. /* @} */
  125. /**
  126. * @defgroup ble_6lowpan_errors 6LoWPAN codes
  127. * @brief Error and status codes specific to 6LoWPAN.
  128. * @{
  129. */
  130. #define BLE_6LOWPAN_CID_NOT_FOUND (BLE_6LOWPAN_ERR_BASE+0x0040)
  131. #define BLE_6LOWPAN_TX_FIFO_FULL (BLE_6LOWPAN_ERR_BASE+0x0041)
  132. /* @} */
  133. /**
  134. * @defgroup iot_sdk_ipv6 IPv6 codes
  135. * @brief Error and status codes specific to IPv6.
  136. * @{
  137. */
  138. #define IOT_IPV6_ERR_ADDR_IF_MISMATCH (IOT_IPV6_ERR_BASE+0x0040)
  139. #define IOT_IPV6_ERR_PENDING (IOT_IPV6_ERR_BASE+0x0041)
  140. /* @} */
  141. /**
  142. * @defgroup iot_sdk_udp_errors UDP codes
  143. * @brief Error and status codes specific to UDP.
  144. * @{
  145. */
  146. #define UDP_PORT_IN_USE (IOT_UDP6_ERR_BASE+0x0040)
  147. #define UDP_BAD_CHECKSUM (IOT_UDP6_ERR_BASE+0x0041)
  148. #define UDP_TRUNCATED_PACKET (IOT_UDP6_ERR_BASE+0x0042)
  149. #define UDP_MALFORMED_PACKET (IOT_UDP6_ERR_BASE+0x0043)
  150. #define UDP_INTERFACE_NOT_READY (IOT_UDP6_ERR_BASE+0x0044)
  151. /* @} */
  152. /**
  153. * @defgroup iot_sdk_socket_errors socket error codes
  154. * @brief Error and status codes specific to socket API.
  155. * @{
  156. */
  157. #define SOCKET_PORT_IN_USE (IOT_SOCKET_ERR_BASE + 0x0040)
  158. #define SOCKET_NO_AVAILABLE_PORTS (IOT_SOCKET_ERR_BASE + 0x0041)
  159. #define SOCKET_WOULD_BLOCK (IOT_SOCKET_ERR_BASE + 0x0042)
  160. #define SOCKET_NO_MEM (IOT_SOCKET_ERR_BASE + 0x0043)
  161. #define SOCKET_NO_ROUTE (IOT_SOCKET_ERR_BASE + 0x0044)
  162. #define SOCKET_TIMEOUT (IOT_SOCKET_ERR_BASE + 0x0045)
  163. #define SOCKET_INTERFACE_NOT_READY (IOT_SOCKET_ERR_BASE + 0x0046)
  164. #define SOCKET_INVALID_PARAM (IOT_SOCKET_ERR_BASE + 0x0047)
  165. #define SOCKET_UNSUPPORTED_PROTOCOL (IOT_SOCKET_ERR_BASE + 0x0048)
  166. #define SOCKET_ADDRESS_IN_USE (IOT_SOCKET_ERR_BASE + 0x0049)
  167. #define SOCKET_NOT_CONNECTED (IOT_SOCKET_ERR_BASE + 0x0050)
  168. /* @} */
  169. /**
  170. * @defgroup iot_sdk_icmp6_errors ICMP codes
  171. * @brief Error and status codes specific to ICMP.
  172. * @{
  173. */
  174. #define ICMP6_UNHANDLED_PACKET_TYPE (IOT_ICMP6_ERR_BASE+0x0040)
  175. #define ICMP6_BAD_CHECKSUM (IOT_ICMP6_ERR_BASE+0x0041)
  176. #define ICMP6_MALFORMED_PACKET (IOT_ICMP6_ERR_BASE+0x0042)
  177. #define ICMP6_INVALID_PACKET_DATA (IOT_ICMP6_ERR_BASE+0x0043)
  178. /* @} */
  179. /**
  180. * @defgroup iot_sdk_coap_errros CoAP codes
  181. * @brief Error and status codes specific to CoAP.
  182. * @{
  183. */
  184. #define COAP_MESSAGE_ERROR_NULL (IOT_COAP_ERR_BASE+0x0040)
  185. #define COAP_MESSAGE_ERROR_INVALID_CONF (IOT_COAP_ERR_BASE+0x0041)
  186. #define COAP_MESSAGE_INVALID_CONTENT (IOT_COAP_ERR_BASE+0x0042)
  187. #define COAP_TRANSMISSION_RESET_BY_PEER (IOT_COAP_ERR_BASE+0x0043)
  188. #define COAP_TRANSMISSION_TIMEOUT (IOT_COAP_ERR_BASE+0x0044)
  189. #define COAP_TRANSPORT_SECURITY_MISSING (IOT_COAP_ERR_BASE+0x0045)
  190. #define COAP_REQUEST_RESOURCE_NOT_FOUND (IOT_COAP_ERR_BASE+0x0046)
  191. #define COAP_REQUEST_HANDLER_NOT_FOUND (IOT_COAP_ERR_BASE+0x0047)
  192. /* @} */
  193. /**
  194. * @defgroup iot_sdk_dns6_errors DNS codes.
  195. * @brief Error and status codes specific to DNS.
  196. * @{
  197. */
  198. #define DNS6_SERVER_UNREACHABLE (IOT_DNS6_ERR_BASE+0x0040)
  199. #define DNS6_FORMAT_ERROR (IOT_DNS6_ERR_BASE+0x0041)
  200. #define DNS6_SERVER_FAILURE (IOT_DNS6_ERR_BASE+0x0042)
  201. #define DNS6_HOSTNAME_NOT_FOUND (IOT_DNS6_ERR_BASE+0x0043)
  202. #define DNS6_NOT_IMPLEMENTED (IOT_DNS6_ERR_BASE+0x0044)
  203. #define DNS6_REFUSED_ERROR (IOT_DNS6_ERR_BASE+0x0045)
  204. #define DNS6_RESPONSE_TRUNCATED (IOT_DNS6_ERR_BASE+0x0046)
  205. /* @} */
  206. /**
  207. * @defgroup iot_sdk_ntp_errors NTP codes.
  208. * @brief Error and status codes specific to NTP.
  209. * @{
  210. */
  211. #define NTP_SERVER_UNREACHABLE (IOT_NTP_ERR_BASE+0x0040)
  212. #define NTP_SERVER_BAD_RESPONSE (IOT_NTP_ERR_BASE+0x0041)
  213. #define NTP_SERVER_KOD_PACKET_RECEIVED (IOT_NTP_ERR_BASE+0x0042)
  214. /* @} */
  215. /**
  216. * @defgroup iot_sdk_tftp_errors TFTP codes.
  217. * @brief Error and status codes specific to TFTP.
  218. * @{
  219. */
  220. /**@brief TFTP Error codes. */
  221. #define TFTP_UNDEFINED_ERROR (IOT_TFTP_ERR_BASE+0x0040)
  222. #define TFTP_FILE_NOT_FOUND (IOT_TFTP_ERR_BASE+0x0041)
  223. #define TFTP_ACCESS_DENIED (IOT_TFTP_ERR_BASE+0x0042)
  224. #define TFTP_FULL_STORAGE (IOT_TFTP_ERR_BASE+0x0043)
  225. #define TFTP_INVALID_OPCODE (IOT_TFTP_ERR_BASE+0x0044)
  226. #define TFTP_INVALID_TID (IOT_TFTP_ERR_BASE+0x0045)
  227. #define TFTP_FILE_EXSISTS (IOT_TFTP_ERR_BASE+0x0046)
  228. #define TFTP_WRONG_USERNAME (IOT_TFTP_ERR_BASE+0x0047)
  229. #define TFTP_OPTION_REJECT (IOT_TFTP_ERR_BASE+0x0048)
  230. #define TFTP_INVALID_PACKET (IOT_TFTP_ERR_BASE+0x0049)
  231. #define TFTP_REMOTE_UNREACHABLE (IOT_TFTP_ERR_BASE+0x004A)
  232. /* @} */
  233. /**@defgroup iot_sdk_mqtt_err_code MQTT Error Codes
  234. *@{
  235. */
  236. #define MQTT_ERR_NOT_CONNECTED (IOT_MQTT_ERR_BASE+0x0040)
  237. #define MQTT_ERR_WRITE (IOT_MQTT_ERR_BASE+0x0041)
  238. #define MQTT_ERR_TCP_PROC_FAILED (IOT_MQTT_ERR_BASE+0x0042)
  239. #define MQTT_CONNECTION_FAILED (IOT_MQTT_ERR_BASE+0x0043)
  240. #define MQTT_ERR_TRANSPORT_CLOSED (IOT_MQTT_ERR_BASE+0x0044)
  241. /**@}
  242. */
  243. /**@defgroup iot_sdk_tls_err_code NRF TLS Interface Error Codes
  244. *@{
  245. */
  246. #define NRF_TLS_CONFIGURATION_FAILED (IOT_TLS_ERR_BASE+0x0040)
  247. #define NRF_TLS_CONTEXT_SETUP_FAILED (IOT_TLS_ERR_BASE+0x0041)
  248. #define NRF_TLS_HANDSHAKE_IN_PROGRESS (IOT_TLS_ERR_BASE+0x0042)
  249. #define NRF_TLS_NO_FREE_INSTANCE (IOT_TLS_ERR_BASE+0x0043)
  250. #define NRF_TLS_INVALID_CA_CERTIFICATE (IOT_TLS_ERR_BASE+0x0044)
  251. #define NRF_TLS_OWN_CERT_SETUP_FAILED (IOT_TLS_ERR_BASE+0x0045)
  252. /**@}
  253. */
  254. /** @} */
  255. /** @} */
  256. #ifdef __cplusplus
  257. }
  258. #endif
  259. #endif // IOT_ERRORS_H__