MS_health_client_api.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. /**
  2. * \file MS_health_client_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_CLIENT_API_
  12. #define _H_MS_HEALTH_CLIENT_API_
  13. /* --------------------------------------------- Header File Inclusion */
  14. #include "MS_access_api.h"
  15. /* --------------------------------------------- Global Definitions */
  16. /**
  17. * \defgroup health_module HEALTH (Mesh Health Model)
  18. * \{
  19. * This section describes the interfaces & APIs offered by the EtherMind
  20. * Mesh Health Model (HEALTH) module to the Application.
  21. */
  22. /* --------------------------------------------- Data Types/ Structures */
  23. /**
  24. * \defgroup health_cb Application Callback
  25. * \{
  26. * This Section Describes the module Notification Callback interface offered
  27. * to the application
  28. */
  29. /**
  30. * Health Client application Asynchronous Notification Callback.
  31. *
  32. * Health Client calls the registered callback to indicate events occurred to the
  33. * application.
  34. *
  35. * \param handle Model Handle.
  36. * \param opcode Opcode.
  37. * \param data_param Data associated with the event if any or NULL.
  38. * \param data_len Size of the event data. 0 if event data is NULL.
  39. */
  40. typedef API_RESULT (* MS_HEALTH_CLIENT_CB)
  41. (
  42. MS_ACCESS_MODEL_HANDLE * handle,
  43. UINT32 opcode,
  44. UCHAR * data_param,
  45. UINT16 data_len
  46. ) DECL_REENTRANT;
  47. /** \} */
  48. /**
  49. * \defgroup health_structures Structures
  50. * \{
  51. */
  52. /**
  53. * Health Status message parameters
  54. */
  55. typedef struct MS_health_status_struct
  56. {
  57. /** Identifier of a performed test */
  58. UCHAR test_id;
  59. /** 16-bit Bluetooth assigned Company Identifier */
  60. UINT16 company_id;
  61. /** The FaultArray field contains a sequence of 1-octet fault values */
  62. UCHAR *faultarray;
  63. /** Number of fault values in the FaultArray */
  64. UINT16 faultarray_len;
  65. } MS_HEALTH_STATUS_STRUCT;
  66. /**
  67. * Health Fault Get clear message parameters
  68. */
  69. typedef struct MS_health_fault_get_clear_struct
  70. {
  71. /** 16-bit Bluetooth assigned Company Identifier */
  72. UINT16 company_id;
  73. } MS_HEALTH_FAULT_GET_CLEAR_STRUCT;
  74. /**
  75. * Health Fault Test message parameters
  76. */
  77. typedef struct MS_health_fault_test_struct
  78. {
  79. /** Identifier of a performed test */
  80. UCHAR test_id;
  81. /** 16-bit Bluetooth assigned Company Identifier */
  82. UINT16 company_id;
  83. } MS_HEALTH_FAULT_TEST_STRUCT;
  84. /**
  85. * Health Period message parameters
  86. */
  87. typedef struct MS_health_period_struct
  88. {
  89. /**
  90. * Divider for the Publish Period.
  91. * Modified Publish Period is used for sending Current Health Status messages
  92. * when there are active faults to communicate.
  93. */
  94. UCHAR fastperioddivisor;
  95. } MS_HEALTH_PERIOD_STRUCT;
  96. /**
  97. * Health Attention message parameters
  98. */
  99. typedef struct MS_health_attention_struct
  100. {
  101. /** Value of the Attention Timer state */
  102. UCHAR attention;
  103. } MS_HEALTH_ATTENTION_STRUCT;
  104. /** \} */
  105. /* --------------------------------------------- Function */
  106. /**
  107. * \defgroup health_api_defs API Definitions
  108. * \{
  109. * This section describes the EtherMind Mesh Health Model APIs.
  110. */
  111. /**
  112. * \defgroup health_cli_api_defs Health Client API Definitions
  113. * \{
  114. * This section describes the Health Client APIs.
  115. */
  116. /**
  117. * \brief API to initialize Health Client model
  118. *
  119. * \par Description
  120. * This is to initialize Health Client model and to register with Acess layer.
  121. *
  122. * \param [in] element_handle
  123. * Element identifier to be associated with the model instance.
  124. *
  125. * \param [in, out] model_handle
  126. * Model identifier associated with the model instance on successful initialization.
  127. * After power cycle of an already provisioned node, the model handle will have
  128. * valid value and the same will be reused for registration.
  129. *
  130. * \param [in] appl_cb Application Callback to be used by the Health Client.
  131. *
  132. * \return API_SUCCESS or an error code indicating reason for failure
  133. */
  134. API_RESULT MS_health_client_init
  135. (
  136. /* IN */ MS_ACCESS_ELEMENT_HANDLE element_handle,
  137. /* INOUT */ MS_ACCESS_MODEL_HANDLE * model_handle,
  138. /* IN */ MS_HEALTH_CLIENT_CB appl_cb
  139. );
  140. /**
  141. * \brief API to get Health client model handle
  142. *
  143. * \par Description
  144. * This is to get the handle of Health client model.
  145. *
  146. * \param [out] model_handle Address of model handle to be filled/returned.
  147. *
  148. * \return API_SUCCESS or an error code indicating reason for failure
  149. */
  150. API_RESULT MS_health_client_get_model_handle
  151. (
  152. /* OUT */ MS_ACCESS_MODEL_HANDLE * model_handle
  153. );
  154. /**
  155. * \brief API to send acknowledged commands
  156. *
  157. * \par Description
  158. * This is to initialize sending acknowledged commands.
  159. *
  160. * \param [in] req_opcode Request Opcode.
  161. * \param [in] param Parameter associated with Request Opcode.
  162. * \param [in] rsp_opcode Response Opcode.
  163. *
  164. * \return API_SUCCESS or an error code indicating reason for failure
  165. */
  166. API_RESULT MS_health_client_send_reliable_pdu
  167. (
  168. /* IN */ UINT32 req_opcode,
  169. /* IN */ void * param,
  170. /* IN */ UINT32 rsp_opcode
  171. );
  172. /**
  173. * \brief API to report the registered fault state
  174. *
  175. * \par Description
  176. * The Health Fault Get is an acknowledged message used to get the current
  177. * Registered Fault state identified by Company ID of an element.
  178. *
  179. * \param [in] param
  180. * Pointer to the structure populated as in \ref ACCESS_HEALTH_FAULT_GET_PARAM
  181. *
  182. * \return API_SUCCESS or an error code indicating reason for failure
  183. */
  184. #define MS_health_fault_get(param) \
  185. MS_health_client_send_reliable_pdu \
  186. (\
  187. MS_ACCESS_HEALTH_FAULT_GET_OPCODE,\
  188. param,\
  189. MS_ACCESS_HEALTH_FAULT_STATUS_OPCODE\
  190. )
  191. /**
  192. * \brief API to clear the registered fault state
  193. *
  194. * \par Description
  195. * The Health Fault Clear Unacknowledged is an unacknowledged message used
  196. * to clear the current Registered Fault state identified by Company ID of an element.
  197. *
  198. * \param [in] param
  199. * Pointer to the structure populated as in \ref ACCESS_HEALTH_FAULT_CLEAR_PARAM
  200. *
  201. * \return API_SUCCESS or an error code indicating reason for failure
  202. */
  203. #define MS_health_fault_clear_unacknowledged(param) \
  204. MS_health_client_send_reliable_pdu \
  205. (\
  206. MS_ACCESS_HEALTH_FAULT_CLEAR_UNACKNOWLEDGED_OPCODE,\
  207. param,\
  208. 0xFFFFFFFF\
  209. )
  210. /**
  211. * \brief API to clear the registered fault state
  212. *
  213. * \par Description
  214. * The Health Fault Clear is an acknowledged message used to clear the
  215. * current Registered Fault state identified by Company ID of an element.
  216. *
  217. * \param [in] param
  218. * Pointer to the structure populated as in \ref ACCESS_HEALTH_FAULT_CLEAR_PARAM
  219. *
  220. * \return API_SUCCESS or an error code indicating reason for failure
  221. */
  222. #define MS_health_fault_clear(param) \
  223. MS_health_client_send_reliable_pdu \
  224. (\
  225. MS_ACCESS_HEALTH_FAULT_CLEAR_OPCODE,\
  226. param,\
  227. MS_ACCESS_HEALTH_FAULT_STATUS_OPCODE\
  228. )
  229. /**
  230. * \brief API to invoke a self-test procedure
  231. *
  232. * \par Description
  233. * The Health Fault Test is an acknowledged message used to invoke a self-test
  234. * procedure of an element. The procedure is implementation specific and may
  235. * result in changing the Health Fault state of an element.
  236. *
  237. * \param [in] param
  238. * Pointer to the structure populated as in \ref ACCESS_HEALTH_FAULT_TEST_PARAM
  239. *
  240. * \return API_SUCCESS or an error code indicating reason for failure
  241. */
  242. #define MS_health_fault_test(param) \
  243. MS_health_client_send_reliable_pdu \
  244. (\
  245. MS_ACCESS_HEALTH_FAULT_TEST_OPCODE,\
  246. param,\
  247. MS_ACCESS_HEALTH_FAULT_STATUS_OPCODE\
  248. )
  249. /**
  250. * \brief API to invoke a self-test procedure
  251. *
  252. * \par Description
  253. * The Health Fault Test Unacknowledged is an unacknowledged message used
  254. * to invoke a self-test procedure of an element. The procedure is implementation
  255. * specific and may result in changing the Health Fault state of an element.
  256. *
  257. * \return API_SUCCESS or an error code indicating reason for failure
  258. */
  259. #define MS_health_fault_test_unacknowledged(param) \
  260. MS_health_client_send_reliable_pdu \
  261. (\
  262. MS_ACCESS_HEALTH_FAULT_TEST_UNACKNOWLEDGED_OPCODE,\
  263. param,\
  264. 0xFFFFFFFF\
  265. )
  266. /**
  267. * \brief API to get the health period state
  268. *
  269. * \par Description
  270. * The Health Period Get is an acknowledged message used to get the
  271. * current Health Period state of an element.
  272. *
  273. * \return API_SUCCESS or an error code indicating reason for failure
  274. */
  275. #define MS_health_period_get() \
  276. MS_health_client_send_reliable_pdu \
  277. (\
  278. MS_ACCESS_HEALTH_PERIOD_GET_OPCODE,\
  279. NULL,\
  280. MS_ACCESS_HEALTH_PERIOD_STATUS_OPCODE\
  281. )
  282. /**
  283. * \brief API to set the health period state
  284. *
  285. * \par Description
  286. * The Health Period Set Unacknowledged is an unacknowledged message used
  287. * to set the current Health Period state of an element.
  288. *
  289. * \param [in] param
  290. * Pointer to the structure populated as in \ref ACCESS_HEALTH_PERIOD_SET_PARAM
  291. *
  292. * \return API_SUCCESS or an error code indicating reason for failure
  293. */
  294. #define MS_health_period_set_unacknowledged(param) \
  295. MS_health_client_send_reliable_pdu \
  296. (\
  297. MS_ACCESS_HEALTH_PERIOD_SET_UNACKNOWLEDGED_OPCODE,\
  298. param,\
  299. 0xFFFFFFFF\
  300. )
  301. /**
  302. * \brief API to set the health period state
  303. *
  304. * \par Description
  305. * The Health Period Set is an acknowledged message used to set the
  306. * current Health Period state of an element.
  307. *
  308. * \param [in] param
  309. * Pointer to the structure populated as in \ref ACCESS_HEALTH_PERIOD_SET_PARAM
  310. *
  311. * \return API_SUCCESS or an error code indicating reason for failure
  312. */
  313. #define MS_health_period_set(param) \
  314. MS_health_client_send_reliable_pdu \
  315. (\
  316. MS_ACCESS_HEALTH_PERIOD_SET_OPCODE,\
  317. param,\
  318. MS_ACCESS_HEALTH_PERIOD_STATUS_OPCODE\
  319. )
  320. /**
  321. * \brief API to get the attention state
  322. *
  323. * \par Description
  324. * The Health Attention Get is an acknowledged message used to get
  325. * the current Attention Timer state of an element.
  326. *
  327. * \return API_SUCCESS or an error code indicating reason for failure
  328. */
  329. #define MS_health_attention_get() \
  330. MS_health_client_send_reliable_pdu \
  331. (\
  332. MS_ACCESS_HEALTH_ATTENTION_GET_OPCODE,\
  333. NULL,\
  334. MS_ACCESS_HEALTH_ATTENTION_STATUS_OPCODE\
  335. )
  336. /**
  337. * \brief API to set the attention state
  338. *
  339. * \par Description
  340. * The Health Attention Set is an acknowledged message used to set the
  341. * Attention Timer state of an element.
  342. *
  343. * \param [in] param
  344. * Pointer to the structure populated as in \ref ACCESS_HEALTH_ATTENTION_SET_PARAM
  345. *
  346. * \return API_SUCCESS or an error code indicating reason for failure
  347. */
  348. #define MS_health_attention_set(param) \
  349. MS_health_client_send_reliable_pdu \
  350. (\
  351. MS_ACCESS_HEALTH_ATTENTION_SET_OPCODE,\
  352. param,\
  353. MS_ACCESS_HEALTH_ATTENTION_STATUS_OPCODE\
  354. )
  355. /**
  356. * \brief API to set the attention state
  357. *
  358. * \par Description
  359. * The Health Attention Set Unacknowledged is an unacknowledged message
  360. * used to set the Attention Timer state of an element.
  361. *
  362. * \param [in] param
  363. * Pointer to the structure populated as in \ref ACCESS_HEALTH_ATTENTION_SET_PARAM
  364. *
  365. * \return API_SUCCESS or an error code indicating reason for failure
  366. */
  367. #define MS_health_attention_set_unacknowledged(param) \
  368. MS_health_client_send_reliable_pdu \
  369. (\
  370. MS_ACCESS_HEALTH_ATTENTION_SET_UNACKNOWLEDGED_OPCODE,\
  371. param,\
  372. 0xFFFFFFFF\
  373. )
  374. /** \} */
  375. /** \} */
  376. /** \} */
  377. #endif /* _H_MS_HEALTH_CLIENT_API_ */