Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
lwm2m.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Linaro Limited
3 * Copyright (c) 2017-2019 Foundries.io
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
27#ifndef ZEPHYR_INCLUDE_NET_LWM2M_H_
28#define ZEPHYR_INCLUDE_NET_LWM2M_H_
29
30#include <time.h>
31#include <zephyr/kernel.h>
32#include <zephyr/sys/mutex.h>
33#include <zephyr/net/coap.h>
35
42/* clang-format off */
43#define LWM2M_OBJECT_SECURITY_ID 0
44#define LWM2M_OBJECT_SERVER_ID 1
45#define LWM2M_OBJECT_ACCESS_CONTROL_ID 2
46#define LWM2M_OBJECT_DEVICE_ID 3
47#define LWM2M_OBJECT_CONNECTIVITY_MONITORING_ID 4
48#define LWM2M_OBJECT_FIRMWARE_ID 5
49#define LWM2M_OBJECT_LOCATION_ID 6
50#define LWM2M_OBJECT_CONNECTIVITY_STATISTICS_ID 7
51#define LWM2M_OBJECT_SOFTWARE_MANAGEMENT_ID 9
52#define LWM2M_OBJECT_PORTFOLIO_ID 16
53#define LWM2M_OBJECT_BINARYAPPDATACONTAINER_ID 19
54#define LWM2M_OBJECT_EVENT_LOG_ID 20
55#define LWM2M_OBJECT_OSCORE_ID 21
56#define LWM2M_OBJECT_GATEWAY_ID 25
57/* clang-format on */
58
69/* clang-format off */
70#define IPSO_OBJECT_GENERIC_SENSOR_ID 3300
71#define IPSO_OBJECT_TEMP_SENSOR_ID 3303
72#define IPSO_OBJECT_HUMIDITY_SENSOR_ID 3304
73#define IPSO_OBJECT_LIGHT_CONTROL_ID 3311
74#define IPSO_OBJECT_ACCELEROMETER_ID 3313
75#define IPSO_OBJECT_VOLTAGE_SENSOR_ID 3316
76#define IPSO_OBJECT_CURRENT_SENSOR_ID 3317
77#define IPSO_OBJECT_PRESSURE_ID 3323
78#define IPSO_OBJECT_BUZZER_ID 3338
79#define IPSO_OBJECT_TIMER_ID 3340
80#define IPSO_OBJECT_ONOFF_SWITCH_ID 3342
81#define IPSO_OBJECT_PUSH_BUTTON_ID 3347
82#define UCIFI_OBJECT_BATTERY_ID 3411
83#define IPSO_OBJECT_FILLING_LEVEL_SENSOR_ID 3435
84/* clang-format on */
85
93typedef void (*lwm2m_socket_fault_cb_t)(int error);
94
102};
103
112};
113
124typedef void (*lwm2m_observe_cb_t)(enum lwm2m_observe_event event, struct lwm2m_obj_path *path,
125 void *user_data);
126
127
128struct lwm2m_ctx;
136typedef void (*lwm2m_ctx_event_cb_t)(struct lwm2m_ctx *ctx,
137 enum lwm2m_rd_client_event event);
138
139
154};
155
160struct lwm2m_ctx {
163
167 struct coap_pending pendings[CONFIG_LWM2M_ENGINE_MAX_PENDING + 1];
168 struct coap_reply replies[CONFIG_LWM2M_ENGINE_MAX_REPLIES + 1];
169 sys_slist_t pending_sends;
170#if defined(CONFIG_LWM2M_QUEUE_MODE_ENABLED)
171 sys_slist_t queued_messages;
172#endif
173 sys_slist_t observer;
182
183#if defined(CONFIG_LWM2M_DTLS_SUPPORT) || defined(__DOXYGEN__)
194
204
209 int (*load_credentials)(struct lwm2m_ctx *client_ctx);
211#endif
217 int (*set_socketoptions)(struct lwm2m_ctx *client_ctx);
218
225
231
232#if defined(CONFIG_LWM2M_QUEUE_MODE_ENABLED) || defined(__DOXYGEN__)
238#endif
241
244
249
252
257
262
265
270 uint8_t validate_buf[CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE];
271
279};
280
288 union {
290 uint8_t u8;
291 uint16_t u16;
292 uint32_t u32;
293 uint64_t u64;
294 int8_t i8;
295 int16_t i16;
296 int32_t i32;
297 int64_t i64;
298 time_t time;
299 double f;
300 bool b;
302 };
303};
304
324typedef void *(*lwm2m_engine_get_data_cb_t)(uint16_t obj_inst_id,
325 uint16_t res_id,
326 uint16_t res_inst_id,
327 size_t *data_len);
328
360typedef int (*lwm2m_engine_set_data_cb_t)(uint16_t obj_inst_id,
361 uint16_t res_id, uint16_t res_inst_id,
362 uint8_t *data, uint16_t data_len,
363 bool last_block, size_t total_size, size_t offset);
364
381typedef int (*lwm2m_engine_user_cb_t)(uint16_t obj_inst_id);
382
399typedef int (*lwm2m_engine_execute_cb_t)(uint16_t obj_inst_id,
400 uint8_t *args, uint16_t args_len);
401
407#define LWM2M_DEVICE_PWR_SRC_TYPE_DC_POWER 0
408#define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_INT 1
409#define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_EXT 2
410#define LWM2M_DEVICE_PWR_SRC_TYPE_FUEL_CELL 3
411#define LWM2M_DEVICE_PWR_SRC_TYPE_PWR_OVER_ETH 4
412#define LWM2M_DEVICE_PWR_SRC_TYPE_USB 5
413#define LWM2M_DEVICE_PWR_SRC_TYPE_AC_POWER 6
414#define LWM2M_DEVICE_PWR_SRC_TYPE_SOLAR 7
415#define LWM2M_DEVICE_PWR_SRC_TYPE_MAX 8
425#define LWM2M_DEVICE_ERROR_NONE 0
426#define LWM2M_DEVICE_ERROR_LOW_POWER 1
427#define LWM2M_DEVICE_ERROR_EXT_POWER_SUPPLY_OFF 2
428#define LWM2M_DEVICE_ERROR_GPS_FAILURE 3
429#define LWM2M_DEVICE_ERROR_LOW_SIGNAL_STRENGTH 4
430#define LWM2M_DEVICE_ERROR_OUT_OF_MEMORY 5
431#define LWM2M_DEVICE_ERROR_SMS_FAILURE 6
432#define LWM2M_DEVICE_ERROR_NETWORK_FAILURE 7
433#define LWM2M_DEVICE_ERROR_PERIPHERAL_FAILURE 8
444#define LWM2M_DEVICE_BATTERY_STATUS_NORMAL 0
447#define LWM2M_DEVICE_BATTERY_STATUS_CHARGING 1
448#define LWM2M_DEVICE_BATTERY_STATUS_CHARGE_COMP 2
451#define LWM2M_DEVICE_BATTERY_STATUS_DAMAGED 3
452#define LWM2M_DEVICE_BATTERY_STATUS_LOW 4
453#define LWM2M_DEVICE_BATTERY_STATUS_NOT_INST 5
454#define LWM2M_DEVICE_BATTERY_STATUS_UNKNOWN 6
466
467
479#define STATE_IDLE 0
483#define STATE_DOWNLOADING 1
487#define STATE_DOWNLOADED 2
491#define STATE_UPDATING 3
492
503#define RESULT_DEFAULT 0
504#define RESULT_SUCCESS 1
505#define RESULT_NO_STORAGE 2
506#define RESULT_OUT_OF_MEM 3
507#define RESULT_CONNECTION_LOST 4
508#define RESULT_INTEGRITY_FAILED 5
509#define RESULT_UNSUP_FW 6
510#define RESULT_INVALID_URI 7
511#define RESULT_UPDATE_FAILED 8
512#define RESULT_UNSUP_PROTO 9
516#if defined(CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT) || defined(__DOXYGEN__)
526
533
544
552
562
569
580
588
598
605
616
624#endif
625
626#if defined(CONFIG_LWM2M_SWMGMT_OBJ_SUPPORT) || defined(__DOXYGEN__)
627
640
653
666
679
692
705
716int lwm2m_swmgmt_install_completed(uint16_t obj_inst_id, int error_code);
717
718#endif
719
720#if defined(CONFIG_LWM2M_EVENT_LOG_OBJ_SUPPORT) || defined(__DOXYGEN__)
721
731
732#endif
733
737#define LWM2M_OBJLNK_MAX_ID USHRT_MAX
738
745};
746
763__deprecated
764int lwm2m_engine_update_observer_min_period(struct lwm2m_ctx *client_ctx, const char *pathstr,
765 uint32_t period_s);
766
782 const struct lwm2m_obj_path *path, uint32_t period_s);
783
800__deprecated
801int lwm2m_engine_update_observer_max_period(struct lwm2m_ctx *client_ctx, const char *pathstr,
802 uint32_t period_s);
803
819 const struct lwm2m_obj_path *path, uint32_t period_s);
820
834__deprecated
835int lwm2m_engine_create_obj_inst(const char *pathstr);
836
849
861__deprecated
862int lwm2m_engine_delete_obj_inst(const char *pathstr);
863
874
883
889
901__deprecated
902int lwm2m_engine_set_opaque(const char *pathstr, const char *data_ptr, uint16_t data_len);
903
913int lwm2m_set_opaque(const struct lwm2m_obj_path *path, const char *data_ptr, uint16_t data_len);
914
925__deprecated
926int lwm2m_engine_set_string(const char *pathstr, const char *data_ptr);
927
936int lwm2m_set_string(const struct lwm2m_obj_path *path, const char *data_ptr);
937
948__deprecated
949int lwm2m_engine_set_u8(const char *pathstr, uint8_t value);
950
959int lwm2m_set_u8(const struct lwm2m_obj_path *path, uint8_t value);
960
971__deprecated
972int lwm2m_engine_set_u16(const char *pathstr, uint16_t value);
973
982int lwm2m_set_u16(const struct lwm2m_obj_path *path, uint16_t value);
983
994__deprecated
995int lwm2m_engine_set_u32(const char *pathstr, uint32_t value);
996
1005int lwm2m_set_u32(const struct lwm2m_obj_path *path, uint32_t value);
1006
1017__deprecated
1018int lwm2m_engine_set_u64(const char *pathstr, uint64_t value);
1019
1032__deprecated
1033int lwm2m_set_u64(const struct lwm2m_obj_path *path, uint64_t value);
1034
1045__deprecated
1046int lwm2m_engine_set_s8(const char *pathstr, int8_t value);
1047
1056int lwm2m_set_s8(const struct lwm2m_obj_path *path, int8_t value);
1057
1068__deprecated
1069int lwm2m_engine_set_s16(const char *pathstr, int16_t value);
1070
1079int lwm2m_set_s16(const struct lwm2m_obj_path *path, int16_t value);
1080
1091__deprecated
1092int lwm2m_engine_set_s32(const char *pathstr, int32_t value);
1093
1102int lwm2m_set_s32(const struct lwm2m_obj_path *path, int32_t value);
1103
1114__deprecated
1115int lwm2m_engine_set_s64(const char *pathstr, int64_t value);
1116
1125int lwm2m_set_s64(const struct lwm2m_obj_path *path, int64_t value);
1126
1137__deprecated
1138int lwm2m_engine_set_bool(const char *pathstr, bool value);
1139
1148int lwm2m_set_bool(const struct lwm2m_obj_path *path, bool value);
1149
1160__deprecated
1161int lwm2m_engine_set_float(const char *pathstr, const double *value);
1162
1171int lwm2m_set_f64(const struct lwm2m_obj_path *path, const double value);
1172
1183__deprecated
1184int lwm2m_engine_set_objlnk(const char *pathstr, const struct lwm2m_objlnk *value);
1185
1194int lwm2m_set_objlnk(const struct lwm2m_obj_path *path, const struct lwm2m_objlnk *value);
1195
1206__deprecated
1207int lwm2m_engine_set_time(const char *pathstr, time_t value);
1208
1217int lwm2m_set_time(const struct lwm2m_obj_path *path, time_t value);
1218
1246 void *value;
1249};
1250
1263int lwm2m_set_bulk(const struct lwm2m_res_item res_list[], size_t res_list_size);
1264
1276__deprecated
1277int lwm2m_engine_get_opaque(const char *pathstr, void *buf, uint16_t buflen);
1278
1288int lwm2m_get_opaque(const struct lwm2m_obj_path *path, void *buf, uint16_t buflen);
1289
1301__deprecated
1302int lwm2m_engine_get_string(const char *pathstr, void *str, uint16_t buflen);
1303
1313int lwm2m_get_string(const struct lwm2m_obj_path *path, void *str, uint16_t buflen);
1314
1325__deprecated
1326int lwm2m_engine_get_u8(const char *pathstr, uint8_t *value);
1327
1336int lwm2m_get_u8(const struct lwm2m_obj_path *path, uint8_t *value);
1337
1348__deprecated
1349int lwm2m_engine_get_u16(const char *pathstr, uint16_t *value);
1350
1359int lwm2m_get_u16(const struct lwm2m_obj_path *path, uint16_t *value);
1360
1371__deprecated
1372int lwm2m_engine_get_u32(const char *pathstr, uint32_t *value);
1373
1382int lwm2m_get_u32(const struct lwm2m_obj_path *path, uint32_t *value);
1383
1394__deprecated
1395int lwm2m_engine_get_u64(const char *pathstr, uint64_t *value);
1396
1409__deprecated
1410int lwm2m_get_u64(const struct lwm2m_obj_path *path, uint64_t *value);
1411
1422__deprecated
1423int lwm2m_engine_get_s8(const char *pathstr, int8_t *value);
1424
1433int lwm2m_get_s8(const struct lwm2m_obj_path *path, int8_t *value);
1434
1445__deprecated
1446int lwm2m_engine_get_s16(const char *pathstr, int16_t *value);
1447
1456int lwm2m_get_s16(const struct lwm2m_obj_path *path, int16_t *value);
1457
1468__deprecated
1469int lwm2m_engine_get_s32(const char *pathstr, int32_t *value);
1470
1479int lwm2m_get_s32(const struct lwm2m_obj_path *path, int32_t *value);
1480
1491__deprecated
1492int lwm2m_engine_get_s64(const char *pathstr, int64_t *value);
1493
1502int lwm2m_get_s64(const struct lwm2m_obj_path *path, int64_t *value);
1503
1514__deprecated
1515int lwm2m_engine_get_bool(const char *pathstr, bool *value);
1516
1525int lwm2m_get_bool(const struct lwm2m_obj_path *path, bool *value);
1526
1537__deprecated
1538int lwm2m_engine_get_float(const char *pathstr, double *buf);
1539
1548int lwm2m_get_f64(const struct lwm2m_obj_path *path, double *value);
1549
1560__deprecated
1561int lwm2m_engine_get_objlnk(const char *pathstr, struct lwm2m_objlnk *buf);
1562
1571int lwm2m_get_objlnk(const struct lwm2m_obj_path *path, struct lwm2m_objlnk *buf);
1572
1583__deprecated
1584int lwm2m_engine_get_time(const char *pathstr, time_t *buf);
1585
1594int lwm2m_get_time(const struct lwm2m_obj_path *path, time_t *buf);
1595
1616__deprecated
1619
1639
1654__deprecated
1657
1672
1695__deprecated
1698
1721
1738__deprecated
1741
1758
1771__deprecated
1774
1786
1799__deprecated
1802
1815
1828__deprecated
1831
1844
1848#define LWM2M_RES_DATA_READ_ONLY 0
1849
1853#define LWM2M_RES_DATA_FLAG_RO BIT(LWM2M_RES_DATA_READ_ONLY)
1854
1858#define LWM2M_HAS_RES_FLAG(res, f) ((res->data_flags & f) == f)
1859
1876__deprecated
1877int lwm2m_engine_set_res_buf(const char *pathstr, void *buffer_ptr, uint16_t buffer_len,
1878 uint16_t data_len, uint8_t data_flags);
1879
1894int lwm2m_set_res_buf(const struct lwm2m_obj_path *path, void *buffer_ptr, uint16_t buffer_len,
1895 uint16_t data_len, uint8_t data_flags);
1896
1913__deprecated
1914int lwm2m_engine_set_res_data(const char *pathstr, void *data_ptr, uint16_t data_len,
1915 uint8_t data_flags);
1916
1929__deprecated
1930int lwm2m_engine_set_res_data_len(const char *pathstr, uint16_t data_len);
1931
1942int lwm2m_set_res_data_len(const struct lwm2m_obj_path *path, uint16_t data_len);
1943
1965__deprecated
1966int lwm2m_engine_get_res_buf(const char *pathstr, void **buffer_ptr, uint16_t *buffer_len,
1967 uint16_t *data_len, uint8_t *data_flags);
1968
1988int lwm2m_get_res_buf(const struct lwm2m_obj_path *path, void **buffer_ptr, uint16_t *buffer_len,
1989 uint16_t *data_len, uint8_t *data_flags);
1990
2006__deprecated
2007int lwm2m_engine_get_res_data(const char *pathstr, void **data_ptr, uint16_t *data_len,
2008 uint8_t *data_flags);
2009
2023__deprecated
2024int lwm2m_engine_create_res_inst(const char *pathstr);
2025
2038
2050__deprecated
2051int lwm2m_engine_delete_res_inst(const char *pathstr);
2052
2063
2075
2089__deprecated
2090bool lwm2m_engine_path_is_observed(const char *pathstr);
2091
2104
2116int lwm2m_engine_stop(struct lwm2m_ctx *client_ctx);
2117
2129int lwm2m_engine_start(struct lwm2m_ctx *client_ctx);
2130
2142void lwm2m_acknowledge(struct lwm2m_ctx *client_ctx);
2143
2183};
2184
2188#define LWM2M_RD_CLIENT_EVENT_REG_UPDATE_FAILURE \
2189 LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT __DEPRECATED_MACRO
2190
2191/*
2192 * LwM2M RD client flags, used to configure LwM2M session.
2193 */
2194
2198#define LWM2M_RD_CLIENT_FLAG_BOOTSTRAP BIT(0)
2199
2221int lwm2m_rd_client_start(struct lwm2m_ctx *client_ctx, const char *ep_name,
2223 lwm2m_observe_cb_t observe_cb);
2224
2240int lwm2m_rd_client_stop(struct lwm2m_ctx *client_ctx,
2241 lwm2m_ctx_event_cb_t event_cb, bool deregister);
2242
2253
2265
2270
2274#define LWM2M_MAX_PATH_STR_SIZE sizeof("/65535/65535/65535/65535")
2275
2284char *lwm2m_path_log_buf(char *buf, struct lwm2m_obj_path *path);
2285
2296};
2297
2302typedef void (*lwm2m_send_cb_t)(enum lwm2m_send_status status);
2303
2317__deprecated
2318int lwm2m_engine_send(struct lwm2m_ctx *ctx, char const *path_list[], uint8_t path_list_size,
2319 bool confirmation_request);
2320
2334__deprecated
2335int lwm2m_send(struct lwm2m_ctx *ctx, const struct lwm2m_obj_path path_list[],
2336 uint8_t path_list_size, bool confirmation_request);
2337
2349int lwm2m_send_cb(struct lwm2m_ctx *ctx, const struct lwm2m_obj_path path_list[],
2350 uint8_t path_list_size, lwm2m_send_cb_t reply_cb);
2351
2359
2375__deprecated
2376int lwm2m_engine_enable_cache(char const *resource_path, struct lwm2m_time_series_elem *data_cache,
2377 size_t cache_len);
2378
2392int lwm2m_enable_cache(const struct lwm2m_obj_path *path, struct lwm2m_time_series_elem *data_cache,
2393 size_t cache_len);
2394
2404};
2405
2415
2427
2428#endif /* ZEPHYR_INCLUDE_NET_LWM2M_H_ */
_TIME_T_ time_t
Definition: _timespec.h:14
CoAP implementation for Zephyr.
int lwm2m_engine_set_u8(const char *pathstr, uint8_t value)
Set resource (instance) value (u8)
int lwm2m_send_cb(struct lwm2m_ctx *ctx, const struct lwm2m_obj_path path_list[], uint8_t path_list_size, lwm2m_send_cb_t reply_cb)
 
