MS_light_xyl_api.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /**
  2. * \file MS_light_xyl_api.h
  3. *
  4. * \brief This file defines the Mesh Light Xyl 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_XYL_API_
  12. #define _H_MS_LIGHT_XYL_API_
  13. /* --------------------------------------------- Header File Inclusion */
  14. #include "MS_access_api.h"
  15. /* --------------------------------------------- Global Definitions */
  16. /**
  17. * \defgroup light_xyl_module LIGHT_XYL (Mesh Light Xyl 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_xyl_cb Application Callback
  25. * \{
  26. * This Section Describes the module Notification Callback interface offered
  27. * to the application
  28. */
  29. /**
  30. * Light Xyl Server application Asynchronous Notification Callback.
  31. *
  32. * Light Xyl 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_XYL_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 Xyl Client application Asynchronous Notification Callback.
  51. *
  52. * Light Xyl 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_XYL_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_xyl_structures Structures
  70. * \{
  71. */
  72. /**
  73. * Light xyL Set message parameters.
  74. */
  75. typedef struct MS_light_xyl_set_struct
  76. {
  77. /** The target value of the Light xyL Lightness state */
  78. UINT16 xyl_lightness;
  79. /** The target value of the Light xyL x state */
  80. UINT16 xyl_x;
  81. /** The target value of the Light xyL y state */
  82. UINT16 xyl_y;
  83. /** Transaction Identifier */
  84. UCHAR tid;
  85. /**
  86. * Transition Time is a 1-octet value that consists of two fields:
  87. * - a 2-bit bit field representing the step resolution
  88. * - a 6-bit bit field representing the number of transition steps.
  89. *
  90. * Field | Size (bits) | Description
  91. * ---------------------------|-------------|----------------
  92. * Transition Number of Steps | 6 | The number of Steps
  93. * Transition Step Resolution | 2 | The resolution of the Default Transition
  94. * | Number of Steps field
  95. */
  96. UCHAR transition_time;
  97. /** Message execution delay in 5 milliseconds steps */
  98. UCHAR delay;
  99. /** Flag: To represent if optional Transaction time and Delay fields are valid */
  100. UCHAR optional_fields_present;
  101. } MS_LIGHT_XYL_SET_STRUCT;
  102. /**
  103. * Light xyL Status Unacknowledged message parameters.
  104. */
  105. typedef struct MS_light_xyl_status_struct
  106. {
  107. /** The present value of the Light xyL Lightness state */
  108. UINT16 xyl_lightness;
  109. /** The present value of the Light xyL x state */
  110. UINT16 xyl_x;
  111. /** The present value of the Light xyL y state */
  112. UINT16 xyl_y;
  113. /**
  114. * Remaining Time is a 1-octet value that consists of two fields:
  115. * - a 2-bit bit field representing the step resolution
  116. * - a 6-bit bit field representing the number of transition steps.
  117. *
  118. * Field | Size (bits) | Description
  119. * ---------------------------|-------------|----------------
  120. * Transition Number of Steps | 6 | The number of Steps
  121. * Transition Step Resolution | 2 | The resolution of the Default Transition
  122. * | Number of Steps field
  123. */
  124. UCHAR remaining_time;
  125. /** Flag: To represent if optional field Remaining Time is valid */
  126. UCHAR optional_fields_present;
  127. } MS_LIGHT_XYL_STATUS_STRUCT;
  128. /**
  129. * Light xyL Target Status Unacknowledged message parameters.
  130. */
  131. typedef struct MS_light_xyl_target_status_struct
  132. {
  133. /** The target value of the Light xyL Lightness state */
  134. UINT16 target_xyl_lightness;
  135. /** The target value of the Light xyL x state */
  136. UINT16 target_xyl_x;
  137. /** The target value of the Light xyL y state */
  138. UINT16 target_xyl_y;
  139. /**
  140. * Remaining Time is a 1-octet value that consists of two fields:
  141. * - a 2-bit bit field representing the step resolution
  142. * - a 6-bit bit field representing the number of transition steps.
  143. *
  144. * Field | Size (bits) | Description
  145. * ---------------------------|-------------|----------------
  146. * Transition Number of Steps | 6 | The number of Steps
  147. * Transition Step Resolution | 2 | The resolution of the Default Transition
  148. * | Number of Steps field
  149. */
  150. UCHAR remaining_time;
  151. /** Flag: To represent if optional field Remaining Time is valid */
  152. UCHAR optional_fields_present;
  153. } MS_LIGHT_XYL_TARGET_STATUS_STRUCT;
  154. /**
  155. * Light HSL Default Set message parameters.
  156. */
  157. typedef struct MS_light_xyl_default_set_struct
  158. {
  159. /** The value of the Light Lightness Default state */
  160. UINT16 lightness;
  161. /** The value of the Light xyL x Default state */
  162. UINT16 xyl_x;
  163. /** The value of the Light xyL y Default state */
  164. UINT16 xyl_y;
  165. } MS_LIGHT_XYL_DEFAULT_SET_STRUCT;
  166. /**
  167. * Light xyL Default Status message parameters.
  168. */
  169. typedef struct MS_light_xyl_default_status_struct
  170. {
  171. /** The value of the Light Lightness Default state */
  172. UINT16 lightness;
  173. /** The value of the Light xyL x Default state */
  174. UINT16 xyl_x;
  175. /** The value of the Light xyL y Default state */
  176. UINT16 xyl_y;
  177. } MS_LIGHT_XYL_DEFAULT_STATUS_STRUCT;
  178. /**
  179. * Light xyL Range Set message parameters.
  180. */
  181. typedef struct MS_light_xyl_range_set_struct
  182. {
  183. /** The value of the xyL x Range Min field of the Light xyL x Range state */
  184. UINT16 xyl_x_range_min;
  185. /** The value of the xyL x Range Max field of the Light xyL x Range state */
  186. UINT16 xyl_x_range_max;
  187. /** The value of the xyL y Range Min field of the Light xyL y Range state */
  188. UINT16 xyl_y_range_min;
  189. /** The value of the xyL y Range Max field of the Light xyL y Range state */
  190. UINT16 xyl_y_range_max;
  191. } MS_LIGHT_XYL_RANGE_SET_STRUCT;
  192. /**
  193. * Light xyL Range Status message parameters.
  194. */
  195. typedef struct MS_light_xyl_range_status_struct
  196. {
  197. /** Status Code for the requesting message. */
  198. UCHAR status_code;
  199. /** The value of the xyL x Range Min field of the Light xyL x Range state */
  200. UINT16 xyl_x_range_min;
  201. /** The value of the xyL x Range Max field of the Light xyL x Range state */
  202. UINT16 xyl_x_range_max;
  203. /** The value of the xyL y Range Min field of the Light xyL y Range state */
  204. UINT16 xyl_y_range_min;
  205. /** The value of the xyL y Range Max field of the Light xyL y Range state */
  206. UINT16 xyl_y_range_max;
  207. } MS_LIGHT_XYL_RANGE_STATUS_STRUCT;
  208. /** \} */
  209. /* --------------------------------------------- Function */
  210. /**
  211. * \defgroup light_xyl_api_defs API Definitions
  212. * \{
  213. * This section describes the EtherMind Mesh Light Xyl Model APIs.
  214. */
  215. /**
  216. * \defgroup light_xyl_ser_api_defs Light Xyl Server API Definitions
  217. * \{
  218. * This section describes the Light Xyl Server APIs.
  219. */
  220. /**
  221. * \brief API to initialize Light_Xyl Server model
  222. *
  223. * \par Description
  224. * This is to initialize Light_Xyl Server model and to register with Acess layer.
  225. *
  226. * \param [in] element_handle
  227. * Element identifier to be associated with the model instance.
  228. *
  229. * \param [in, out] xyl_model_handle
  230. * Model identifier associated with the Light xyl model instance on successful initialization.
  231. * After power cycle of an already provisioned node, the model handle will have
  232. * valid value and the same will be reused for registration.
  233. *
  234. * \param [in, out] xyl_setup_model_handle
  235. * Model identifier associated with the Light xyl Setup model instance on successful initialization.
  236. * After power cycle of an already provisioned node, the model handle will have
  237. * valid value and the same will be reused for registration.
  238. *
  239. * \param [in] appl_cb Application Callback to be used by the Light_Xyl Server.
  240. *
  241. * \return API_SUCCESS or an error code indicating reason for failure
  242. */
  243. API_RESULT MS_light_xyl_server_init
  244. (
  245. /* IN */ MS_ACCESS_ELEMENT_HANDLE element_handle,
  246. /* INOUT */ MS_ACCESS_MODEL_HANDLE * xyl_model_handle,
  247. /* INOUT */ MS_ACCESS_MODEL_HANDLE * xyl_setup_model_handle,
  248. /* IN */ MS_LIGHT_XYL_SERVER_CB appl_cb
  249. );
  250. /**
  251. * \brief API to send reply or to update state change
  252. *
  253. * \par Description
  254. * This is to send reply for a request or to inform change in state.
  255. *
  256. * \param [in] ctx Context of the message.
  257. * \param [in] current_state_params Model specific current state parameters.
  258. * \param [in] target_state_params Model specific target state parameters (NULL: to be ignored).
  259. * \param [in] remaining_time Time from current state to target state (0: to be ignored).
  260. * \param [in] ext_params Additional parameters (NULL: to be ignored).
  261. *
  262. * \return API_SUCCESS or an error code indicating reason for failure
  263. */
  264. API_RESULT MS_light_xyl_server_state_update
  265. (
  266. /* IN */ MS_ACCESS_MODEL_REQ_MSG_CONTEXT * ctx,
  267. /* IN */ MS_ACCESS_MODEL_STATE_PARAMS * current_state_params,
  268. /* IN */ MS_ACCESS_MODEL_STATE_PARAMS * target_state_params,
  269. /* IN */ UINT16 remaining_time,
  270. /* IN */ MS_ACCESS_MODEL_EXT_PARAMS * ext_params
  271. );
  272. /** \} */
  273. /**
  274. * \defgroup light_xyl_cli_api_defs Light Xyl Client API Definitions
  275. * \{
  276. * This section describes the Light Xyl Client APIs.
  277. */
  278. /**
  279. * \brief API to initialize Light_Xyl Client model
  280. *
  281. * \par Description
  282. * This is to initialize Light_Xyl Client model and to register with Acess layer.
  283. *
  284. * \param [in] element_handle
  285. * Element identifier to be associated with the model instance.
  286. *
  287. * \param [in, out] model_handle
  288. * Model identifier associated with the model instance on successful initialization.
  289. * After power cycle of an already provisioned node, the model handle will have
  290. * valid value and the same will be reused for registration.
  291. *
  292. * \param [in] appl_cb Application Callback to be used by the Light_Xyl Client.
  293. *
  294. * \return API_SUCCESS or an error code indicating reason for failure
  295. */
  296. API_RESULT MS_light_xyl_client_init
  297. (
  298. /* IN */ MS_ACCESS_ELEMENT_HANDLE element_handle,
  299. /* INOUT */ MS_ACCESS_MODEL_HANDLE * model_handle,
  300. /* IN */ MS_LIGHT_XYL_CLIENT_CB appl_cb
  301. );
  302. /**
  303. * \brief API to get Light_Xyl client model handle
  304. *
  305. * \par Description
  306. * This is to get the handle of Light_Xyl client model.
  307. *
  308. * \param [out] model_handle Address of model handle to be filled/returned.
  309. *
  310. * \return API_SUCCESS or an error code indicating reason for failure
  311. */
  312. API_RESULT MS_light_xyl_client_get_model_handle
  313. (
  314. /* OUT */ MS_ACCESS_MODEL_HANDLE * model_handle
  315. );
  316. /**
  317. * \brief API to send acknowledged commands
  318. *
  319. * \par Description
  320. * This is to initialize sending acknowledged commands.
  321. *
  322. * \param [in] req_opcode Request Opcode.
  323. * \param [in] param Parameter associated with Request Opcode.
  324. * \param [in] rsp_opcode Response Opcode.
  325. *
  326. * \return API_SUCCESS or an error code indicating reason for failure
  327. */
  328. API_RESULT MS_light_xyl_client_send_reliable_pdu
  329. (
  330. /* IN */ UINT32 req_opcode,
  331. /* IN */ void * param,
  332. /* IN */ UINT32 rsp_opcode
  333. );
  334. /**
  335. * \brief API to get the Light xyL Lightness, Light xyL x, and Light xyL y states of an element.
  336. *
  337. * \par Description
  338. * The Light xyL Get is an acknowledged message used to get the Light xyL
  339. * Lightness, Light xyL x, and Light xyL y states of an element.
  340. * Upon receiving a Light xyL Get message, the element shall respond with a Light xyL Status message.
  341. * The response to the Light xyL Get message is a Light xyL Status message.
  342. * There are no parameters for this message.
  343. *
  344. * \return API_SUCCESS or an error code indicating reason for failure
  345. */
  346. #define MS_light_xyl_get() \
  347. MS_light_xyl_client_send_reliable_pdu \
  348. (\
  349. MS_ACCESS_LIGHT_XYL_GET_OPCODE,\
  350. NULL,\
  351. MS_ACCESS_LIGHT_XYL_STATUS_OPCODE\
  352. )
  353. /**
  354. * \brief API to set the Light xyL Lightness, Light xyL x state, and the Light xyL y states of an element.
  355. *
  356. * \par Description
  357. * The Light xyL Set is an acknowledged message used to set the Light xyL Lightness, Light xyL x state, and the Light xyL y states of an element.
  358. * The response to the Light xyL Set message is a Light xyL Status message.
  359. *
  360. * \param [in] param Light xyL Set message
  361. *
  362. * \return API_SUCCESS or an error code indicating reason for failure
  363. */
  364. #define MS_light_xyl_set(param) \
  365. MS_light_xyl_client_send_reliable_pdu \
  366. (\
  367. MS_ACCESS_LIGHT_XYL_SET_OPCODE,\
  368. param,\
  369. MS_ACCESS_LIGHT_XYL_STATUS_OPCODE\
  370. )
  371. /**
  372. * \brief API to set the Light xyL Lightness, Light xyL x state, and the Light xyL y states of an element.
  373. *
  374. * \par Description
  375. * The Light xyL Set Unacknowledged is an unacknowledged message used to set
  376. * the Light xyL Lightness, Light xyL x, and the Light xyL y states of an
  377. * element.
  378. *
  379. * \param [in] param Light xyL Set message
  380. *
  381. * \return API_SUCCESS or an error code indicating reason for failure
  382. */
  383. #define MS_light_xyl_set_unacknowledged(param) \
  384. MS_light_xyl_client_send_reliable_pdu \
  385. (\
  386. MS_ACCESS_LIGHT_XYL_SET_UNACKNOWLEDGED_OPCODE,\
  387. param,\
  388. 0xFFFFFFFF\
  389. )
  390. /**
  391. * \brief API to get the target Light xyL Lightness, Light xyL x, and Light xyL y states of an element.
  392. *
  393. * \par Description
  394. * The Light xyL Target Get is an acknowledged message used to get the target Light xyL Lightness, Light xyL x, and Light xyL y states of an element.
  395. * The response to the Light xyL Target Get message is a Light xyL Target Status message.
  396. * There are no parameters for this message.
  397. *
  398. * \return API_SUCCESS or an error code indicating reason for failure
  399. */
  400. #define MS_light_xyl_target_get() \
  401. MS_light_xyl_client_send_reliable_pdu \
  402. (\
  403. MS_ACCESS_LIGHT_XYL_TARGET_GET_OPCODE,\
  404. NULL,\
  405. MS_ACCESS_LIGHT_XYL_TARGET_STATUS_OPCODE\
  406. )
  407. /**
  408. * \brief API to get the Light Lightness Default, the Light xyL x Default, and Light xyL y Default states of an element.
  409. *
  410. * \par Description
  411. * Light xyL Default Get is an acknowledged message used to get the Light Lightness Default, the Light xyL x Default, and Light xyL y Default states of an element.
  412. * The response to the Light xyL Default Get message is a Light xyL Default Status message.
  413. * There are no parameters for this message.
  414. *
  415. * \return API_SUCCESS or an error code indicating reason for failure
  416. */
  417. #define MS_light_xyl_default_get() \
  418. MS_light_xyl_client_send_reliable_pdu \
  419. (\
  420. MS_ACCESS_LIGHT_XYL_DEFAULT_GET_OPCODE,\
  421. NULL,\
  422. MS_ACCESS_LIGHT_XYL_DEFAULT_STATUS_OPCODE\
  423. )
  424. /**
  425. * \brief API to set the Light Lightness Default, the Light xyL x Default, and Light xyL y Default states of an element.
  426. *
  427. * \par Description
  428. * Light xyL Default Set is an acknowledged message used to set the Light Lightness Default, the Light xyL x Default, and Light xyL y Default states of an element.
  429. * The response to the Light xyL Default Set message is a Light xyL Default Status message.
  430. *
  431. * \param [in] param Light HSL Default Set message
  432. *
  433. * \return API_SUCCESS or an error code indicating reason for failure
  434. */
  435. #define MS_light_xyl_default_set(param) \
  436. MS_light_xyl_client_send_reliable_pdu \
  437. (\
  438. MS_ACCESS_LIGHT_XYL_DEFAULT_SET_OPCODE,\
  439. param,\
  440. MS_ACCESS_LIGHT_XYL_DEFAULT_STATUS_OPCODE\
  441. )
  442. /**
  443. * \brief API to set the Light Lightness Default, the Light xyL x Default, and Light xyL y Default states of an element.
  444. *
  445. * \par Description
  446. * Light xyL Default Set Unacknowledged is an unacknowledged message used to
  447. * set the Light Lightness Default, the Light xyL x Default, and Light xyL y
  448. * Default states of an element.
  449. *
  450. * \param [in] param Light HSL Default Set message
  451. *
  452. * \return API_SUCCESS or an error code indicating reason for failure
  453. */
  454. #define MS_light_xyl_default_set_unacknowledged(param) \
  455. MS_light_xyl_client_send_reliable_pdu \
  456. (\
  457. MS_ACCESS_LIGHT_XYL_DEFAULT_SET_UNACKNOWLEDGED_OPCODE,\
  458. param,\
  459. 0xFFFFFFFF\
  460. )
  461. /**
  462. * \brief API to get the Light xyL x Range and Light xyL y Range states of an element.
  463. *
  464. * \par Description
  465. * The Light xyL Range Get is an acknowledged message used to get the Light xyL x Range and Light xyL y Range states of an element.
  466. * The response to the Light xyL Range Get message is a Light xyL Range Status message.
  467. * There are no parameters for this message.
  468. *
  469. * \return API_SUCCESS or an error code indicating reason for failure
  470. */
  471. #define MS_light_xyl_range_get() \
  472. MS_light_xyl_client_send_reliable_pdu \
  473. (\
  474. MS_ACCESS_LIGHT_XYL_RANGE_GET_OPCODE,\
  475. NULL,\
  476. MS_ACCESS_LIGHT_XYL_RANGE_STATUS_OPCODE\
  477. )
  478. /**
  479. * \brief API to set the Light xyL x Range and Light xyL y Range states of an element.
  480. *
  481. * \par Description
  482. * Light xyL Range Set is an acknowledged message used to set the Light xyL x Range and Light xyL y Range states of an element.
  483. * The response to the Light xyL Range Set message is a Light xyL Range Status message.
  484. *
  485. * \param [in] param Light xyL Range Set message
  486. *
  487. * \return API_SUCCESS or an error code indicating reason for failure
  488. */
  489. #define MS_light_xyl_range_set(param) \
  490. MS_light_xyl_client_send_reliable_pdu \
  491. (\
  492. MS_ACCESS_LIGHT_XYL_RANGE_SET_OPCODE,\
  493. param,\
  494. MS_ACCESS_LIGHT_XYL_RANGE_STATUS_OPCODE\
  495. )
  496. /**
  497. * \brief API to set the Light xyL x Range and Light xyL y Range states of an element.
  498. *
  499. * \par Description
  500. * Light xyL Range Set Unacknowledged is an unacknowledged message used to set
  501. * the Light xyL x Range and Light xyL y Range states of an element.
  502. *
  503. * \param [in] param Light xyL Range Set message
  504. *
  505. * \return API_SUCCESS or an error code indicating reason for failure
  506. */
  507. #define MS_light_xyl_range_set_unacknowledged(param) \
  508. MS_light_xyl_client_send_reliable_pdu \
  509. (\
  510. MS_ACCESS_LIGHT_XYL_RANGE_SET_UNACKNOWLEDGED_OPCODE,\
  511. param,\
  512. 0xFFFFFFFF\
  513. )
  514. /** \} */
  515. /** \} */
  516. /** \} */
  517. #endif /*_H_MS_LIGHT_XYL_API_ */