MS_generic_location_api.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. /**
  2. * \file MS_generic_location_api.h
  3. *
  4. * \brief This file defines the Mesh Generic Location 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_GENERIC_LOCATION_API_
  12. #define _H_MS_GENERIC_LOCATION_API_
  13. /* --------------------------------------------- Header File Inclusion */
  14. #include "MS_access_api.h"
  15. /* --------------------------------------------- Global Definitions */
  16. /**
  17. * \defgroup generic_location_module GENERIC_LOCATION (Mesh Generic Location 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 generic_location_cb Application Callback
  25. * \{
  26. * This Section Describes the module Notification Callback interface offered
  27. * to the application
  28. */
  29. /**
  30. * Generic Location Server application Asynchronous Notification Callback.
  31. *
  32. * Generic Location 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_GENERIC_LOCATION_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. * Generic Location Client application Asynchronous Notification Callback.
  51. *
  52. * Generic Location 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_GENERIC_LOCATION_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. * Generic Location Setup Server application Asynchronous Notification Callback.
  69. *
  70. * Generic Location Setup Server calls the registered callback to indicate events occurred to the
  71. * application.
  72. *
  73. * \param [in] ctx Context of the message received for a specific model instance.
  74. * \param [in] msg_raw Uninterpreted/raw received message.
  75. * \param [in] req_type Requested message type.
  76. * \param [in] state_params Model specific state parameters.
  77. * \param [in] ext_params Additional parameters.
  78. */
  79. typedef API_RESULT (* MS_GENERIC_LOCATION_SETUP_SERVER_CB)
  80. (
  81. MS_ACCESS_MODEL_REQ_MSG_CONTEXT * ctx,
  82. MS_ACCESS_MODEL_REQ_MSG_RAW * msg_raw,
  83. MS_ACCESS_MODEL_REQ_MSG_T * req_type,
  84. MS_ACCESS_MODEL_STATE_PARAMS * state_params,
  85. MS_ACCESS_MODEL_EXT_PARAMS * ext_params
  86. ) DECL_REENTRANT;
  87. /** \} */
  88. /**
  89. * \defgroup generic_location_structures Structures
  90. * \{
  91. */
  92. /**
  93. * Generic Location Global Set message parameters.
  94. */
  95. typedef struct MS_generic_location_global_struct
  96. {
  97. /**
  98. * Global Coordinates (Latitude).
  99. * The Global Latitude field describes the global WGS84 North coordinate of the element.
  100. */
  101. UINT32 global_latitude;
  102. /**
  103. * Global Coordinates (Longitude).
  104. * The Global Longitude field describes the global WGS84 East coordinate of the element.
  105. */
  106. UINT32 global_longitude;
  107. /**
  108. * Global Altitude.
  109. * The Global Altitude field determines the altitude of the device above the WGS84 datum.
  110. * It expresses the altitude beyond the WGS84 ellipsoid of the element that exposed its position.
  111. *
  112. * Value | Description
  113. * --------------|------------
  114. * 0x7FFF | Global Altitude is not configured.
  115. * 0x7FFE | Global Altitude is greater than or equal to 32766 meters.
  116. * 0x8000-0x7FFD | Global Altitude is (field value) from -32768 meters through 32765 meters.
  117. */
  118. UINT16 global_altitude;
  119. } MS_GENERIC_LOCATION_GLOBAL_STRUCT;
  120. /**
  121. * Generic Location Local Set message parameters.
  122. */
  123. typedef struct MS_generic_location_local_struct
  124. {
  125. /**
  126. * Local Coordinates (North).
  127. * The Local North field describes the North coordinate of the device using a local coordinate system.
  128. * It is relative to the north orientation on a predefined map.
  129. *
  130. * The Local North value is encoded in decimeters and has a range of -32767 decimeters through 32767 decimeters.
  131. * The value 0x8000 means the Local North information is not configured.
  132. */
  133. UINT16 local_north;
  134. /**
  135. * Local Coordinates (East).
  136. * The Local East field describes the East coordinate of the device using a local coordinate system.
  137. * It is relative to the east orientation of a predefined map.
  138. *
  139. * The Local East value is encoded decimeters and it ranges from -32767 decimeters through 32767 decimeters.
  140. * The value 0x8000 means the Local East information is not configured.
  141. */
  142. UINT16 local_east;
  143. /**
  144. * Local Altitude.
  145. * The Local Altitude field determines the altitude of the device relative to the Generic Location Global Altitude.
  146. *
  147. * Value | Description
  148. * --------------|------------
  149. * 0x7FFF | Local Altitude is not configured.
  150. * 0x7FFE | Local Altitude is greater than or equal to 32766 meters.
  151. * 0x8000-0x7FFD | Local Altitude is (field value) from -32768 meters through 32765 meters.
  152. */
  153. UINT16 local_altitude;
  154. /**
  155. * Floor Number.
  156. *
  157. * The Floor Number field describes the floor number where the element is installed.
  158. * The floor number, N, is encoded as X = N + 20, where X is the encoded floor number.
  159. * Floor number = -20 (X=0) has a special meaning, indicating the floor -20, and also any floor below that.
  160. * Floor number = 232 (X=252) has a special meaning, indicating the floor 232, and also any floor above that.
  161. *
  162. * Encoded Value X | Floor number N
  163. * ----------------|---------------
  164. * 0x00 | Floor -20 or any floor below -20.
  165. * 0x01-0xFB | Floor number N, encoded as X = N + 20.
  166. * 0xFC | Floor 232 or any floor above 232.
  167. * 0xFD | Ground floor. Floor 0.
  168. * 0xFE | Ground floor. Floor 1.
  169. * 0xFF | Not configured
  170. *
  171. * Note: The reason for having two definitions of ground floor (0 or 1) is to allow for
  172. * different conventions applicable in different countries.
  173. */
  174. UCHAR floor_number;
  175. /**
  176. * Uncertainty.
  177. * The Uncertainty field is a 16-bit bit field that describes the uncertainty of
  178. * the location information the element exposes.
  179. *
  180. * bits | Field | Description
  181. * ------|-------------|------------
  182. * 0 | Stationary | This bit indicates whether the device broadcasting the location information
  183. * has a stationary location or is mobile. (0 = Stationary, 1 = Mobile)
  184. * 1-7 | RFU | Reserved for Future Use
  185. * 8-11 | Update Time | This value (x) is a 4-bit value ranging from 0 through 15.
  186. * It represents the time (t) elapsed since the last update of the device's position,
  187. * measured in seconds using the following formula: t=2^(x-3)
  188. * The represented range is from 0.125 seconds through 4096 seconds.
  189. * Note: If 'stationary' is set, this value can be ignored.
  190. * 12-15 | Precision | This value (y) is a 4-bit value ranging from 0 through 15.
  191. * It represents a location precision with the formula: Precision = 2^(y-3)
  192. * The represented range is from 0.125 meters through 4096 meters.
  193. */
  194. UINT16 uncertainty;
  195. } MS_GENERIC_LOCATION_LOCAL_STRUCT;
  196. /** \} */
  197. /* --------------------------------------------- Function */
  198. /**
  199. * \defgroup generic_location_api_defs API Definitions
  200. * \{
  201. * This section describes the EtherMind Mesh Generic Location Model APIs.
  202. */
  203. /**
  204. * \defgroup generic_location_ser_api_defs Generic Location Server API Definitions
  205. * \{
  206. * This section describes the Generic Location Server APIs.
  207. */
  208. /**
  209. * \brief API to initialize Generic_Location Server model
  210. *
  211. * \par Description
  212. * This is to initialize Generic_Location Server model and to register with Acess layer.
  213. *
  214. * \param [in] element_handle
  215. * Element identifier to be associated with the model instance.
  216. *
  217. * \param [in, out] model_handle
  218. * Model identifier associated with the model instance on successful initialization.
  219. * After power cycle of an already provisioned node, the model handle will have
  220. * valid value and the same will be reused for registration.
  221. *
  222. * \param [in] appl_cb Application Callback to be used by the Generic_Location Server.
  223. *
  224. * \return API_SUCCESS or an error code indicating reason for failure
  225. */
  226. API_RESULT MS_generic_location_server_init
  227. (
  228. /* IN */ MS_ACCESS_ELEMENT_HANDLE element_handle,
  229. /* INOUT */ MS_ACCESS_MODEL_HANDLE * model_handle,
  230. /* IN */ MS_GENERIC_LOCATION_SERVER_CB appl_cb
  231. );
  232. /**
  233. * \brief API to send reply or to update state change
  234. *
  235. * \par Description
  236. * This is to send reply for a request or to inform change in state.
  237. *
  238. * \param [in] ctx Context of the message.
  239. * \param [in] current_state_params Model specific current state parameters.
  240. * \param [in] target_state_params Model specific target state parameters (NULL: to be ignored).
  241. * \param [in] remaining_time Time from current state to target state (0: to be ignored).
  242. * \param [in] ext_params Additional parameters (NULL: to be ignored).
  243. *
  244. * \return API_SUCCESS or an error code indicating reason for failure
  245. */
  246. API_RESULT MS_generic_location_server_state_update
  247. (
  248. /* IN */ MS_ACCESS_MODEL_REQ_MSG_CONTEXT * ctx,
  249. /* IN */ MS_ACCESS_MODEL_STATE_PARAMS * current_state_params,
  250. /* IN */ MS_ACCESS_MODEL_STATE_PARAMS * target_state_params,
  251. /* IN */ UINT16 remaining_time,
  252. /* IN */ MS_ACCESS_MODEL_EXT_PARAMS * ext_params
  253. );
  254. /**
  255. * \brief API to initialize Generic_Location_Setup Server model
  256. *
  257. * \par Description
  258. * This is to initialize Generic_Location_Setup Server model and to register with Acess layer.
  259. *
  260. * \param [in] element_handle
  261. * Element identifier to be associated with the model instance.
  262. *
  263. * \param [in, out] model_handle
  264. * Model identifier associated with the model instance on successful initialization.
  265. * After power cycle of an already provisioned node, the model handle will have
  266. * valid value and the same will be reused for registration.
  267. *
  268. * \param [in] appl_cb Application Callback to be used by the Generic_Location_Setup Server.
  269. *
  270. * \return API_SUCCESS or an error code indicating reason for failure
  271. */
  272. API_RESULT MS_generic_location_setup_server_init
  273. (
  274. /* IN */ MS_ACCESS_ELEMENT_HANDLE element_handle,
  275. /* INOUT */ MS_ACCESS_MODEL_HANDLE * model_handle,
  276. /* IN */ MS_GENERIC_LOCATION_SETUP_SERVER_CB appl_cb
  277. );
  278. /**
  279. * \brief API to send reply or to update state change
  280. *
  281. * \par Description
  282. * This is to send reply for a request or to inform change in state.
  283. *
  284. * \param [in] ctx Context of the message.
  285. * \param [in] current_state_params Model specific current state parameters.
  286. * \param [in] target_state_params Model specific target state parameters (NULL: to be ignored).
  287. * \param [in] remaining_time Time from current state to target state (0: to be ignored).
  288. * \param [in] ext_params Additional parameters (NULL: to be ignored).
  289. *
  290. * \return API_SUCCESS or an error code indicating reason for failure
  291. */
  292. API_RESULT MS_generic_location_setup_server_state_update
  293. (
  294. /* IN */ MS_ACCESS_MODEL_REQ_MSG_CONTEXT * ctx,
  295. /* IN */ MS_ACCESS_MODEL_STATE_PARAMS * current_state_params,
  296. /* IN */ MS_ACCESS_MODEL_STATE_PARAMS * target_state_params,
  297. /* IN */ UINT16 remaining_time,
  298. /* IN */ MS_ACCESS_MODEL_EXT_PARAMS * ext_params
  299. );
  300. /** \} */
  301. /**
  302. * \defgroup generic_location_cli_api_defs Generic Location Client API Definitions
  303. * \{
  304. * This section describes the Generic Location Client APIs.
  305. */
  306. /**
  307. * \brief API to initialize Generic_Location Client model
  308. *
  309. * \par Description
  310. * This is to initialize Generic_Location Client model and to register with Acess layer.
  311. *
  312. * \param [in] element_handle
  313. * Element identifier to be associated with the model instance.
  314. *
  315. * \param [in, out] model_handle
  316. * Model identifier associated with the model instance on successful initialization.
  317. * After power cycle of an already provisioned node, the model handle will have
  318. * valid value and the same will be reused for registration.
  319. *
  320. * \param [in] appl_cb Application Callback to be used by the Generic_Location Client.
  321. *
  322. * \return API_SUCCESS or an error code indicating reason for failure
  323. */
  324. API_RESULT MS_generic_location_client_init
  325. (
  326. /* IN */ MS_ACCESS_ELEMENT_HANDLE element_handle,
  327. /* INOUT */ MS_ACCESS_MODEL_HANDLE * model_handle,
  328. /* IN */ MS_GENERIC_LOCATION_CLIENT_CB appl_cb
  329. );
  330. /**
  331. * \brief API to get Generic_Location client model handle
  332. *
  333. * \par Description
  334. * This is to get the handle of Generic_Location client model.
  335. *
  336. * \param [out] model_handle Address of model handle to be filled/returned.
  337. *
  338. * \return API_SUCCESS or an error code indicating reason for failure
  339. */
  340. API_RESULT MS_generic_location_client_get_model_handle
  341. (
  342. /* OUT */ MS_ACCESS_MODEL_HANDLE * model_handle
  343. );
  344. /**
  345. * \brief API to send acknowledged commands
  346. *
  347. * \par Description
  348. * This is to initialize sending acknowledged commands.
  349. *
  350. * \param [in] req_opcode Request Opcode.
  351. * \param [in] param Parameter associated with Request Opcode.
  352. * \param [in] rsp_opcode Response Opcode.
  353. *
  354. * \return API_SUCCESS or an error code indicating reason for failure
  355. */
  356. API_RESULT MS_generic_location_client_send_reliable_pdu
  357. (
  358. /* IN */ UINT32 req_opcode,
  359. /* IN */ void * param,
  360. /* IN */ UINT32 rsp_opcode
  361. );
  362. /**
  363. * \brief API to get the selected fields of the Generic Location state of an element.
  364. *
  365. * \par Description
  366. * Generic Location Global Get message is an acknowledged message used to get the selected fields
  367. * of the Generic Location state of an element.
  368. * The response to the Generic Location Global Get message is a Generic Location Global Status message.
  369. * There are no parameters for this message.
  370. *
  371. * \return API_SUCCESS or an error code indicating reason for failure
  372. */
  373. #define MS_generic_location_global_get() \
  374. MS_generic_location_client_send_reliable_pdu \
  375. (\
  376. MS_ACCESS_GENERIC_LOCATION_GLOBAL_GET_OPCODE,\
  377. NULL,\
  378. MS_ACCESS_GENERIC_LOCATION_GLOBAL_STATUS_OPCODE\
  379. )
  380. /**
  381. * \brief API to set the selected fields of the Generic Location state of an element.
  382. *
  383. * \par Description
  384. * Generic Location Global Set is an acknowledged message used to set the selected fields of the Generic Location state of an element.
  385. * The response to the Generic Location Global Set message is a Generic Location Global Status message.
  386. *
  387. * \param [in] param Generic Location Global Set message
  388. *
  389. * \return API_SUCCESS or an error code indicating reason for failure
  390. */
  391. #define MS_generic_location_global_set(param) \
  392. MS_generic_location_client_send_reliable_pdu \
  393. (\
  394. MS_ACCESS_GENERIC_LOCATION_GLOBAL_SET_OPCODE,\
  395. param,\
  396. MS_ACCESS_GENERIC_LOCATION_GLOBAL_STATUS_OPCODE\
  397. )
  398. /**
  399. * \brief API to set the selected fields of the Generic Location state of an element.
  400. *
  401. * \par Description
  402. * Generic Location Global Set Unacknowledged is an unacknowledged message used to set the selected fields
  403. * of the Generic Location state of an element.
  404. *
  405. * \return API_SUCCESS or an error code indicating reason for failure
  406. */
  407. #define MS_generic_location_global_set_unacknowledged(param) \
  408. MS_generic_location_client_send_reliable_pdu \
  409. (\
  410. MS_ACCESS_GENERIC_LOCATION_GLOBAL_SET_UNACKNOWLEDGED_OPCODE,\
  411. param,\
  412. 0xFFFFFFFF\
  413. )
  414. /**
  415. * \brief API to get the selected fields of the Generic Location state of an element.
  416. *
  417. * \par Description
  418. * Generic Location Local Get message is an acknowledged message used to get the selected fields
  419. * of the Generic Location state of an element.
  420. * The response to the Generic Location Local Get message is a Generic Location Local Status message.
  421. * There are no parameters for this message.
  422. *
  423. * \return API_SUCCESS or an error code indicating reason for failure
  424. */
  425. #define MS_generic_location_local_get() \
  426. MS_generic_location_client_send_reliable_pdu \
  427. (\
  428. MS_ACCESS_GENERIC_LOCATION_LOCAL_GET_OPCODE,\
  429. NULL,\
  430. MS_ACCESS_GENERIC_LOCATION_LOCAL_STATUS_OPCODE\
  431. )
  432. /**
  433. * \brief API to set the selected fields of the Generic Location state of an element.
  434. *
  435. * \par Description
  436. * Generic Location Local Set is an acknowledged message used to set the selected fields
  437. * of the Generic Location state of an element.
  438. * The response to the Generic Location Local Set message is a Generic Location Local Status message.
  439. *
  440. * \param [in] param Generic Location Local Set message
  441. *
  442. * \return API_SUCCESS or an error code indicating reason for failure
  443. */
  444. #define MS_generic_location_local_set(param) \
  445. MS_generic_location_client_send_reliable_pdu \
  446. (\
  447. MS_ACCESS_GENERIC_LOCATION_LOCAL_SET_OPCODE,\
  448. param,\
  449. MS_ACCESS_GENERIC_LOCATION_LOCAL_STATUS_OPCODE\
  450. )
  451. /**
  452. * \brief API to set the selected fields of the Generic Location state of an element.
  453. *
  454. * \par Description
  455. * Generic Location Local Set Unacknowledged is an unacknowledged message used to set the selected fields
  456. * of the Generic Location state of an element.
  457. *
  458. * \param [in] param Generic Location Local Set message
  459. *
  460. * \return API_SUCCESS or an error code indicating reason for failure
  461. */
  462. #define MS_generic_location_local_set_unacknowledged(param) \
  463. MS_generic_location_client_send_reliable_pdu \
  464. (\
  465. MS_ACCESS_GENERIC_LOCATION_LOCAL_SET_UNACKNOWLEDGED_OPCODE,\
  466. param,\
  467. 0xFFFFFFFF\
  468. )
  469. /** \} */
  470. /** \} */
  471. /** \} */
  472. #endif /*_H_MS_GENERIC_LOCATION_API_ */