MS_health_server_api.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /**
  2. * \file MS_health_server_api.h
  3. *
  4. * \brief This file defines the Mesh Health Model Application Interface
  5. * - includes Data Structures and Methods for both Server and Client.
  6. */
  7. /*
  8. * Copyright (C) 2017. Mindtree Ltd.
  9. * All rights reserved.
  10. */
  11. #ifndef _H_MS_HEALTH_SERVER_API_
  12. #define _H_MS_HEALTH_SERVER_API_
  13. /* --------------------------------------------- Header File Inclusion */
  14. #include "MS_access_api.h"
  15. /* --------------------------------------------- Global Definitions */
  16. /**
  17. * \defgroup health_fault_values Fault Values
  18. * \{
  19. * This section lists the Fault Values defined for Health Model.
  20. */
  21. /** Health Model - Fault Values */
  22. /** No Fault */
  23. #define MS_HEALTH_FAULT_NO_FAULT 0x00
  24. /** Battery Low Warning */
  25. #define MS_HEALTH_FAULT_BATTERY_LOW_WARNING 0x01
  26. /** Battery Low Error */
  27. #define MS_HEALTH_FAULT_BATTERY_LOW_ERROR 0x02
  28. /** Supply Voltage Too Low Warning */
  29. #define MS_HEALTH_FAULT_SUPPLY_VOLTAGE_TOO_LOW_WARNING 0x03
  30. /** Supply Voltage Too Low Error */
  31. #define MS_HEALTH_FAULT_SUPPLY_VOLTAGE_TOO_LOW_ERROR 0x04
  32. /** Supply Voltage Too High Warning */
  33. #define MS_HEALTH_FAULT_SUPPLY_VOLTAGE_TOO_HIGH_WARNING 0x05
  34. /** Supply Voltage Too High Error */
  35. #define MS_HEALTH_FAULT_SUPPLY_VOLTAGE_TOO_HIGH_ERROR 0x06
  36. /** Power Supply Interrupted Warning */
  37. #define MS_HEALTH_FAULT_POWER_SUPPLY_INTERRUPTED_WARNING 0x07
  38. /** Power Supply Interrupted Error */
  39. #define MS_HEALTH_FAULT_POWER_SUPPLY_INTERRUPTED_ERROR 0x08
  40. /** No Load Warning */
  41. #define MS_HEALTH_FAULT_NO_LOAD_WARNING 0x09
  42. /** No Load Error */
  43. #define MS_HEALTH_FAULT_NO_LOAD_ERROR 0x0A
  44. /** Overload Warning */
  45. #define MS_HEALTH_FAULT_OVERLOAD_WARNING 0x0B
  46. /** Overload Error */
  47. #define MS_HEALTH_FAULT_OVERLOAD_ERROR 0x0C
  48. /** Overheat Warning */
  49. #define MS_HEALTH_FAULT_OVERHEAT_WARNING 0x0D
  50. /** Overheat Error */
  51. #define MS_HEALTH_FAULT_OVERHEAT_ERROR 0x0E
  52. /** Condensation Warning */
  53. #define MS_HEALTH_FAULT_CONDENSATION_WARNING 0x0F
  54. /** Condensation Error */
  55. #define MS_HEALTH_FAULT_CONDENSATION_ERROR 0x10
  56. /** Vibration Warning */
  57. #define MS_HEALTH_FAULT_VIBRATION_WARNING 0x11
  58. /** Vibration Error */
  59. #define MS_HEALTH_FAULT_VIBRATION_ERROR 0x12
  60. /** Configuration Warning */
  61. #define MS_HEALTH_FAULT_CONFIGURATION_WARNING 0x13
  62. /** Configuration Error */
  63. #define MS_HEALTH_FAULT_CONFIGURATION_ERROR 0x14
  64. /** Element Not Calibrated Warning */
  65. #define MS_HEALTH_FAULT_ELEMENT_NOT_CALIBRATED_WARNING 0x15
  66. /** Element Not Calibrated Error */
  67. #define MS_HEALTH_FAULT_ELEMENT_NOT_CALIBRATED_ERROR 0x16
  68. /** Memory Warning */
  69. #define MS_HEALTH_FAULT_MEMORY_WARNING 0x17
  70. /** Memory Error */
  71. #define MS_HEALTH_FAULT_MEMORY_ERROR 0x18
  72. /** Self-Test Warning */
  73. #define MS_HEALTH_FAULT_SELF_TEST_WARNING 0x19
  74. /** Self-Test Error */
  75. #define MS_HEALTH_FAULT_SELF_TEST_ERROR 0x1A
  76. /** Input Too Low Warning */
  77. #define MS_HEALTH_FAULT_INPUT_TOO_LOW_WARNING 0x1B
  78. /** Input Too Low Error */
  79. #define MS_HEALTH_FAULT_INPUT_TOO_LOW_ERROR 0x1C
  80. /** Input Too High Warning */
  81. #define MS_HEALTH_FAULT_INPUT_TOO_HIGH_WARNING 0x1D
  82. /** Input Too High Error */
  83. #define MS_HEALTH_FAULT_INPUT_TOO_HIGH_ERROR 0x1E
  84. /** Input No Change Warning */
  85. #define MS_HEALTH_FAULT_INPUT_NO_CHANGE_WARNING 0x1F
  86. /** Input No Change Error */
  87. #define MS_HEALTH_FAULT_INPUT_NO_CHANGE_ERROR 0x20
  88. /** Actuator Blocked Warning */
  89. #define MS_HEALTH_FAULT_ACTUATOR_BLOCKED_WARNING 0x21
  90. /** Actuator Blocked Error */
  91. #define MS_HEALTH_FAULT_ACTUATOR_BLOCKED_ERROR 0x22
  92. /** Housing Opened Warning */
  93. #define MS_HEALTH_FAULT_HOUSING_OPENED_WARNING 0x23
  94. /** Housing Opened Error */
  95. #define MS_HEALTH_FAULT_HOUSING_OPENED_ERROR 0x24
  96. /** Tamper Warning */
  97. #define MS_HEALTH_FAULT_TAMPER_WARNING 0x25
  98. /** Tamper Error */
  99. #define MS_HEALTH_FAULT_TAMPER_ERROR 0x26
  100. /** Device Moved Warning */
  101. #define MS_HEALTH_FAULT_DEVICE_MOVED_WARNING 0x27
  102. /** Device Moved Error */
  103. #define MS_HEALTH_FAULT_DEVICE_MOVED_ERROR 0x28
  104. /** Device Dropped Warning */
  105. #define MS_HEALTH_FAULT_DEVICE_DROPPED_WARNING 0x29
  106. /** Device Dropped Error */
  107. #define MS_HEALTH_FAULT_DEVICE_DROPPED_ERROR 0x2A
  108. /** Overflow Warning */
  109. #define MS_HEALTH_FAULT_OVERFLOW_WARNING 0x2B
  110. /** Overflow Error */
  111. #define MS_HEALTH_FAULT_OVERFLOW_ERROR 0x2C
  112. /** Empty Warning */
  113. #define MS_HEALTH_FAULT_EMPTY_WARNING 0x2D
  114. /** Empty Error */
  115. #define MS_HEALTH_FAULT_EMPTY_ERROR 0x2E
  116. /** Internal Bus Warning */
  117. #define MS_HEALTH_FAULT_INTERNAL_BUS_WARNING 0x2F
  118. /** Internal Bus Error */
  119. #define MS_HEALTH_FAULT_INTERNAL_BUS_ERROR 0x30
  120. /** Mechanism Jammed Warning */
  121. #define MS_HEALTH_FAULT_MECHANISM_JAMMED_WARNING 0x31
  122. /** Mechanism Jammed Error*/
  123. #define MS_HEALTH_FAULT_MECHANISM_JAMMED_ERROR 0x32
  124. /* 0x33 - 0x7F: Reserved for Future Use */
  125. /* 0x80 - 0xFF: Vendor Specific Warning / Error */
  126. /** \} */
  127. /**
  128. * \defgroup health_server_events Health Server Events
  129. * \{
  130. * This section lists the Application Events defined for Health Server Model.
  131. */
  132. /** Attention Start */
  133. #define MS_HEALTH_SERVER_ATTENTION_START 0x01
  134. /** Attention Restart */
  135. #define MS_HEALTH_SERVER_ATTENTION_RESTART 0x02
  136. /** Attention Stop */
  137. #define MS_HEALTH_SERVER_ATTENTION_STOP 0x03
  138. /** \} */
  139. /* --------------------------------------------- Data Types/ Structures */
  140. /**
  141. * \brief Health Server application Asynchronous Notification Callback.
  142. *
  143. * \par Description
  144. * Health Server calls the registered callback to indicate events occurred to the
  145. * application.
  146. *
  147. * \param handle Model Handle.
  148. * \param event_type Health Server Event type.
  149. * \param event_param Parameter associated with the event if any or NULL.
  150. * \param param_len Size of the event parameter data. 0 if event param is NULL.
  151. */
  152. typedef API_RESULT (* MS_HEALTH_SERVER_CB)
  153. (
  154. MS_ACCESS_MODEL_HANDLE * handle,
  155. UINT8 event_type,
  156. UINT8 * event_param,
  157. UINT16 param_len
  158. ) DECL_REENTRANT;
  159. /**
  160. * Health Server Self Test Function.
  161. */
  162. /* TODO: Add context of the Health Server, so that associated current/registered fault can be updated */
  163. typedef void (* MS_HEALTH_SERVER_SELF_TEST_FN)(UINT8 test_id, UINT16 company_id);
  164. /**
  165. * Health Server Self Test Funtion Structure.
  166. */
  167. typedef struct _MS_HEALTH_SERVER_SELF_TEST
  168. {
  169. /** Test ID */
  170. UINT8 test_id;
  171. /** Self Test Function */
  172. MS_HEALTH_SERVER_SELF_TEST_FN self_test_fn;
  173. }MS_HEALTH_SERVER_SELF_TEST;
  174. /* --------------------------------------------- Function */
  175. /**
  176. * \brief API to initialize Health Server model
  177. *
  178. * \par Description
  179. * This is to initialize Health Server model and to register with Acess layer.
  180. *
  181. * \param [in] element_handle
  182. * Element identifier to be associated with the model instance.
  183. *
  184. * \param [in, out] model_handle
  185. * Model identifier associated with the model instance on successful initialization.
  186. * After power cycle of an already provisioned node, the model handle will have
  187. * valid value and the same will be reused for registration.
  188. *
  189. * \param [in] company_id
  190. * Company Identifier
  191. *
  192. * \param [in] self_tests
  193. * List of Self Tests that can be run.
  194. *
  195. * \param [in] num_self_tests
  196. * Number of Self Tests in the list.
  197. *
  198. * \param [in] appl_cb Application Callback to be used by the Health Server.
  199. *
  200. * \return API_SUCCESS or an error code indicating reason for failure
  201. */
  202. API_RESULT MS_health_server_init
  203. (
  204. /* IN */ MS_ACCESS_ELEMENT_HANDLE element_handle,
  205. /* INOUT */ MS_ACCESS_MODEL_HANDLE * model_handle,
  206. /* IN */ UINT16 company_id,
  207. /* IN */ MS_HEALTH_SERVER_SELF_TEST * self_tests,
  208. /* IN */ UINT32 num_self_tests,
  209. /* IN */ MS_HEALTH_SERVER_CB appl_cb
  210. );
  211. /**
  212. * \brief API to report self-test fault
  213. *
  214. * \par Description
  215. * This is to report fault observed during self-test procedure.
  216. *
  217. * \param [in] model_handle
  218. * Model Handle identifying the Health Server model instance.
  219. *
  220. * \param [in] test_id
  221. * Identifier of the self-test
  222. *
  223. * \param [in] company_id
  224. * Company Identifier
  225. *
  226. * \param [in] fault_code
  227. * Fault value indicating the error.
  228. *
  229. * \return API_SUCCESS or an error code indicating reason for failure
  230. */
  231. API_RESULT MS_health_server_report_fault
  232. (
  233. /* IN */ MS_ACCESS_MODEL_HANDLE * model_handle,
  234. /* IN */ UINT8 test_id,
  235. /* IN */ UINT16 company_id,
  236. /* IN */ UINT8 fault_code
  237. );
  238. /**
  239. * \cond ignore_this Ignore this fundtion while generating doxygen document
  240. */
  241. API_RESULT MS_health_server_publish_current_status
  242. (
  243. UCHAR * status,
  244. UINT16 length
  245. );
  246. /**
  247. * \endcond
  248. */
  249. #endif /*_H_MS_HEALTH_SERVER_API_ */