lwm2m_objects.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. /**
  2. * Copyright (c) 2015 - 2019, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. /**@file lwm2m_objects.h
  41. *
  42. * @defgroup iot_sdk_lwm2m_objects OMA LWM2M objects definitions and types
  43. * @ingroup iot_sdk_lwm2m
  44. * @{
  45. * @brief OMA LWM2M objects definitions and types.
  46. *
  47. * @note The definitions used in this module are from the OMA LWM2M
  48. * "Lightweight Machine to Machine Technical Specification - OMA_TS-LightweightM2M-V1_0-20131210-C".
  49. * The specification could be found at http://openmobilealliance.org/.
  50. */
  51. #ifndef LWM2M_OBJECTS_H__
  52. #define LWM2M_OBJECTS_H__
  53. #include <stdint.h>
  54. #include <stdbool.h>
  55. #include "lwm2m_api.h"
  56. #ifdef __cplusplus
  57. extern "C" {
  58. #endif
  59. /* @brief LWM2M Enabler Object IDs Appendix E */
  60. #define LWM2M_OBJ_SECURITY 0
  61. #define LWM2M_OBJ_SERVER 1
  62. #define LWM2M_OBJ_ACL 2
  63. #define LWM2M_OBJ_DEVICE 3
  64. #define LWM2M_OBJ_CONN_MON 4
  65. #define LWM2M_OBJ_FIRMWARE 5
  66. #define LWM2M_OBJ_LOCATION 6
  67. #define LWM2M_OBJ_CONN_STAT 7
  68. /* @brief LWM2M Registry Objects */
  69. #define LWM2M_OBJ_SOFTWARE_UPDATE 9
  70. /* LWM2M Security Resource IDs Appendix E.1 */
  71. #define LWM2M_SECURITY_SERVER_URI 0
  72. #define LWM2M_SECURITY_BOOTSTRAP_SERVER 1
  73. #define LWM2M_SECURITY_SECURITY_MODE 2
  74. #define LWM2M_SECURITY_PUBLIC_KEY 3
  75. #define LWM2M_SECURITY_SERVER_PUBLIC_KEY 4
  76. #define LWM2M_SECURITY_SECRET_KEY 5
  77. #define LWM2M_SECURITY_SMS_SECURITY_MODE 6
  78. #define LWM2M_SECURITY_SMS_BINDING_KEY_PARAM 7
  79. #define LWM2M_SECURITY_SMS_BINDING_SECRET_KEY 8
  80. #define LWM2M_SECURITY_SERVER_SMS_NUMBER 9
  81. #define LWM2M_SECURITY_SHORT_SERVER_ID 10
  82. #define LWM2M_SECURITY_CLIENT_HOLD_OFF_TIME 11
  83. /* LWM2M Server Resources Appendix E.2 */
  84. #define LWM2M_SERVER_SHORT_SERVER_ID 0
  85. #define LWM2M_SERVER_LIFETIME 1
  86. #define LWM2M_SERVER_DEFAULT_MIN_PERIOD 2
  87. #define LWM2M_SERVER_DEFAULT_MAX_PERIOD 3
  88. #define LWM2M_SERVER_DISABLE 4
  89. #define LWM2M_SERVER_DISABLE_TIMEOUT 5
  90. #define LWM2M_SERVER_NOTIFY_WHEN_DISABLED 6
  91. #define LWM2M_SERVER_BINDING 7
  92. #define LWM2M_SERVER_REGISTRATION_UPDATE_TRIGGER 8
  93. /* LWM2M Firmware update Resources Appendix E.6 */
  94. #define LWM2M_FIRMWARE_PACKAGE 0
  95. #define LWM2M_FIRMWARE_PACKAGE_URI 1
  96. #define LWM2M_FIRMWARE_UPDATE 2
  97. #define LWM2M_FIRMWARE_STATE 3
  98. #define LWM2M_FIRMWARE_UPDATE_SUPPORTED_OBJECTS 4
  99. #define LWM2M_FIRMWARE_UPDATE_RESULT 5
  100. #define LWM2M_FIRMWARE_STATE_IDLE 1
  101. #define LWM2M_FIRMWARE_STATE_DOWNLOADING 2
  102. #define LWM2M_FIRMWARE_STATE_DOWNLOADED 3
  103. #define LWM2M_FIRMWARE_UPDATE_RESULT_DEFAULT 0
  104. #define LWM2M_FIRMWARE_UPDATE_RESULT_SUCCESS 1
  105. #define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_STORAGE 2
  106. #define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_MEMORY 3
  107. #define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_CONN_LOST 4
  108. #define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_CRC 5
  109. #define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_UNSUPPORTED 6
  110. #define LWM2M_FIRMWARE_UPDATE_RESULT_ERROR_INVALID_URI 7
  111. /* LWM2M ACL Resources */
  112. #define LWM2M_ACL_OBJECT_ID 0
  113. #define LWM2M_ACL_INSTANCE_ID 1
  114. #define LWM2M_ACL_ACL 2
  115. #define LWM2M_ACL_CONTROL_OWNER 3
  116. /* LWM2M Connectivity Monitoring Resources */
  117. #define LWM2M_CONN_MON_NETWORK_BEARER 0
  118. #define LWM2M_CONN_MON_AVAILABLE_NETWORK_BEARER 1
  119. #define LWM2M_CONN_MON_RADIO_SIGNAL_STRENGHT 2
  120. #define LWM2M_CONN_MON_LINK_QUALITY 3
  121. #define LWM2M_CONN_MON_IP_ADDRESSES 4
  122. #define LWM2M_CONN_MON_ROUTER_IP_ADRESSES 5
  123. #define LWM2M_CONN_MON_LINK_UTILIZATION 6
  124. #define LWM2M_CONN_MON_APN 7
  125. #define LWM2M_CONN_MON_CELL_ID 8
  126. #define LWM2M_CONN_MON_SMNC 9
  127. #define LWM2M_CONN_MON_SMCC 10
  128. /* LWM2M Connectivity Statistics */
  129. #define LWM2M_CONN_STAT_SMS_TX_COUNTER 0
  130. #define LWM2M_CONN_STAT_SMS_RX_COUNTER 1
  131. #define LWM2M_CONN_STAT_TX_DATA 2
  132. #define LWM2M_CONN_STAT_RX_DATA 3
  133. #define LWM2M_CONN_STAT_MAX_MSG_SIZE 4
  134. #define LWM2M_CONN_STAT_AVG_MSG_SIZE 5
  135. #define LWM2M_CONN_STAT_START_RESET 6
  136. /* LWM2M Device */
  137. #define LWM2M_DEVICE_MANUFACTURER 0
  138. #define LWM2M_DEVICE_MODEL_NUMBER 1
  139. #define LWM2M_DEVICE_SERIAL_NUMBER 2
  140. #define LWM2M_DEVICE_FIRMWARE_VERSION 3
  141. #define LWM2M_DEVICE_REBOOT 4
  142. #define LWM2M_DEVICE_FACTORY_RESET 5
  143. #define LWM2M_DEVICE_AVAILABLE_POWER_SOURCES 6
  144. #define LWM2M_DEVICE_POWER_SOURCE_VOLTAGE 7
  145. #define LWM2M_DEVICE_POWER_SOURCE_CURRENT 8
  146. #define LWM2M_DEVICE_BATTERY_LEVEL 9
  147. #define LWM2M_DEVICE_MEMORY_FREE 10
  148. #define LWM2M_DEVICE_ERROR_CODE 11
  149. #define LWM2M_DEVICE_RESET_ERROR_CODE 12
  150. #define LWM2M_DEVICE_CURRENT_TIME 13
  151. #define LWM2M_DEVICE_UTC_OFFSET 14
  152. #define LWM2M_DEVICE_TIMEZONE 15
  153. #define LWM2M_DEVICE_SUPPORTED_BINDINGS 16
  154. /* LWM2M Location */
  155. #define LWM2M_LOCATION_LATITUDE 0
  156. #define LWM2M_LOCATION_LONGITUDE 1
  157. #define LWM2M_LOCATION_ALTITUDE 2
  158. #define LWM2M_LOCATION_UNCERTAINTY 3
  159. #define LWM2M_LOCATION_VELOCITY 4
  160. #define LWM2M_LOCATION_TIMESTAMP 5
  161. /* LWM2M Software update */
  162. #define LWM2M_SW_UPDATE_PKG_NAME 0
  163. #define LWM2M_SW_UPDATE_PKG_VERSION 1
  164. #define LWM2M_SW_UPDATE_PACKAGE 2
  165. #define LWM2M_SW_UPDATE_PACKAGE_URI 3
  166. #define LWM2M_SW_UPDATE_INSTALL 4
  167. #define LWM2M_SW_UPDATE_CHECKPOINT 5
  168. #define LWM2M_SW_UPDATE_UNINSTALL 6
  169. #define LWM2M_SW_UPDATE_UPDATE_STATE 7
  170. #define LWM2M_SW_UPDATE_SUPPORTED_OBJECTS 8
  171. /**
  172. * LWM2M Enabler
  173. */
  174. typedef struct
  175. {
  176. lwm2m_instance_prototype_t proto; /* Internal. MUST be first. */
  177. uint8_t operations[12]; /* Internal. MUST be second. */
  178. uint16_t resource_ids[12]; /* Internal. MUST be third. */
  179. /* Public members. */
  180. lwm2m_string_t server_uri;
  181. bool bootstrap_server;
  182. uint8_t security_mode;
  183. lwm2m_opaque_t public_key;
  184. lwm2m_opaque_t server_public_key;
  185. lwm2m_opaque_t secret_key;
  186. uint8_t sms_security_mode;
  187. lwm2m_opaque_t sms_binding_key_param;
  188. lwm2m_opaque_t sms_binding_secret_keys;
  189. uint32_t sms_number;
  190. uint16_t short_server_id;
  191. lwm2m_time_t client_hold_off_time;
  192. } lwm2m_security_t;
  193. typedef struct
  194. {
  195. lwm2m_instance_prototype_t proto; /* Internal. MUST be first. */
  196. uint8_t operations[9]; /* Internal. MUST be second. */
  197. uint16_t resource_ids[9]; /* Internal. MUST be third. */
  198. /* Public members. */
  199. uint16_t short_server_id;
  200. lwm2m_time_t lifetime;
  201. lwm2m_time_t default_minimum_period;
  202. lwm2m_time_t default_maximum_period;
  203. void * disable; // Function pointer.
  204. lwm2m_time_t disable_timeout;
  205. bool notification_storing_on_disabled;
  206. lwm2m_string_t binding;
  207. void * registration_update_trigger; // Function pointer.
  208. } lwm2m_server_t;
  209. typedef struct
  210. {
  211. lwm2m_instance_prototype_t proto; /* Internal. MUST be first. */
  212. uint8_t operations[6]; /* Internal. MUST be second. */
  213. uint16_t resource_ids[6]; /* Internal. MUST be third. */
  214. /* Public members. */
  215. lwm2m_opaque_t package;
  216. lwm2m_string_t package_uri;
  217. uint8_t state;
  218. bool update_supported_objects;
  219. uint8_t update_result;
  220. } lwm2m_firmware_t;
  221. typedef struct
  222. {
  223. lwm2m_instance_prototype_t proto;
  224. uint8_t operations[4];
  225. uint16_t resource_ids[4];
  226. /* Public members. */
  227. uint16_t acl_object_id;
  228. uint16_t acl_instance_id;
  229. uint16_t acl;
  230. uint16_t control_owner;
  231. } lwm2m_acl_t;
  232. typedef struct
  233. {
  234. lwm2m_instance_prototype_t proto;
  235. uint8_t operations[11];
  236. uint16_t resource_ids[11];
  237. /* Public members. */
  238. uint32_t network_bearer;
  239. uint32_t available_network_bearer;// TODO this is a list!
  240. uint32_t radio_signal_strength; // Unit: dBm
  241. uint32_t link_quality;
  242. lwm2m_string_t ip_addresses; // TODO: this is a list!
  243. lwm2m_string_t router_ip_addresses; // TODO: this is a list!
  244. uint8_t link_utilization; // Unit: percent
  245. lwm2m_string_t apn; // TODO: this is a list!
  246. uint32_t cell_id;
  247. uint8_t smnc; // Unit: percent
  248. uint32_t smcc;
  249. } lwm2m_connectivity_monitoring_t;
  250. typedef struct
  251. {
  252. lwm2m_instance_prototype_t proto;
  253. uint8_t operations[7];
  254. uint16_t resource_ids[7];
  255. /* Public members. */
  256. uint32_t sms_tx_counter;
  257. uint32_t sms_rx_counter;
  258. uint32_t tx_data; // Unit: kilo-bytes
  259. uint32_t rx_data; // Unit: kilo-bytes
  260. uint32_t max_message_size; // Unit: byte
  261. uint32_t average_message_size; // Unit: byte
  262. /* StartOrReset is Execute only */
  263. } lwm2m_connectivity_statistics_t;
  264. typedef struct
  265. {
  266. lwm2m_instance_prototype_t proto;
  267. uint8_t operations[17];
  268. uint16_t resource_ids[17];
  269. /* Public members. */
  270. lwm2m_string_t manufacturer;
  271. lwm2m_string_t model_number;
  272. lwm2m_string_t serial_number;
  273. lwm2m_string_t firmware_version;
  274. /* Reboot is execute only */
  275. /* Factory reset is execute only */
  276. uint8_t avail_power_sources; // TODO: this is a list, Range: 0-7
  277. uint32_t power_source_voltage; // TODO: this is a list, Unit: mV
  278. uint32_t power_source_current; // TODO: this is a list, Unit: mA
  279. uint8_t battery_level; // Unit: percent
  280. uint32_t memory_free; // Unit: KB
  281. uint32_t error_code; // TODO: this is a list
  282. /* Reset Error code is execute only */
  283. lwm2m_time_t current_time;
  284. lwm2m_string_t utc_offset;
  285. lwm2m_string_t timezone;
  286. lwm2m_string_t supported_bindings; // TODO this is a list
  287. } lwm2m_device_t;
  288. typedef struct
  289. {
  290. lwm2m_instance_prototype_t proto;
  291. uint8_t operations[6];
  292. uint16_t resource_ids[6];
  293. /* Public members. */
  294. lwm2m_string_t latitude; // Unit: Deg
  295. lwm2m_string_t longitude; // Unit: Deg
  296. lwm2m_string_t altitude; // Unit: m
  297. lwm2m_string_t uncertainty; // Unit: m
  298. lwm2m_opaque_t velocity; // Unit: Refers to 3GPP GAD specs
  299. lwm2m_time_t timestamp; // Range: 0-6
  300. } lwm2m_location_t;
  301. typedef struct
  302. {
  303. lwm2m_instance_prototype_t proto;
  304. uint8_t operations[9];
  305. uint16_t resource_ids[9];
  306. /* Public members. */
  307. lwm2m_string_t pkg_name;
  308. lwm2m_string_t pkg_version;
  309. lwm2m_opaque_t package;
  310. lwm2m_string_t package_uri;
  311. /* Install is execute only */
  312. uint16_t checkpoint; // TODO: this is of type Objlnk
  313. /* Uninstall is execute only */
  314. uint8_t update_state; // Range: 1-5
  315. bool update_supported_objects;
  316. } lwm2m_software_update_t;
  317. /**@brief Initialize a LWM2M security object instance.
  318. *
  319. * @details Must be called before any use of the instance.
  320. *
  321. * @param[in] p_instance Pointer to instance structure to initialize.
  322. */
  323. void lwm2m_instance_security_init(lwm2m_security_t * p_instance);
  324. /**@brief Initialize a LWM2M server object instance.
  325. *
  326. * @details Must be called before any use of the instance.
  327. * @param[in] p_instance Pointer to instance structure to initialize.
  328. */
  329. void lwm2m_instance_server_init(lwm2m_server_t * p_instance);
  330. /**@brief Initialize a LWM2M firmware object instance.
  331. *
  332. * @details Must be called before any use of the instance.
  333. *
  334. * @param[in] p_instance Pointer to instance structure to initialize.
  335. */
  336. void lwm2m_instance_firmware_init(lwm2m_firmware_t * p_instance);
  337. /**@brief Initialize a LWM2M ACL object instance
  338. *
  339. * @details Must be called before any use of the instance.
  340. *
  341. * @param[in] p_instance Pointer to instance structure to initialize.
  342. */
  343. void lwm2m_instance_acl_init(lwm2m_acl_t * p_instance);
  344. /**@brief Initialize a LWM2M connectivity monitoring object instance
  345. *
  346. * @details Must be called before any use of the instance.
  347. *
  348. * @param[in] p_instance Pointer to instance structure to initialize.
  349. */
  350. void lwm2m_instance_connectivity_monitoring_init(lwm2m_connectivity_monitoring_t * p_instance);
  351. /**@brief Initialize a LWM2M connectivity statistics object instance
  352. *
  353. * @details Must be called before any use of the instance.
  354. *
  355. * @param[in] p_instance Pointer to instance structure to initialize.
  356. */
  357. void lwm2m_instance_connectivity_statistics_init(lwm2m_connectivity_statistics_t * p_instance);
  358. /**@brief Initialize a LWM2M device object instance
  359. *
  360. * @details Must be called before any use of the instance.
  361. *
  362. * @param[in] p_instance Pointer to instance structure to initialize.
  363. */
  364. void lwm2m_instance_device_init(lwm2m_device_t * p_instance);
  365. /**@brief Initialize a LWM2M location object instance
  366. *
  367. * @details Must be called before any use of the instance.
  368. *
  369. * @param[in] p_instance Pointer to instance structure to initialize.
  370. */
  371. void lwm2m_instance_location_init(lwm2m_location_t * p_instance);
  372. /**@brief Initialize a LWM2M software update object instance
  373. *
  374. * @details Must be called before any use of the instance.
  375. *
  376. * @param[in] p_instance Pointer to instance structure to initialize.
  377. */
  378. void lwm2m_instance_software_update_init(lwm2m_software_update_t * p_instance);
  379. #ifdef __cplusplus
  380. }
  381. #endif
  382. #endif // LWM2M_OBJECTS_H__
  383. /** @} */