sdk_errors.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. /**@file
  13. *
  14. * @defgroup sdk_error SDK Error codes
  15. * @{
  16. * @ingroup app_common
  17. * @{
  18. * @details Error codes are 32-bit unsigned integers with the most significant 16-bit reserved for
  19. * identifying the module where the error occurred while the least least significant LSB
  20. * are used to provide the cause or nature of error. Each module is assigned a 16-bit
  21. * unsigned integer. Which it will use to identify all errors that occurred in it. 16-bit
  22. * LSB range is with module id as the MSB in the 32-bit error code is reserved for the
  23. * module. As an example, if 0x8800 identifies a certain SDK module, all values from
  24. * 0x88000000 - 0x8800FFFF are reserved for this module.
  25. * It should be noted that common error reasons have been assigned values to make it
  26. * possible to decode error reason easily. As an example, lets module uninitialized has
  27. * been assigned an error code 0x000A0. Then, if application encounters an error code
  28. * 0xZZZZ00A0, it knows that it accessing a certain module without initializing it.
  29. * Apart from this, each module is allowed to define error codes that are not covered by
  30. * the common ones, however, these values are defined in a range that does not conflict
  31. * with common error values. For module, specific error however, it is possible that the
  32. * same error value is used by two different modules to indicated errors of very different
  33. * nature. If error is already defined by the NRF common error codes, these are reused.
  34. * A range is reserved for application as well, it can use this range for defining
  35. * application specific errors.
  36. *
  37. * @note Success code, NRF_SUCCESS, does not include any module identifier.
  38. */
  39. #ifndef SDK_ERRORS_H__
  40. #define SDK_ERRORS_H__
  41. #include <stdint.h>
  42. #include "nrf_error.h"
  43. /**
  44. * @defgroup sdk_err_base Base defined for SDK Modules
  45. * @{
  46. */
  47. #define SDK_ERROR_BASE (NRF_ERROR_BASE_NUM + 0x8000) /**< Base value defined for SDK module identifiers. */
  48. #define SDK_COMMON_ERROR_BASE (NRF_ERROR_BASE_NUM + 0x0080) /**< Base error value to be used for SDK error values. */
  49. /* @} */
  50. /**
  51. * @defgroup sdk_module_codes Codes reserved as identification for module where the error occurred.
  52. * @{
  53. */
  54. #define DEVICE_MANAGER_ERR_BASE (0x8000)
  55. #define MEMORY_MANAGER_ERR_BASE (0x8100)
  56. /* @} */
  57. /**
  58. * @defgroup sdk_iot_errors Codes reserved as identification for IoT errors.
  59. * @{
  60. */
  61. #define IOT_ERR_BASE_START (0xA000)
  62. #define IOT_ERR_BASE_STOP (0xAFFF)
  63. /* @} */
  64. /**
  65. * @defgroup sdk_common_errors Codes reserved as identification for common errors.
  66. * @{
  67. */
  68. #define MODULE_NOT_INITIALZED (SDK_COMMON_ERROR_BASE + 0x0000)
  69. #define MUTEX_INIT_FAILED (SDK_COMMON_ERROR_BASE + 0x0001)
  70. #define MUTEX_LOCK_FAILED (SDK_COMMON_ERROR_BASE + 0x0002)
  71. #define MUTEX_UNLOCK_FAILED (SDK_COMMON_ERROR_BASE + 0x0003)
  72. #define MUTEX_COND_INIT_FAILED (SDK_COMMON_ERROR_BASE + 0x0004)
  73. #define MODULE_ALREADY_INITIALIZED (SDK_COMMON_ERROR_BASE + 0x0005)
  74. #define API_NOT_IMPLEMENTED (SDK_COMMON_ERROR_BASE + 0x0010)
  75. #define FEATURE_NOT_ENABLED (SDK_COMMON_ERROR_BASE + 0x0011)
  76. /* @} */
  77. /**
  78. * @defgroup dm_specific_errors Error / status codes specific to device manager.
  79. * @{
  80. */
  81. #define DM_NO_APP_CONTEXT (DEVICE_MANAGER_ERR_BASE + 0x0040)
  82. #define DM_SERVICE_CONTEXT_NOT_APPLIED (DEVICE_MANAGER_ERR_BASE + 0x0041)
  83. #define DM_CONTEXT_INFO_LOST (DEVICE_MANAGER_ERR_BASE + 0x0042)
  84. #define DM_DEVICE_CONTEXT_FULL (DEVICE_MANAGER_ERR_BASE + 0x0043)
  85. /* @} */
  86. /**
  87. * @brief API Result.
  88. *
  89. * @details Indicates success or failure of an API procedure. In case of failure, a comprehensive
  90. * error code indicating cause or reason for failure is provided.
  91. *
  92. * Though called an API result, it could used in Asynchronous notifications callback along
  93. * with asynchronous callback as event result. This mechanism is employed when an event
  94. * marks the end of procedure initiated using API. API result, in this case, will only be
  95. * an indicative of whether the procedure has been requested successfully.
  96. */
  97. typedef uint32_t ret_code_t;
  98. /** @} */
  99. /** @} */
  100. #endif // SDK_ERRORS_H__