int lwm2m_get_f64(const struct lwm2m_obj_path *path, double *value)
Get resource (instance) value (double)
int lwm2m_set_objlnk(const struct lwm2m_obj_path *path, const struct lwm2m_objlnk *value)
Set resource (instance) value (Objlnk)
bool lwm2m_engine_path_is_observed(const char *pathstr)
Check whether a path is observed.
int lwm2m_engine_stop(struct lwm2m_ctx *client_ctx)
Stop the LwM2M engine.
int lwm2m_engine_get_float(const char *pathstr, double *buf)
Get resource (instance) value (double)
int lwm2m_get_u32(const struct lwm2m_obj_path *path, uint32_t *value)
Get resource (instance) value (u32)
int lwm2m_set_res_data_len(const struct lwm2m_obj_path *path, uint16_t data_len)
Update data size for a resource.
bool lwm2m_path_is_observed(const struct lwm2m_obj_path *path)
Check whether a path is observed.
int lwm2m_engine_set_s64(const char *pathstr, int64_t value)
Set resource (instance) value (s64)
lwm2m_security_mode_e
Security modes as defined in LwM2M Security object.
Definition: lwm2m.h:2398
int lwm2m_get_s8(const struct lwm2m_obj_path *path, int8_t *value)
Get resource (instance) value (s8)
int lwm2m_engine_register_pre_write_callback(const char *pathstr, lwm2m_engine_get_data_cb_t cb)
Set resource (instance) pre-write callback.
int lwm2m_engine_resume(void)
Resume the LwM2M engine thread.
int lwm2m_set_s64(const struct lwm2m_obj_path *path, int64_t value)
Set resource (instance) value (s64)
int lwm2m_engine_pause(void)
Suspend the LwM2M engine Thread.
int lwm2m_set_u8(const struct lwm2m_obj_path *path, uint8_t value)
Set resource (instance) value (u8)
int lwm2m_get_u16(const struct lwm2m_obj_path *path, uint16_t *value)
Get resource (instance) value (u16)
int lwm2m_engine_set_s16(const char *pathstr, int16_t value)
Set resource (instance) value (s16)
lwm2m_engine_execute_cb_t lwm2m_firmware_get_update_cb(void)
Get the event callback for firmware update execute events.
int lwm2m_set_u16(const struct lwm2m_obj_path *path, uint16_t value)
Set resource (instance) value (u16)
lwm2m_send_status
LwM2M send status.
Definition: lwm2m.h:2292
int lwm2m_get_string(const struct lwm2m_obj_path *path, void *str, uint16_t buflen)
Get resource (instance) value (string)
int lwm2m_engine_register_read_callback(const char *pathstr, lwm2m_engine_get_data_cb_t cb)
Set resource (instance) read callback.
int lwm2m_get_s16(const struct lwm2m_obj_path *path, int16_t *value)
Get resource (instance) value (s16)
int lwm2m_engine_get_time(const char *pathstr, time_t *buf)
Get resource (instance) value (Time)
int lwm2m_engine_set_string(const char *pathstr, const char *data_ptr)
Set resource (instance) value (string)
int lwm2m_swmgmt_set_write_package_cb(uint16_t obj_inst_id, lwm2m_engine_set_data_cb_t cb)
Set data callback for software management block transfer.
int lwm2m_register_exec_callback(const struct lwm2m_obj_path *path, lwm2m_engine_execute_cb_t cb)
Set resource execute event callback.
int lwm2m_engine_set_opaque(const char *pathstr, const char *data_ptr, uint16_t data_len)
Set resource (instance) value (opaque buffer)
int lwm2m_get_time(const struct lwm2m_obj_path *path, time_t *buf)
Get resource (instance) value (Time)
void lwm2m_firmware_set_update_cb_inst(uint16_t obj_inst_id, lwm2m_engine_execute_cb_t cb)
Set data callback to handle firmware update execute events.
int lwm2m_engine_set_u32(const char *pathstr, uint32_t value)
Set resource (instance) value (u32)
int lwm2m_set_s32(const struct lwm2m_obj_path *path, int32_t value)
Set resource (instance) value (s32)
int lwm2m_engine_create_obj_inst(const char *pathstr)
Create an LwM2M object instance.
int lwm2m_set_f64(const struct lwm2m_obj_path *path, const double value)
Set resource (instance) value (double)
int lwm2m_engine_get_opaque(const char *pathstr, void *buf, uint16_t buflen)
Get resource (instance) value (opaque buffer)
int lwm2m_register_create_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb)
Set object instance create event callback.
lwm2m_engine_execute_cb_t lwm2m_firmware_get_update_cb_inst(uint16_t obj_inst_id)
Get the event callback for firmware update execute events.
int lwm2m_set_s8(const struct lwm2m_obj_path *path, int8_t value)
Set resource (instance) value (s8)
int lwm2m_engine_delete_obj_inst(const char *pathstr)
Delete an LwM2M object instance.
void(* lwm2m_ctx_event_cb_t)(struct lwm2m_ctx *ctx, enum lwm2m_rd_client_event event)
Asynchronous RD client event callback.
Definition: lwm2m.h:136
void lwm2m_firmware_set_cancel_cb(lwm2m_engine_user_cb_t cb)
Set callback for firmware update cancel.
int(* lwm2m_engine_set_data_cb_t)(uint16_t obj_inst_id, uint16_t res_id, uint16_t res_inst_id, uint8_t *data, uint16_t data_len, bool last_block, size_t total_size, size_t offset)
Asynchronous callback when data has been set to a resource buffer.
Definition: lwm2m.h:360
int lwm2m_register_post_write_callback(const struct lwm2m_obj_path *path, lwm2m_engine_set_data_cb_t cb)
Set resource (instance) post-write callback.
int lwm2m_engine_get_s32(const char *pathstr, int32_t *value)
Get resource (instance) value (s32)
int lwm2m_set_bulk(const struct lwm2m_res_item res_list[], size_t res_list_size)
Set multiple resource (instance) values.
int lwm2m_engine_update_observer_min_period(struct lwm2m_ctx *client_ctx, const char *pathstr, uint32_t period_s)
Change an observer's pmin value.
lwm2m_engine_set_data_cb_t lwm2m_firmware_get_write_cb(void)
Get the data callback for firmware block transfer writes.
int lwm2m_get_objlnk(const struct lwm2m_obj_path *path, struct lwm2m_objlnk *buf)
Get resource (instance) value (Objlnk)
int lwm2m_engine_set_s32(const char *pathstr, int32_t value)
Set resource (instance) value (s32)
int lwm2m_engine_set_u16(const char *pathstr, uint16_t value)
Set resource (instance) value (u16)
int lwm2m_engine_get_u8(const char *pathstr, uint8_t *value)
Get resource (instance) value (u8)
int lwm2m_create_object_inst(const struct lwm2m_obj_path *path)
Create an LwM2M object instance.
int lwm2m_set_res_buf(const struct lwm2m_obj_path *path, void *buffer_ptr, uint16_t buffer_len, uint16_t data_len, uint8_t data_flags)
Set data buffer for a resource.
int lwm2m_swmgmt_install_completed(uint16_t obj_inst_id, int error_code)
Function to be called when a Software Management object instance completed the Install operation.
int lwm2m_engine_send(struct lwm2m_ctx *ctx, char const *path_list[], uint8_t path_list_size, bool confirmation_request)
 
