ipso_objects.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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. #include <string.h>
  41. #include <stddef.h>
  42. #include "ipso_objects.h"
  43. #include "lwm2m.h"
  44. #include "lwm2m_tlv.h"
  45. //lint -e516 -save // Symbol '__INTADDR__()' has arg. type conflict
  46. #define LWM2M_INSTANCE_OFFSET_SET(instance, type) \
  47. instance->proto.operations_offset = offsetof(type, operations); \
  48. instance->proto.resource_ids_offset = offsetof(type, resource_ids);
  49. //lint -restore
  50. void ipso_instance_digital_input_init(ipso_digital_input_t * p_instance)
  51. {
  52. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_digital_input_t);
  53. p_instance->proto.object_id = IPSO_SO_ID_DIGITAL_INPUT;
  54. p_instance->proto.instance_id = 0;
  55. p_instance->proto.num_resources = sizeof(((ipso_digital_input_t *)0)->operations);
  56. // Set access types.
  57. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  58. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  59. p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  60. p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  61. p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  62. p_instance->operations[5] = LWM2M_OPERATION_CODE_EXECUTE;
  63. p_instance->operations[6] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  64. p_instance->operations[7] = LWM2M_OPERATION_CODE_READ;
  65. // Set resource IDs.
  66. p_instance->resource_ids[0] = IPSO_RR_ID_DIGITAL_INPUT_STATE;
  67. p_instance->resource_ids[1] = IPSO_RR_ID_DIGITAL_INPUT_COUNTER;
  68. p_instance->resource_ids[2] = IPSO_RR_ID_DIGITAL_INPUT_POLARITY;
  69. p_instance->resource_ids[3] = IPSO_RR_ID_DIGITAL_INPUT_DEBOUNCE_PERIOD;
  70. p_instance->resource_ids[4] = IPSO_RR_ID_DIGITAL_INPUT_EDGE_SELECTION;
  71. p_instance->resource_ids[5] = IPSO_RR_ID_DIGITAL_INPUT_COUNTER_RESET;
  72. p_instance->resource_ids[6] = IPSO_RR_ID_APPLICATION_TYPE;
  73. p_instance->resource_ids[7] = IPSO_RR_ID_SENSOR_TYPE;
  74. }
  75. void ipso_instance_digital_output_init(ipso_digital_output_t * p_instance)
  76. {
  77. // Set prototype variables.
  78. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_digital_output_t);
  79. p_instance->proto.object_id = IPSO_SO_ID_DIGITAL_OUTPUT;
  80. p_instance->proto.instance_id = 0;
  81. p_instance->proto.num_resources = sizeof(((ipso_digital_output_t *)0)->operations);
  82. // Set access types.
  83. p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  84. p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  85. p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  86. // Set resource IDs.
  87. p_instance->resource_ids[0] = IPSO_RR_ID_DIGITAL_OUTPUT_STATE;
  88. p_instance->resource_ids[1] = IPSO_RR_ID_DIGITAL_OUTPUT_POLARITY;
  89. p_instance->resource_ids[2] = IPSO_RR_ID_APPLICATION_TYPE;
  90. }
  91. void ipso_instance_analog_input_init(ipso_analog_input_t * p_instance)
  92. {
  93. // Set prototype variables.
  94. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_analog_input_t);
  95. p_instance->proto.object_id = IPSO_SO_ID_ANALOGUE_INPUT;
  96. p_instance->proto.instance_id = 0;
  97. p_instance->proto.num_resources = sizeof(((ipso_analog_input_t *)0)->operations);
  98. // Set access types.
  99. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  100. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  101. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  102. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  103. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  104. p_instance->operations[5] = LWM2M_OPERATION_CODE_EXECUTE;
  105. p_instance->operations[6] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  106. p_instance->operations[7] = LWM2M_OPERATION_CODE_READ;
  107. // Set resource IDs.
  108. p_instance->resource_ids[0] = IPSO_RR_ID_ANALOG_INPUT_CURRENT_VALUE;
  109. p_instance->resource_ids[1] = IPSO_RR_ID_MIN_MEASURED_VALUE;
  110. p_instance->resource_ids[2] = IPSO_RR_ID_MAX_MEASURED_VALUE;
  111. p_instance->resource_ids[3] = IPSO_RR_ID_MIN_RANGE_VALUE;
  112. p_instance->resource_ids[4] = IPSO_RR_ID_MAX_RANGE_VALUE;
  113. p_instance->resource_ids[5] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
  114. p_instance->resource_ids[6] = IPSO_RR_ID_APPLICATION_TYPE;
  115. p_instance->resource_ids[7] = IPSO_RR_ID_SENSOR_TYPE;
  116. }
  117. void ipso_instance_analog_output_init(ipso_analog_output_t * p_instance)
  118. {
  119. // Set prototype variables.
  120. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_analog_output_t);
  121. p_instance->proto.object_id = IPSO_SO_ID_ANALOGUE_OUTPUT;
  122. p_instance->proto.instance_id = 0;
  123. p_instance->proto.num_resources = sizeof(((ipso_analog_output_t *)0)->operations);
  124. // Set access types.
  125. p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  126. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  127. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  128. p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  129. // Set resource IDs.
  130. p_instance->resource_ids[0] = IPSO_RR_ID_ANALOG_OUTPUT_CURRENT_VALUE;
  131. p_instance->resource_ids[1] = IPSO_RR_ID_MIN_RANGE_VALUE;
  132. p_instance->resource_ids[2] = IPSO_RR_ID_MAX_RANGE_VALUE;
  133. p_instance->resource_ids[3] = IPSO_RR_ID_APPLICATION_TYPE;
  134. }
  135. void ipso_instance_generic_sensor_init(ipso_generic_sensor_t * p_instance)
  136. {
  137. // Set prototype variables.
  138. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_generic_sensor_t);
  139. p_instance->proto.object_id = IPSO_SO_ID_GENERIC_SENSOR;
  140. p_instance->proto.instance_id = 0;
  141. p_instance->proto.num_resources = sizeof(((ipso_generic_sensor_t *)0)->operations);
  142. // Set access types.
  143. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  144. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  145. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  146. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  147. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  148. p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
  149. p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
  150. p_instance->operations[7] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  151. p_instance->operations[8] = LWM2M_OPERATION_CODE_READ;
  152. // Set resource IDs.
  153. p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
  154. p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
  155. p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
  156. p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
  157. p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
  158. p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
  159. p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
  160. p_instance->resource_ids[7] = IPSO_RR_ID_APPLICATION_TYPE;
  161. p_instance->resource_ids[8] = IPSO_RR_ID_SENSOR_TYPE;
  162. }
  163. void ipso_instance_illuminance_init(ipso_illuminance_t * p_instance)
  164. {
  165. // Set prototype variables.
  166. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_illuminance_t);
  167. p_instance->proto.object_id = IPSO_SO_ID_ILLUMINANCE_SENSOR;
  168. p_instance->proto.instance_id = 0;
  169. p_instance->proto.num_resources = sizeof(((ipso_illuminance_t *)0)->operations);
  170. // Set access types.
  171. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  172. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  173. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  174. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  175. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  176. p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
  177. p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
  178. // Set resource IDs.
  179. p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
  180. p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
  181. p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
  182. p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
  183. p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
  184. p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
  185. p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
  186. }
  187. void ipso_instance_presence_init(ipso_presence_t * p_instance)
  188. {
  189. // Set prototype variables.
  190. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_presence_t);
  191. p_instance->proto.object_id = IPSO_SO_ID_PRESENCE_SENSOR;
  192. p_instance->proto.instance_id = 0;
  193. p_instance->proto.num_resources = sizeof(((ipso_presence_t *)0)->operations);
  194. // Set access types.
  195. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  196. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  197. p_instance->operations[2] = LWM2M_OPERATION_CODE_EXECUTE;
  198. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  199. p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  200. p_instance->operations[5] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  201. // Set resource IDs.
  202. p_instance->resource_ids[0] = IPSO_RR_ID_DIGITAL_INPUT_STATE;
  203. p_instance->resource_ids[1] = IPSO_RR_ID_DIGITAL_INPUT_COUNTER;
  204. p_instance->resource_ids[2] = IPSO_RR_ID_DIGITAL_INPUT_COUNTER_RESET;
  205. p_instance->resource_ids[3] = IPSO_RR_ID_SENSOR_TYPE;
  206. p_instance->resource_ids[4] = IPSO_RR_ID_BUSY_TO_CLEAR_DELAY;
  207. p_instance->resource_ids[5] = IPSO_RR_ID_CLEAR_TO_BUSY_DELAY;
  208. }
  209. void ipso_instance_temperature_init(ipso_temperature_t * p_instance)
  210. {
  211. // Set prototype variables.
  212. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_temperature_t);
  213. p_instance->proto.object_id = IPSO_SO_ID_TEMPERATURE_SENSOR;
  214. p_instance->proto.instance_id = 0;
  215. p_instance->proto.num_resources = sizeof(((ipso_temperature_t *)0)->operations);
  216. // Set access types.
  217. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  218. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  219. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  220. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  221. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  222. p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
  223. p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
  224. // Set resource IDs.
  225. p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
  226. p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
  227. p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
  228. p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
  229. p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
  230. p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
  231. p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
  232. }
  233. void ipso_instance_humidity_init(ipso_humidity_t * p_instance)
  234. {
  235. // Set prototype variables.
  236. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_humidity_t);
  237. p_instance->proto.object_id = IPSO_SO_ID_HUMIDITY_SENSOR;
  238. p_instance->proto.instance_id = 0;
  239. p_instance->proto.num_resources = sizeof(((ipso_humidity_t *)0)->operations);
  240. // Set access types.
  241. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  242. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  243. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  244. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  245. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  246. p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
  247. p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
  248. // Set resource IDs.
  249. p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
  250. p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
  251. p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
  252. p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
  253. p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
  254. p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
  255. p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
  256. }
  257. void ipso_instance_power_measurement_init(ipso_power_measurement_t * p_instance)
  258. {
  259. // Set prototype variables.
  260. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_power_measurement_t);
  261. p_instance->proto.object_id = IPSO_SO_ID_POWER_MEASUREMENT;
  262. p_instance->proto.instance_id = 0;
  263. p_instance->proto.num_resources = sizeof(((ipso_power_measurement_t *)0)->operations);
  264. // Set access types.
  265. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  266. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  267. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  268. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  269. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  270. p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
  271. p_instance->operations[6] = LWM2M_OPERATION_CODE_WRITE;
  272. p_instance->operations[7] = LWM2M_OPERATION_CODE_READ;
  273. p_instance->operations[8] = LWM2M_OPERATION_CODE_READ;
  274. p_instance->operations[9] = LWM2M_OPERATION_CODE_READ;
  275. p_instance->operations[10] = LWM2M_OPERATION_CODE_READ;
  276. p_instance->operations[11] = LWM2M_OPERATION_CODE_READ;
  277. p_instance->operations[12] = LWM2M_OPERATION_CODE_EXECUTE;
  278. p_instance->operations[13] = LWM2M_OPERATION_CODE_READ;
  279. p_instance->operations[14] = LWM2M_OPERATION_CODE_WRITE;
  280. p_instance->operations[15] = LWM2M_OPERATION_CODE_READ;
  281. p_instance->operations[16] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  282. p_instance->operations[17] = LWM2M_OPERATION_CODE_EXECUTE;
  283. // Set resource IDs.
  284. p_instance->resource_ids[0] = IPSO_RR_ID_INSTANTANEOUS_ACTIVE_POWER;
  285. p_instance->resource_ids[1] = IPSO_RR_ID_MIN_MEASURED_ACTIVE_POWER;
  286. p_instance->resource_ids[2] = IPSO_RR_ID_MAX_MEASURED_ACTIVE_POWER;
  287. p_instance->resource_ids[3] = IPSO_RR_ID_MIN_RANGE_ACTIVE_POWER;
  288. p_instance->resource_ids[4] = IPSO_RR_ID_MAX_RANGE_ACTIVE_POWER;
  289. p_instance->resource_ids[5] = IPSO_RR_ID_CUMULATIVE_ACTIVE_POWER;
  290. p_instance->resource_ids[6] = IPSO_RR_ID_ACTIVE_POWER_CALIBRATION;
  291. p_instance->resource_ids[7] = IPSO_RR_ID_INSTANTANEOUS_REACTIVE_POWER;
  292. p_instance->resource_ids[8] = IPSO_RR_ID_MIN_MEASURED_REACTIVE_POWER;
  293. p_instance->resource_ids[9] = IPSO_RR_ID_MAX_MEASURED_REACTIVE_POWER;
  294. p_instance->resource_ids[10] = IPSO_RR_ID_MIN_RANGE_REACTIVE_POWER;
  295. p_instance->resource_ids[11] = IPSO_RR_ID_MAX_RANGE_REACTIVE_POWER;
  296. p_instance->resource_ids[12] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
  297. p_instance->resource_ids[13] = IPSO_RR_ID_CUMULATIVE_REACTIVE_POWER;
  298. p_instance->resource_ids[14] = IPSO_RR_ID_REACTIVE_POWER_CALIBRATION;
  299. p_instance->resource_ids[15] = IPSO_RR_ID_POWER_FACTOR;
  300. p_instance->resource_ids[16] = IPSO_RR_ID_CURRENT_CALIBRATION;
  301. p_instance->resource_ids[17] = IPSO_RR_ID_RESET_CUMULATIVE_ENERGY;
  302. }
  303. void ipso_instance_actuation_init(ipso_actuation_t * p_instance)
  304. {
  305. // Set prototype variables.
  306. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_actuation_t);
  307. p_instance->proto.object_id = IPSO_SO_ID_ACTUATION;
  308. p_instance->proto.instance_id = 0;
  309. p_instance->proto.num_resources = sizeof(((ipso_actuation_t *)0)->operations);
  310. // Set access types.
  311. p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  312. p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  313. p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  314. p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  315. p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  316. // Set resource IDs.
  317. p_instance->resource_ids[0] = IPSO_RR_ID_ON_OFF;
  318. p_instance->resource_ids[1] = IPSO_RR_ID_DIMMER;
  319. p_instance->resource_ids[2] = IPSO_RR_ID_ON_TIME;
  320. p_instance->resource_ids[3] = IPSO_RR_ID_MULTI_STATE_OUTPUT;
  321. p_instance->resource_ids[4] = IPSO_RR_ID_APPLICATION_TYPE;
  322. }
  323. void ipso_instance_set_point_init(ipso_set_point_t * p_instance)
  324. {
  325. // Set prototype variables.
  326. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_set_point_t);
  327. p_instance->proto.object_id = IPSO_SO_ID_SET_POINT;
  328. p_instance->proto.instance_id = 0;
  329. p_instance->proto.num_resources = sizeof(((ipso_set_point_t *)0)->operations);
  330. // Set access types.
  331. p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  332. p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  333. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  334. p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  335. // Set resource IDs.
  336. p_instance->resource_ids[0] = IPSO_RR_ID_SETPOINT_VALUE;
  337. p_instance->resource_ids[1] = IPSO_RR_ID_COLOUR;
  338. p_instance->resource_ids[2] = IPSO_RR_ID_SENSOR_UNITS;
  339. p_instance->resource_ids[3] = IPSO_RR_ID_APPLICATION_TYPE;
  340. }
  341. void ipso_instance_load_control_init(ipso_load_control_t * p_instance)
  342. {
  343. // Set prototype variables.
  344. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_load_control_t);
  345. p_instance->proto.object_id = IPSO_SO_ID_LOAD_CONTROL;
  346. p_instance->proto.instance_id = 0;
  347. p_instance->proto.num_resources = sizeof(((ipso_load_control_t *)0)->operations);
  348. // Set access types.
  349. p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  350. p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  351. p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  352. p_instance->operations[3] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  353. p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  354. p_instance->operations[5] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  355. // Set resource IDs.
  356. p_instance->resource_ids[0] = IPSO_RR_ID_EVENT_IDENTIFIER;
  357. p_instance->resource_ids[1] = IPSO_RR_ID_START_TIME;
  358. p_instance->resource_ids[2] = IPSO_RR_ID_DURATION_IN_MIN;
  359. p_instance->resource_ids[3] = IPSO_RR_ID_CRITICALITY_LEVEL;
  360. p_instance->resource_ids[4] = IPSO_RR_ID_AVG_LOAD_ADJPCT;
  361. p_instance->resource_ids[5] = IPSO_RR_ID_DUTY_CYCLE;
  362. }
  363. void ipso_instance_light_control_init(ipso_light_control_t * p_instance)
  364. {
  365. // Set prototype variables.
  366. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_light_control_t);
  367. p_instance->proto.object_id = IPSO_SO_ID_LIGHT_CONTROL;
  368. p_instance->proto.instance_id = 0;
  369. p_instance->proto.num_resources = sizeof(((ipso_light_control_t *)0)->operations);
  370. // Set access types.
  371. p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  372. p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  373. p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  374. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  375. p_instance->operations[4] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  376. p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
  377. p_instance->operations[6] = LWM2M_OPERATION_CODE_READ;
  378. // Set resource IDs.
  379. p_instance->resource_ids[0] = IPSO_RR_ID_ON_OFF;
  380. p_instance->resource_ids[1] = IPSO_RR_ID_DIMMER;
  381. p_instance->resource_ids[2] = IPSO_RR_ID_COLOUR;
  382. p_instance->resource_ids[3] = IPSO_RR_ID_SENSOR_UNITS;
  383. p_instance->resource_ids[4] = IPSO_RR_ID_ON_TIME;
  384. p_instance->resource_ids[5] = IPSO_RR_ID_CUMULATIVE_ACTIVE_POWER;
  385. p_instance->resource_ids[6] = IPSO_RR_ID_POWER_FACTOR;
  386. }
  387. void ipso_instance_power_control_init(ipso_power_control_t * p_instance)
  388. {
  389. // Set prototype variables.
  390. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_power_control_t);
  391. p_instance->proto.object_id = IPSO_SO_ID_POWER_CONTROL;
  392. p_instance->proto.instance_id = 0;
  393. p_instance->proto.num_resources = sizeof(((ipso_power_control_t *)0)->operations);
  394. // Set access types.
  395. p_instance->operations[0] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  396. p_instance->operations[1] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  397. p_instance->operations[2] = (LWM2M_OPERATION_CODE_READ | LWM2M_OPERATION_CODE_WRITE);
  398. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  399. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  400. // Set resource IDs.
  401. p_instance->resource_ids[0] = IPSO_RR_ID_ON_OFF;
  402. p_instance->resource_ids[1] = IPSO_RR_ID_DIMMER;
  403. p_instance->resource_ids[2] = IPSO_RR_ID_ON_TIME;
  404. p_instance->resource_ids[3] = IPSO_RR_ID_CUMULATIVE_ACTIVE_POWER;
  405. p_instance->resource_ids[4] = IPSO_RR_ID_POWER_FACTOR;
  406. }
  407. void ipso_instance_accelerometer_init(ipso_accelerometer_t * p_instance)
  408. {
  409. // Set prototype variables.
  410. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_accelerometer_t);
  411. p_instance->proto.object_id = IPSO_SO_ID_ACCELEROMETER;
  412. p_instance->proto.instance_id = 0;
  413. p_instance->proto.num_resources = sizeof(((ipso_accelerometer_t *)0)->operations);
  414. // Set access types.
  415. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  416. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  417. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  418. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  419. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  420. p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
  421. // Set resource IDs.
  422. p_instance->resource_ids[0] = IPSO_RR_ID_X_VALUE;
  423. p_instance->resource_ids[1] = IPSO_RR_ID_Y_VALUE;
  424. p_instance->resource_ids[2] = IPSO_RR_ID_Z_VALUE;
  425. p_instance->resource_ids[3] = IPSO_RR_ID_SENSOR_UNITS;
  426. p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
  427. p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
  428. }
  429. void ipso_instance_magnetometer_init(ipso_magnetometer_t * p_instance)
  430. {
  431. // Set prototype variables.
  432. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_magnetometer_t);
  433. p_instance->proto.object_id = IPSO_SO_ID_MAGNETOMETER;
  434. p_instance->proto.instance_id = 0;
  435. p_instance->proto.num_resources = sizeof(((ipso_magnetometer_t *)0)->operations);
  436. // Set access types.
  437. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  438. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  439. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  440. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  441. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  442. // Set resource IDs.
  443. p_instance->resource_ids[0] = IPSO_RR_ID_X_VALUE;
  444. p_instance->resource_ids[1] = IPSO_RR_ID_Y_VALUE;
  445. p_instance->resource_ids[2] = IPSO_RR_ID_Z_VALUE;
  446. p_instance->resource_ids[3] = IPSO_RR_ID_SENSOR_UNITS;
  447. p_instance->resource_ids[4] = IPSO_RR_ID_COMPASS_DIRECTION;
  448. }
  449. void ipso_instance_barometer_init(ipso_barometer_t * p_instance)
  450. {
  451. // Set prototype variables.
  452. LWM2M_INSTANCE_OFFSET_SET(p_instance, ipso_barometer_t);
  453. p_instance->proto.object_id = IPSO_SO_ID_BAROMETER;
  454. p_instance->proto.instance_id = 0;
  455. p_instance->proto.num_resources = sizeof(((ipso_barometer_t *)0)->operations);
  456. // Set access types.
  457. p_instance->operations[0] = LWM2M_OPERATION_CODE_READ;
  458. p_instance->operations[1] = LWM2M_OPERATION_CODE_READ;
  459. p_instance->operations[2] = LWM2M_OPERATION_CODE_READ;
  460. p_instance->operations[3] = LWM2M_OPERATION_CODE_READ;
  461. p_instance->operations[4] = LWM2M_OPERATION_CODE_READ;
  462. p_instance->operations[5] = LWM2M_OPERATION_CODE_READ;
  463. p_instance->operations[6] = LWM2M_OPERATION_CODE_EXECUTE;
  464. // Set resource IDs.
  465. p_instance->resource_ids[0] = IPSO_RR_ID_SENSOR_VALUE;
  466. p_instance->resource_ids[1] = IPSO_RR_ID_SENSOR_UNITS;
  467. p_instance->resource_ids[2] = IPSO_RR_ID_MIN_MEASURED_VALUE;
  468. p_instance->resource_ids[3] = IPSO_RR_ID_MAX_MEASURED_VALUE;
  469. p_instance->resource_ids[4] = IPSO_RR_ID_MIN_RANGE_VALUE;
  470. p_instance->resource_ids[5] = IPSO_RR_ID_MAX_RANGE_VALUE;
  471. p_instance->resource_ids[6] = IPSO_RR_ID_RESET_MIN_MAX_MEASURED_VALUES;
  472. }