MS_light_lc_api.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /**
  2. * \file MS_light_lc_api.h
  3. *
  4. * \brief This file defines the Mesh Light Lc 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_LIGHT_LC_API_
  12. #define _H_MS_LIGHT_LC_API_
  13. /* --------------------------------------------- Header File Inclusion */
  14. #include "MS_access_api.h"
  15. /* --------------------------------------------- Global Definitions */
  16. /**
  17. * \defgroup light_lc_module LIGHT_LC (Mesh Light Lc Model)
  18. * \{
  19. * This section describes the interfaces & APIs offered by the EtherMind
  20. * Mesh Generic OnOff Model (ONOFF) module to the Application.
  21. */
  22. /* --------------------------------------------- Data Types/ Structures */
  23. /**
  24. * \defgroup light_lc_cb Application Callback
  25. * \{
  26. * This Section Describes the module Notification Callback interface offered
  27. * to the application
  28. */
  29. /**
  30. * Light Lc Server application Asynchronous Notification Callback.
  31. *
  32. * Light Lc Server calls the registered callback to indicate events occurred to the
  33. * application.
  34. *
  35. * \param [in] ctx Context of the message received for a specific model instance.
  36. * \param [in] msg_raw Uninterpreted/raw received message.
  37. * \param [in] req_type Requested message type.
  38. * \param [in] state_params Model specific state parameters.
  39. * \param [in] ext_params Additional parameters.
  40. */
  41. typedef API_RESULT (* MS_LIGHT_LC_SERVER_CB)
  42. (
  43. MS_ACCESS_MODEL_REQ_MSG_CONTEXT * ctx,
  44. MS_ACCESS_MODEL_REQ_MSG_RAW * msg_raw,
  45. MS_ACCESS_MODEL_REQ_MSG_T * req_type,
  46. MS_ACCESS_MODEL_STATE_PARAMS * state_params,
  47. MS_ACCESS_MODEL_EXT_PARAMS * ext_params
  48. ) DECL_REENTRANT;
  49. /**
  50. * Light Lc Client application Asynchronous Notification Callback.
  51. *
  52. * Light Lc Client calls the registered callback to indicate events occurred to the
  53. * application.
  54. *
  55. * \param handle Model Handle.
  56. * \param opcode Opcode.
  57. * \param data_param Data associated with the event if any or NULL.
  58. * \param data_len Size of the event data. 0 if event data is NULL.
  59. */
  60. typedef API_RESULT (* MS_LIGHT_LC_CLIENT_CB)
  61. (
  62. MS_ACCESS_MODEL_HANDLE * handle,
  63. UINT32 opcode,
  64. UCHAR * data_param,
  65. UINT16 data_len
  66. ) DECL_REENTRANT;
  67. /** \} */
  68. /**
  69. * \defgroup light_lc_structures Structures
  70. * \{
  71. */
  72. /**
  73. * Light LC Mode Set/Status message parameters.
  74. */
  75. typedef struct MS_light_lc_mode_struct
  76. {
  77. /** The target value of the Light LC Mode state */
  78. UCHAR mode;
  79. } MS_LIGHT_LC_MODE_STRUCT;
  80. typedef struct MS_light_lc_om_struct
  81. {
  82. /** The target value of the Light LC Occupancy Mode state */
  83. UCHAR mode;
  84. } MS_LIGHT_LC_OM_STRUCT;
  85. /**
  86. * Light LC Light OnOff Set message parameters.
  87. */
  88. typedef struct MS_light_lc_light_onoff_set_struct
  89. {
  90. /** The target value of the Light LC Light OnOff state */
  91. UCHAR light_onoff;
  92. /** Transaction Identifier */
  93. UCHAR tid;
  94. /**
  95. * Transition Time is a 1-octet value that consists of two fields:
  96. * - a 2-bit bit field representing the step resolution
  97. * - a 6-bit bit field representing the number of transition steps.
  98. *
  99. * Field | Size (bits) | Description
  100. * ---------------------------|-------------|----------------
  101. * Transition Number of Steps | 6 | The number of Steps
  102. * Transition Step Resolution | 2 | The resolution of the Default Transition
  103. * | Number of Steps field
  104. */
  105. UCHAR transition_time;
  106. /** Message execution delay in 5 milliseconds steps */
  107. UCHAR delay;
  108. /** Flag: To represent if optional Transaction time and Delay fields are valid */
  109. UCHAR optional_fields_present;
  110. } MS_LIGHT_LC_LIGHT_ONOFF_SET_STRUCT;
  111. /**
  112. * Light LC Light OnOff Status message parameters.
  113. */
  114. typedef struct MS_light_lc_light_onoff_status_struct
  115. {
  116. /** The present value of the Light LC Light OnOff state */
  117. UCHAR present_light_onoff;
  118. /** The target value of the Light LC Light OnOff state (Optional) */
  119. UCHAR target_light_onoff;
  120. /**
  121. * Remaining Time is a 1-octet value that consists of two fields:
  122. * - a 2-bit bit field representing the step resolution
  123. * - a 6-bit bit field representing the number of transition steps.
  124. *
  125. * Field | Size (bits) | Description
  126. * ---------------------------|-------------|----------------
  127. * Transition Number of Steps | 6 | The number of Steps
  128. * Transition Step Resolution | 2 | The resolution of the Default Transition
  129. * | Number of Steps field
  130. */
  131. UCHAR remaining_time;
  132. /** Flag: To represent if optional fields Target LC Light OnOff and Remaining Time are valid */
  133. UCHAR optional_fields_present;
  134. } MS_LIGHT_LC_LIGHT_ONOFF_STATUS_STRUCT;
  135. /**
  136. * Light LC Property Get message parameters.
  137. */
  138. typedef struct MS_light_lc_property_get_struct
  139. {
  140. /** Property ID identifying a Light LC Property. */
  141. UINT16 light_lc_property_id;
  142. } MS_LIGHT_LC_PROPERTY_GET_STRUCT;
  143. /**
  144. * Light LC Property Set message parameters.
  145. */
  146. typedef struct MS_light_lc_property_set_struct
  147. {
  148. /** Property ID identifying a Light LC Property. */
  149. UINT16 light_lc_property_id;
  150. /** Raw value for the Light LC Property */
  151. UCHAR *light_lc_property_value;
  152. /** Raw value length for the Light LC Property */
  153. UINT16 light_lc_property_value_len;
  154. } MS_LIGHT_LC_PROPERTY_SET_STRUCT;
  155. /**
  156. * Light LC Property Status message parameters.
  157. */
  158. typedef struct MS_light_lc_property_status_struct
  159. {
  160. /** Property ID identifying a Light LC Property. */
  161. UINT16 light_lc_property_id;
  162. /** Raw value for the Light LC Property */
  163. UCHAR *light_lc_property_value;
  164. /** Raw value length for the Light LC Property */
  165. UINT16 light_lc_property_value_len;
  166. } MS_LIGHT_LC_PROPERTY_STATUS_STRUCT;
  167. /** \} */
  168. /* --------------------------------------------- Function */
  169. /**
  170. * \defgroup light_lc_api_defs API Definitions
  171. * \{
  172. * This section describes the EtherMind Mesh Light Lc Model APIs.
  173. */
  174. /**
  175. * \defgroup light_lc_ser_api_defs Light Lc Server API Definitions
  176. * \{
  177. * This section describes the Light Lc Server APIs.
  178. */
  179. /**
  180. * \brief API to initialize Light_Lc Server model
  181. *
  182. * \par Description
  183. * This is to initialize Light_Lc Server model and to register with Acess layer.
  184. *
  185. * \param [in] element_handle
  186. * Element identifier to be associated with the model instance.
  187. *
  188. * \param [in, out] lc_model_handle
  189. * Model identifier associated with the Light LC model instance on successful initialization.
  190. * After power cycle of an already provisioned node, the model handle will have
  191. * valid value and the same will be reused for registration.
  192. *
  193. * \param [in, out] lc_setup_model_handle
  194. * Model identifier associated with the Light LC Setup model instance on successful initialization.
  195. * After power cycle of an already provisioned node, the model handle will have
  196. * valid value and the same will be reused for registration.
  197. *
  198. * \param [in] appl_cb Application Callback to be used by the Light_Lc Server.
  199. *
  200. * \return API_SUCCESS or an error code indicating reason for failure
  201. */
  202. API_RESULT MS_light_lc_server_init
  203. (
  204. /* IN */ MS_ACCESS_ELEMENT_HANDLE element_handle,
  205. /* INOUT */ MS_ACCESS_MODEL_HANDLE * lc_model_handle,
  206. /* INOUT */ MS_ACCESS_MODEL_HANDLE * lc_setup_model_handle,
  207. /* IN */ MS_LIGHT_LC_SERVER_CB appl_cb
  208. );
  209. /**
  210. * \brief API to send reply or to update state change
  211. *
  212. * \par Description
  213. * This is to send reply for a request or to inform change in state.
  214. *
  215. * \param [in] ctx Context of the message.
  216. * \param [in] current_state_params Model specific current state parameters.
  217. * \param [in] target_state_params Model specific target state parameters (NULL: to be ignored).
  218. * \param [in] remaining_time Time from current state to target state (0: to be ignored).
  219. * \param [in] ext_params Additional parameters (NULL: to be ignored).
  220. *
  221. * \return API_SUCCESS or an error code indicating reason for failure
  222. */
  223. API_RESULT MS_light_lc_server_state_update
  224. (
  225. /* IN */ MS_ACCESS_MODEL_REQ_MSG_CONTEXT * ctx,
  226. /* IN */ MS_ACCESS_MODEL_STATE_PARAMS * current_state_params,
  227. /* IN */ MS_ACCESS_MODEL_STATE_PARAMS * target_state_params,
  228. /* IN */ UINT16 remaining_time,
  229. /* IN */ MS_ACCESS_MODEL_EXT_PARAMS * ext_params
  230. );
  231. /** \} */
  232. /**
  233. * \defgroup light_lc_cli_api_defs Light Lc Client API Definitions
  234. * \{
  235. * This section describes the Light Lc Client APIs.
  236. */
  237. /**
  238. * \brief API to initialize Light_Lc Client model
  239. *
  240. * \par Description
  241. * This is to initialize Light_Lc Client model and to register with Acess layer.
  242. *
  243. * \param [in] element_handle
  244. * Element identifier to be associated with the model instance.
  245. *
  246. * \param [in, out] model_handle
  247. * Model identifier associated with the model instance on successful initialization.
  248. * After power cycle of an already provisioned node, the model handle will have
  249. * valid value and the same will be reused for registration.
  250. *
  251. * \param [in] appl_cb Application Callback to be used by the Light_Lc Client.
  252. *
  253. * \return API_SUCCESS or an error code indicating reason for failure
  254. */
  255. API_RESULT MS_light_lc_client_init
  256. (
  257. /* IN */ MS_ACCESS_ELEMENT_HANDLE element_handle,
  258. /* INOUT */ MS_ACCESS_MODEL_HANDLE * model_handle,
  259. /* IN */ MS_LIGHT_LC_CLIENT_CB appl_cb
  260. );
  261. /**
  262. * \brief API to get Light_Lc client model handle
  263. *
  264. * \par Description
  265. * This is to get the handle of Light_Lc client model.
  266. *
  267. * \param [out] model_handle Address of model handle to be filled/returned.
  268. *
  269. * \return API_SUCCESS or an error code indicating reason for failure
  270. */
  271. API_RESULT MS_light_lc_client_get_model_handle
  272. (
  273. /* OUT */ MS_ACCESS_MODEL_HANDLE * model_handle
  274. );
  275. /**
  276. * \brief API to send acknowledged commands
  277. *
  278. * \par Description
  279. * This is to initialize sending acknowledged commands.
  280. *
  281. * \param [in] req_opcode Request Opcode.
  282. * \param [in] param Parameter associated with Request Opcode.
  283. * \param [in] rsp_opcode Response Opcode.
  284. *
  285. * \return API_SUCCESS or an error code indicating reason for failure
  286. */
  287. API_RESULT MS_light_lc_client_send_reliable_pdu
  288. (
  289. /* IN */ UINT32 req_opcode,
  290. /* IN */ void * param,
  291. /* IN */ UINT32 rsp_opcode
  292. );
  293. /**
  294. * \brief API to get the Light LC Mode state of an element.
  295. *
  296. * \par Description
  297. * Light LC Mode Get is an acknowledged message used to get the Light LC Mode state of an element.
  298. * The response to the Light LC Mode Get message is a Light LC Mode Status message.
  299. * There are no parameters for this message.
  300. *
  301. * \return API_SUCCESS or an error code indicating reason for failure
  302. */
  303. #define MS_light_lc_mode_get() \
  304. MS_light_lc_client_send_reliable_pdu \
  305. (\
  306. MS_ACCESS_LIGHT_LC_MODE_GET_OPCODE,\
  307. NULL,\
  308. MS_ACCESS_LIGHT_LC_MODE_STATUS_OPCODE\
  309. )
  310. /**
  311. * \brief API to set the Light LC Mode state of an element.
  312. *
  313. * \par Description
  314. * The Light LC Mode Set is an acknowledged message used to set the Light LC Mode state of an element.
  315. * The response to the Light LC Mode Set message is a Light LC Mode Status message.
  316. *
  317. * \param [in] param Light LC Mode Set message
  318. *
  319. * \return API_SUCCESS or an error code indicating reason for failure
  320. */
  321. #define MS_light_lc_mode_set(param) \
  322. MS_light_lc_client_send_reliable_pdu \
  323. (\
  324. MS_ACCESS_LIGHT_LC_MODE_SET_OPCODE,\
  325. param,\
  326. MS_ACCESS_LIGHT_LC_MODE_STATUS_OPCODE\
  327. )
  328. /**
  329. * \brief API to set the Light LC Mode state of an element.
  330. *
  331. * \par Description
  332. * The Light LC Mode Set Unacknowledged is an unacknowledged message used to
  333. * set the Light LC Mode state of an element.
  334. *
  335. * \param [in] param Light LC Mode Set message
  336. *
  337. * \return API_SUCCESS or an error code indicating reason for failure
  338. */
  339. #define MS_light_lc_mode_set_unacknowledged(param) \
  340. MS_light_lc_client_send_reliable_pdu \
  341. (\
  342. MS_ACCESS_LIGHT_LC_MODE_SET_UNACKNOWLEDGED_OPCODE,\
  343. param,\
  344. 0xFFFFFFFF\
  345. )
  346. /**
  347. * \brief API to get the Light LC Occupancy Mode state of an element.
  348. *
  349. * \par Description
  350. * Light LC OM Get is an acknowledged message used to get the Light LC Occupancy Mode state of an element.
  351. * The response to the Light LC OM Get message is a Light LC OM Status message.
  352. * There are no parameters for this message.
  353. *
  354. * \return API_SUCCESS or an error code indicating reason for failure
  355. */
  356. #define MS_light_lc_om_get() \
  357. MS_light_lc_client_send_reliable_pdu \
  358. (\
  359. MS_ACCESS_LIGHT_LC_OM_GET_OPCODE,\
  360. NULL,\
  361. MS_ACCESS_LIGHT_LC_OM_STATUS_OPCODE\
  362. )
  363. /**
  364. * \brief API to set the Light LC Occupancy Mode state of an element.
  365. *
  366. * \par Description
  367. * The Light LC OM Set is an acknowledged message used to set the Light LC Occupancy Mode state of an element.
  368. * The response to the Light LC OM Set message is a Light LC OM Status message.
  369. *
  370. * \param [in] param Light LC OM Set message
  371. *
  372. * \return API_SUCCESS or an error code indicating reason for failure
  373. */
  374. #define MS_light_lc_om_set(param) \
  375. MS_light_lc_client_send_reliable_pdu \
  376. (\
  377. MS_ACCESS_LIGHT_LC_OM_SET_OPCODE,\
  378. param,\
  379. MS_ACCESS_LIGHT_LC_OM_STATUS_OPCODE\
  380. )
  381. /**
  382. * \brief API to set the Light LC Occupancy Mode state of an element.
  383. *
  384. * \par Description
  385. * The Light LC OM Set Unacknowledged is an unacknowledged message used to set
  386. * the Light LC Occupancy Mode state of an element.
  387. *
  388. * \param [in] param Light LC OM Set message
  389. *
  390. * \return API_SUCCESS or an error code indicating reason for failure
  391. */
  392. #define MS_light_lc_om_set_unacknowledged(param) \
  393. MS_light_lc_client_send_reliable_pdu \
  394. (\
  395. MS_ACCESS_LIGHT_LC_OM_SET_UNACKNOWLEDGED_OPCODE,\
  396. param,\
  397. 0xFFFFFFFF\
  398. )
  399. /**
  400. * \brief API to get the Light LC Light OnOff state of an element.
  401. *
  402. * \par Description
  403. * Light LC Light OnOff Get is an acknowledged message used to get the Light LC Light OnOff state of an element.
  404. * The response to the Light LC Light OnOff Get message is a Light LC Light OnOff Status message.
  405. * There are no parameters for this message.
  406. *
  407. * \return API_SUCCESS or an error code indicating reason for failure
  408. */
  409. #define MS_light_lc_light_onoff_get() \
  410. MS_light_lc_client_send_reliable_pdu \
  411. (\
  412. MS_ACCESS_LIGHT_LC_LIGHT_ONOFF_GET_OPCODE,\
  413. NULL,\
  414. MS_ACCESS_LIGHT_LC_LIGHT_ONOFF_STATUS_OPCODE\
  415. )
  416. /**
  417. * \brief API to set the Light LC Light OnOff state of an element.
  418. *
  419. * \par Description
  420. * The Light LC Light OnOff Set is an acknowledged message used to set the Light LC Light OnOff state of an element.
  421. * The response to the Light LC Light OnOff Set message is a Light LC Light OnOff Status message.
  422. *
  423. * \param [in] param Light LC Light OnOff Set message
  424. *
  425. * \return API_SUCCESS or an error code indicating reason for failure
  426. */
  427. #define MS_light_lc_light_onoff_set(param) \
  428. MS_light_lc_client_send_reliable_pdu \
  429. (\
  430. MS_ACCESS_LIGHT_LC_LIGHT_ONOFF_SET_OPCODE,\
  431. param,\
  432. MS_ACCESS_LIGHT_LC_LIGHT_ONOFF_STATUS_OPCODE\
  433. )
  434. /**
  435. * \brief API to set the Light LC Light OnOff state of an element.
  436. *
  437. * \par Description
  438. * The Light LC Light OnOff Set Unacknowledged is an unacknowledged message
  439. * used to set the Light LC Light OnOff state of an element.
  440. *
  441. * \param [in] param Light LC Light OnOff Set message
  442. *
  443. * \return API_SUCCESS or an error code indicating reason for failure
  444. */
  445. #define MS_light_lc_light_onoff_set_unacknowledged(param) \
  446. MS_light_lc_client_send_reliable_pdu \
  447. (\
  448. MS_ACCESS_LIGHT_LC_LIGHT_ONOFF_SET_UNACKNOWLEDGED_OPCODE,\
  449. param,\
  450. 0xFFFFFFFF\
  451. )
  452. /**
  453. * \brief API to to get the Light LC Property state of an element.
  454. *
  455. * \par Description
  456. * Light LC Property Get is an acknowledged message used to get the Light LC Property state of an element.
  457. * The response to the Light LC Property Get message is a Light LC Property Status message.
  458. *
  459. * \param [in] param Light LC Property Get message
  460. *
  461. * \return API_SUCCESS or an error code indicating reason for failure
  462. */
  463. #define MS_light_lc_property_get(param) \
  464. MS_light_lc_client_send_reliable_pdu \
  465. (\
  466. MS_ACCESS_LIGHT_LC_PROPERTY_GET_OPCODE,\
  467. param,\
  468. MS_ACCESS_LIGHT_LC_PROPERTY_STATUS_OPCODE\
  469. )
  470. /**
  471. * \brief API to set the Light LC Property state of an element.
  472. *
  473. * \par Description
  474. * The Light LC Property Set is an acknowledged message used to set the Light LC Property state of an element.
  475. * The response to the Light LC Property Set message is a Light LC Property Status message.
  476. *
  477. * \param [in] param Light LC Property Set message
  478. *
  479. * \return API_SUCCESS or an error code indicating reason for failure
  480. */
  481. #define MS_light_lc_property_set(param) \
  482. MS_light_lc_client_send_reliable_pdu \
  483. (\
  484. MS_ACCESS_LIGHT_LC_PROPERTY_SET_OPCODE,\
  485. param,\
  486. MS_ACCESS_LIGHT_LC_PROPERTY_STATUS_OPCODE\
  487. )
  488. /**
  489. * \brief API to set the Light LC Property state of an element.
  490. *
  491. * \par Description
  492. * The Light LC Property Set Unacknowledged is an unacknowledged message used
  493. * to set the Light LC Property state of an element.
  494. *
  495. * \param [in] param Light LC Property Set message
  496. *
  497. * \return API_SUCCESS or an error code indicating reason for failure
  498. */
  499. #define MS_light_lc_property_set_unacknowledged(param) \
  500. MS_light_lc_client_send_reliable_pdu \
  501. (\
  502. MS_ACCESS_LIGHT_LC_PROPERTY_SET_UNACKNOWLEDGED_OPCODE,\
  503. param,\
  504. 0xFFFFFFFF\
  505. )
  506. /** \} */
  507. /** \} */
  508. /** \} */
  509. #endif /*_H_MS_LIGHT_LC_API_ */