int lwm2m_engine_register_post_write_callback(const char *pathstr, lwm2m_engine_set_data_cb_t cb)
Set resource (instance) post-write callback.
void *(* lwm2m_engine_get_data_cb_t)(uint16_t obj_inst_id, uint16_t res_id, uint16_t res_inst_id, size_t *data_len)
Asynchronous callback to get a resource buffer and length.
Definition: lwm2m.h:324
int lwm2m_engine_get_bool(const char *pathstr, bool *value)
Get resource (instance) value (bool)
void lwm2m_firmware_set_update_cb(lwm2m_engine_execute_cb_t cb)
Set data callback to handle firmware update execute events.
int lwm2m_engine_get_res_data(const char *pathstr, void **data_ptr, uint16_t *data_len, uint8_t *data_flags)
Get data buffer for a resource.
int lwm2m_engine_create_res_inst(const char *pathstr)
Create a resource instance.
int lwm2m_engine_set_res_buf(const char *pathstr, void *buffer_ptr, uint16_t buffer_len, uint16_t data_len, uint8_t data_flags)
Set data buffer for a resource.
void lwm2m_firmware_set_write_cb(lwm2m_engine_set_data_cb_t cb)
Set data callback for firmware block transfer.
int lwm2m_engine_get_u16(const char *pathstr, uint16_t *value)
Get resource (instance) value (u16)
int lwm2m_enable_cache(const struct lwm2m_obj_path *path, struct lwm2m_time_series_elem *data_cache, size_t cache_len)
 
int lwm2m_engine_register_delete_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb)
Set object instance delete event callback.
int lwm2m_update_observer_max_period(struct lwm2m_ctx *client_ctx, const struct lwm2m_obj_path *path, uint32_t period_s)
Change an observer's pmax value.
int lwm2m_security_mode(struct lwm2m_ctx *ctx)
Read security mode from selected security object instance.
lwm2m_engine_user_cb_t lwm2m_firmware_get_cancel_cb_inst(uint16_t obj_inst_id)
Get the callback for firmware update cancel.
int lwm2m_register_pre_write_callback(const struct lwm2m_obj_path *path, lwm2m_engine_get_data_cb_t cb)
Set resource (instance) pre-write callback.
int lwm2m_engine_get_s8(const char *pathstr, int8_t *value)
Get resource (instance) value (s8)
int lwm2m_set_time(const struct lwm2m_obj_path *path, time_t value)
Set resource (instance) value (Time)
int lwm2m_set_string(const struct lwm2m_obj_path *path, const char *data_ptr)
Set resource (instance) value (string)
int lwm2m_engine_get_string(const char *pathstr, void *str, uint16_t buflen)
Get resource (instance) value (string)
lwm2m_socket_states
Different traffic states of the LwM2M socket.
Definition: lwm2m.h:149
int lwm2m_swmgmt_set_deactivate_cb(uint16_t obj_inst_id, lwm2m_engine_execute_cb_t cb)
Set callback to handle software deactivation requests.
int lwm2m_engine_get_s64(const char *pathstr, int64_t *value)
Get resource (instance) value (s64)
int lwm2m_engine_set_u64(const char *pathstr, uint64_t value)
Set resource (instance) value (u64)
void(* lwm2m_send_cb_t)(enum lwm2m_send_status status)
Callback returning send status.
Definition: lwm2m.h:2302
int lwm2m_get_u64(const struct lwm2m_obj_path *path, uint64_t *value)
Get resource (instance) value (u64)
int lwm2m_engine_set_res_data_len(const char *pathstr, uint16_t data_len)
Update data size for a resource.
struct lwm2m_ctx * lwm2m_rd_client_ctx(void)
&#160;
int lwm2m_set_u64(const struct lwm2m_obj_path *path, uint64_t value)
Set resource (instance) value (u64)
int lwm2m_engine_set_bool(const char *pathstr, bool value)
Set resource (instance) value (bool)
int lwm2m_engine_get_u64(const char *pathstr, uint64_t *value)
Get resource (instance) value (u64)
void lwm2m_acknowledge(struct lwm2m_ctx *client_ctx)
Acknowledge the currently processed request with an empty ACK.
int lwm2m_register_delete_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb)
Set object instance delete event callback.
int lwm2m_set_u32(const struct lwm2m_obj_path *path, uint32_t value)
Set resource (instance) value (u32)
void lwm2m_event_log_set_read_log_data_cb(lwm2m_engine_get_data_cb_t cb)
Set callback to read log data.
lwm2m_engine_user_cb_t lwm2m_firmware_get_cancel_cb(void)
Get a callback for firmware update cancel.
int lwm2m_set_default_sockopt(struct lwm2m_ctx *ctx)
Set default socket options for DTLS connections.
int lwm2m_engine_get_s16(const char *pathstr, int16_t *value)
Get resource (instance) value (s16)
char * lwm2m_path_log_buf(char *buf, struct lwm2m_obj_path *path)
Helper function to print path objects' contents to log.
int lwm2m_get_s32(const struct lwm2m_obj_path *path, int32_t *value)
Get resource (instance) value (s32)
void lwm2m_registry_lock(void)
Locks the registry for this thread.
int lwm2m_rd_client_start(struct lwm2m_ctx *client_ctx, const char *ep_name, uint32_t flags, lwm2m_ctx_event_cb_t event_cb, lwm2m_observe_cb_t observe_cb)
Start the LwM2M RD (Registration / Discovery) Client.
int lwm2m_set_bool(const struct lwm2m_obj_path *path, bool value)
Set resource (instance) value (bool)
int lwm2m_engine_start(struct lwm2m_ctx *client_ctx)
Start the LwM2M engine.
int lwm2m_engine_register_create_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb)
Set object instance create event callback.
void lwm2m_firmware_set_cancel_cb_inst(uint16_t obj_inst_id, lwm2m_engine_user_cb_t cb)
Set data callback for firmware update cancel.
int lwm2m_set_opaque(const struct lwm2m_obj_path *path, const char *data_ptr, uint16_t data_len)
Set resource (instance) value (opaque buffer)
int lwm2m_get_s64(const struct lwm2m_obj_path *path, int64_t *value)
Get resource (instance) value (s64)
void lwm2m_registry_unlock(void)
Unlocks the registry previously locked by lwm2m_registry_lock().
int lwm2m_update_device_service_period(uint32_t period_ms)
Update the period of the device service.
void lwm2m_rd_client_update(void)
Trigger a Registration Update of the LwM2M RD Client.
int lwm2m_swmgmt_set_read_package_version_cb(uint16_t obj_inst_id, lwm2m_engine_get_data_cb_t cb)
Set callback to read software package.
int(* lwm2m_engine_user_cb_t)(uint16_t obj_inst_id)
Asynchronous event notification callback.
Definition: lwm2m.h:381
int lwm2m_engine_set_res_data(const char *pathstr, void *data_ptr, uint16_t data_len, uint8_t data_flags)
Set data buffer for a resource.
int lwm2m_device_add_err(uint8_t error_code)
Register a new error code with LwM2M Device object.
int lwm2m_get_res_buf(const struct lwm2m_obj_path *path, void **buffer_ptr, uint16_t *buffer_len, uint16_t *data_len, uint8_t *data_flags)
Get data buffer for a resource.
int lwm2m_engine_delete_res_inst(const char *pathstr)
Delete a resource instance.
int lwm2m_engine_register_validate_callback(const char *pathstr, lwm2m_engine_set_data_cb_t cb)
Set resource (instance) validation callback.
int lwm2m_swmgmt_set_activate_cb(uint16_t obj_inst_id, lwm2m_engine_execute_cb_t cb)
Set callback to handle software activation requests.
void lwm2m_firmware_set_write_cb_inst(uint16_t obj_inst_id, lwm2m_engine_set_data_cb_t cb)
Set data callback for firmware block transfer.
int lwm2m_get_u8(const struct lwm2m_obj_path *path, uint8_t *value)
Get resource (instance) value (u8)
int lwm2m_create_res_inst(const struct lwm2m_obj_path *path)
Create a resource instance.
lwm2m_observe_event
Observe callback events.
Definition: lwm2m.h:107
lwm2m_rd_client_event
LwM2M RD client events.
Definition: lwm2m.h:2150
int lwm2m_engine_update_observer_max_period(struct lwm2m_ctx *client_ctx, const char *pathstr, uint32_t period_s)
Change an observer's pmax value.
int lwm2m_swmgmt_set_delete_package_cb(uint16_t obj_inst_id, lwm2m_engine_execute_cb_t cb)
Set callback to handle software uninstall requests.
int lwm2m_delete_res_inst(const struct lwm2m_obj_path *path)
Delete a resource instance.
int lwm2m_engine_register_exec_callback(const char *pathstr, lwm2m_engine_execute_cb_t cb)
Set resource execute event callback.
int lwm2m_engine_set_time(const char *pathstr, time_t value)
Set resource (instance) value (Time)
int lwm2m_set_s16(const struct lwm2m_obj_path *path, int16_t value)
Set resource (instance) value (s16)
int lwm2m_register_validate_callback(const struct lwm2m_obj_path *path, lwm2m_engine_set_data_cb_t cb)
Set resource (instance) validation callback.
lwm2m_engine_set_data_cb_t lwm2m_firmware_get_write_cb_inst(uint16_t obj_inst_id)
Get the data callback for firmware block transfer writes.
void(* lwm2m_observe_cb_t)(enum lwm2m_observe_event event, struct lwm2m_obj_path *path, void *user_data)
Observe callback indicating observer adds and deletes, and notification ACKs and timeouts.
Definition: lwm2m.h:124
int lwm2m_engine_set_objlnk(const char *pathstr, const struct lwm2m_objlnk *value)
Set resource (instance) value (Objlnk)
int lwm2m_update_observer_min_period(struct lwm2m_ctx *client_ctx, const struct lwm2m_obj_path *path, uint32_t period_s)
Change an observer's pmin value.
int lwm2m_swmgmt_set_install_package_cb(uint16_t obj_inst_id, lwm2m_engine_execute_cb_t cb)
Set callback to handle software install requests.
int lwm2m_get_opaque(const struct lwm2m_obj_path *path, void *buf, uint16_t buflen)
Get resource (instance) value (opaque buffer)
int lwm2m_send(struct lwm2m_ctx *ctx, const struct lwm2m_obj_path path_list[], uint8_t path_list_size, bool confirmation_request)
 
int lwm2m_engine_set_s8(const char *pathstr, int8_t value)
Set resource (instance) value (s8)
void(* lwm2m_socket_fault_cb_t)(int error)
Callback function called when a socket error is encountered.
Definition: lwm2m.h:93
int lwm2m_engine_set_float(const char *pathstr, const double *value)
Set resource (instance) value (double)
int lwm2m_engine_enable_cache(char const *resource_path, struct lwm2m_time_series_elem *data_cache, size_t cache_len)
 
int(* lwm2m_engine_execute_cb_t)(uint16_t obj_inst_id, uint8_t *args, uint16_t args_len)
Asynchronous execute notification callback.
Definition: lwm2m.h:399
int lwm2m_register_read_callback(const struct lwm2m_obj_path *path, lwm2m_engine_get_data_cb_t cb)
Set resource (instance) read callback.
int lwm2m_engine_get_objlnk(const char *pathstr, struct lwm2m_objlnk *buf)
Get resource (instance) value (Objlnk)
int lwm2m_delete_object_inst(const struct lwm2m_obj_path *path)
Delete an LwM2M object instance.
int lwm2m_rd_client_stop(struct lwm2m_ctx *client_ctx, lwm2m_ctx_event_cb_t event_cb, bool deregister)
Stop the LwM2M RD (De-register) Client.
int lwm2m_get_bool(const struct lwm2m_obj_path *path, bool *value)
Get resource (instance) value (bool)
int lwm2m_engine_get_u32(const char *pathstr, uint32_t *value)
Get resource (instance) value (u32)
int lwm2m_engine_get_res_buf(const char *pathstr, void **buffer_ptr, uint16_t *buffer_len, uint16_t *data_len, uint8_t *data_flags)
Get data buffer for a resource.
@ LWM2M_SECURITY_PSK
Pre-Shared Key mode.
Definition: lwm2m.h:2399
@ LWM2M_SECURITY_RAW_PK
Raw Public Key mode.
Definition: lwm2m.h:2400
@ LWM2M_SECURITY_CERT
Certificate mode.
Definition: lwm2m.h:2401
@ LWM2M_SECURITY_CERT_EST
Certificate mode with EST.
Definition: lwm2m.h:2403
@ LWM2M_SECURITY_NOSEC
NoSec mode.
Definition: lwm2m.h:2402
@ LWM2M_SEND_STATUS_SUCCESS
Succeed.
Definition: lwm2m.h:2293
@ LWM2M_SEND_STATUS_FAILURE
Failure.
Definition: lwm2m.h:2294
@ LWM2M_SEND_STATUS_TIMEOUT
Timeout.
Definition: lwm2m.h:2295
@ LWM2M_SOCKET_STATE_NO_DATA
No more data is expected.
Definition: lwm2m.h:153
@ LWM2M_SOCKET_STATE_ONE_RESPONSE
One response is expected for the next message.
Definition: lwm2m.h:151
@ LWM2M_SOCKET_STATE_ONGOING
Ongoing traffic is expected.
Definition: lwm2m.h:150
@ LWM2M_SOCKET_STATE_LAST
Next message is the last one.
Definition: lwm2m.h:152
@ LWM2M_OBSERVE_EVENT_OBSERVER_ADDED
Observer added.
Definition: lwm2m.h:108
@ LWM2M_OBSERVE_EVENT_NOTIFY_TIMEOUT
Notification timed out.
Definition: lwm2m.h:111
@ LWM2M_OBSERVE_EVENT_NOTIFY_ACK
Notification ACKed.
Definition: lwm2m.h:110
@ LWM2M_OBSERVE_EVENT_OBSERVER_REMOVED
Observer removed.
Definition: lwm2m.h:109
@ LWM2M_RD_CLIENT_EVENT_DEREGISTER_FAILURE
De-registration failure.
Definition: lwm2m.h:2168
@ LWM2M_RD_CLIENT_EVENT_QUEUE_MODE_RX_OFF
Queue mode RX off.
Definition: lwm2m.h:2172
@ LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_TRANSFER_COMPLETE
Bootstrap transfer complete.
Definition: lwm2m.h:2158
@ LWM2M_RD_CLIENT_EVENT_SERVER_DISABLED
Server disabled.
Definition: lwm2m.h:2182
@ LWM2M_RD_CLIENT_EVENT_REGISTRATION_COMPLETE
Registration complete.
Definition: lwm2m.h:2162
@ LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT
Registration timeout.
Definition: lwm2m.h:2164
@ LWM2M_RD_CLIENT_EVENT_REG_UPDATE_COMPLETE
Registration update complete.
Definition: lwm2m.h:2166
@ LWM2M_RD_CLIENT_EVENT_DEREGISTER
De-register.
Definition: lwm2m.h:2180
@ LWM2M_RD_CLIENT_EVENT_REG_UPDATE
Registration update.
Definition: lwm2m.h:2178
@ LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_FAILURE
Bootstrap registration failure.
Definition: lwm2m.h:2154
@ LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_COMPLETE
Bootstrap registration complete.
Definition: lwm2m.h:2156
@ LWM2M_RD_CLIENT_EVENT_DISCONNECT
Disconnected.
Definition: lwm2m.h:2170
@ LWM2M_RD_CLIENT_EVENT_NONE
Invalid event.
Definition: lwm2m.h:2152
@ LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE
Registration failure.
Definition: lwm2m.h:2160
@ LWM2M_RD_CLIENT_EVENT_ENGINE_SUSPENDED
Engine suspended.
Definition: lwm2m.h:2174
@ LWM2M_RD_CLIENT_EVENT_NETWORK_ERROR
Network error.
Definition: lwm2m.h:2176
struct _slist sys_slist_t
Single-linked list structure.
Definition: slist.h:49
Public kernel APIs.
time_t time(time_t *tloc)
flags
Definition: parser.h:96
state
Definition: parser_state.h:29
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__INT32_TYPE__ int32_t
Definition: stdint.h:74
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
__INT64_TYPE__ int64_t
Definition: stdint.h:75
__INT8_TYPE__ int8_t
Definition: stdint.h:72
__INT16_TYPE__ int16_t
Definition: stdint.h:73
Represents a request awaiting for an acknowledgment (ACK).
Definition: coap.h:352
Represents the handler for the reply of a request, it is also used when observing resources.
Definition: coap.h:367
LwM2M context structure to maintain information for a single LwM2M connection.
Definition: lwm2m.h:160
lwm2m_socket_fault_cb_t fault_cb
Socket fault callback.
Definition: lwm2m.h:256
char * desthostname
Destination hostname.
Definition: lwm2m.h:199
bool hostname_verify
Flag to indicate if hostname verification is enabled.
Definition: lwm2m.h:203
lwm2m_observe_cb_t observe_cb
Callback for new or cancelled observations, and acknowledged or timed out notifications.
Definition: lwm2m.h:261
struct sockaddr remote_addr
Destination address storage.
Definition: lwm2m.h:162
uint8_t validate_buf[CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE]
Validation buffer.
Definition: lwm2m.h:270
int(* load_credentials)(struct lwm2m_ctx *client_ctx)
Custom load_credentials function.
Definition: lwm2m.h:209
int tls_tag
TLS tag is set by client as a reference used when the LwM2M engine calls tls_credential_(add|delete)
Definition: lwm2m.h:193
int(* set_socketoptions)(struct lwm2m_ctx *client_ctx)
Custom socket options.
Definition: lwm2m.h:217
int srv_obj_inst
Current index of Server Object used in this context.
Definition: lwm2m.h:243
void * processed_req
A pointer to currently processed request, for internal LwM2M engine use.
Definition: lwm2m.h:181
bool bootstrap_mode
Flag to enable BOOTSTRAP interface.
Definition: lwm2m.h:248
lwm2m_ctx_event_cb_t event_cb
Callback for client events.
Definition: lwm2m.h:264
int sec_obj_inst
Current index of Security Object used for server credentials.
Definition: lwm2m.h:240
bool buffer_client_messages
Flag to indicate that the client is buffering Notifications and Send messages.
Definition: lwm2m.h:237
void(* set_socket_state)(int fd, enum lwm2m_socket_states state)
Callback to indicate transmission states.
Definition: lwm2m.h:278
bool use_dtls
Flag to indicate if context should use DTLS.
Definition: lwm2m.h:224
int sock_fd
Socket File Descriptor.
Definition: lwm2m.h:251
uint16_t desthostnamelen
Destination hostname length.
Definition: lwm2m.h:201
bool connection_suspended
Flag to indicate that the socket connection is suspended.
Definition: lwm2m.h:230
LwM2M object path structure.
Definition: lwm2m.h:96
uint16_t obj_inst_id
Object instance ID.
Definition: lwm2m.h:98
uint16_t res_inst_id
Resource instance ID.
Definition: lwm2m.h:100
uint8_t level
Path level (0-4).
Definition: lwm2m.h:101
uint16_t res_id
Resource ID.
Definition: lwm2m.h:99
uint16_t obj_id
Object ID.
Definition: lwm2m.h:97
LWM2M Objlnk resource type structure.
Definition: lwm2m.h:742
uint16_t obj_id
Object ID.
Definition: lwm2m.h:743
uint16_t obj_inst
Object instance ID.
Definition: lwm2m.h:744
LwM2M resource item structure.
Definition: lwm2m.h:1242
uint16_t size
Size of the value.
Definition: lwm2m.h:1248
void * value
Pointer to resource value.
Definition: lwm2m.h:1246
struct lwm2m_obj_path * path
Pointer to LwM2M path as a struct.
Definition: lwm2m.h:1244
LwM2M Time series data structure.
Definition: lwm2m.h:284
time_t t
Cached data Unix timestamp.
Definition: lwm2m.h:286
Generic sockaddr struct.
Definition: net_ip.h:385