Zephyr API Documentation  3.6.0
A Scalable Open Source RTOS
3.6.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
24#ifndef ZEPHYR_INCLUDE_NET_LWM2M_H_
25#define ZEPHYR_INCLUDE_NET_LWM2M_H_
26
27#include <time.h>
28#include <zephyr/kernel.h>
29#include <zephyr/sys/mutex.h>
30#include <zephyr/net/coap.h>
32
39/* clang-format off */
40#define LWM2M_OBJECT_SECURITY_ID 0
41#define LWM2M_OBJECT_SERVER_ID 1
42#define LWM2M_OBJECT_ACCESS_CONTROL_ID 2
43#define LWM2M_OBJECT_DEVICE_ID 3
44#define LWM2M_OBJECT_CONNECTIVITY_MONITORING_ID 4
45#define LWM2M_OBJECT_FIRMWARE_ID 5
46#define LWM2M_OBJECT_LOCATION_ID 6
47#define LWM2M_OBJECT_CONNECTIVITY_STATISTICS_ID 7
48#define LWM2M_OBJECT_SOFTWARE_MANAGEMENT_ID 9
49#define LWM2M_OBJECT_PORTFOLIO_ID 16
50#define LWM2M_OBJECT_BINARYAPPDATACONTAINER_ID 19
51#define LWM2M_OBJECT_EVENT_LOG_ID 20
52#define LWM2M_OBJECT_OSCORE_ID 21
53#define LWM2M_OBJECT_GATEWAY_ID 25
54/* clang-format on */
55
66/* clang-format off */
67#define IPSO_OBJECT_GENERIC_SENSOR_ID 3300
68#define IPSO_OBJECT_TEMP_SENSOR_ID 3303
69#define IPSO_OBJECT_HUMIDITY_SENSOR_ID 3304
70#define IPSO_OBJECT_LIGHT_CONTROL_ID 3311
71#define IPSO_OBJECT_ACCELEROMETER_ID 3313
72#define IPSO_OBJECT_VOLTAGE_SENSOR_ID 3316
73#define IPSO_OBJECT_CURRENT_SENSOR_ID 3317
74#define IPSO_OBJECT_PRESSURE_ID 3323
75#define IPSO_OBJECT_BUZZER_ID 3338
76#define IPSO_OBJECT_TIMER_ID 3340
77#define IPSO_OBJECT_ONOFF_SWITCH_ID 3342
78#define IPSO_OBJECT_PUSH_BUTTON_ID 3347
79#define UCIFI_OBJECT_BATTERY_ID 3411
80#define IPSO_OBJECT_FILLING_LEVEL_SENSOR_ID 3435
81/* clang-format on */
82
90typedef void (*lwm2m_socket_fault_cb_t)(int error);
91
99};
100
109};
110
121typedef void (*lwm2m_observe_cb_t)(enum lwm2m_observe_event event, struct lwm2m_obj_path *path,
122 void *user_data);
123
124
125struct lwm2m_ctx;
133typedef void (*lwm2m_ctx_event_cb_t)(struct lwm2m_ctx *ctx,
134 enum lwm2m_rd_client_event event);
135
136
151};
152
157struct lwm2m_ctx {
160
164 struct coap_pending pendings[CONFIG_LWM2M_ENGINE_MAX_PENDING + 1];
165 struct coap_reply replies[CONFIG_LWM2M_ENGINE_MAX_REPLIES + 1];
166 sys_slist_t pending_sends;
167#if defined(CONFIG_LWM2M_QUEUE_MODE_ENABLED)
168 sys_slist_t queued_messages;
169#endif
170 sys_slist_t observer;
179
180#if defined(CONFIG_LWM2M_DTLS_SUPPORT) || defined(__DOXYGEN__)
191
201
206 int (*load_credentials)(struct lwm2m_ctx *client_ctx);
208#endif
214 int (*set_socketoptions)(struct lwm2m_ctx *client_ctx);
215
222
228
229#if defined(CONFIG_LWM2M_QUEUE_MODE_ENABLED) || defined(__DOXYGEN__)
235#endif
238
241
246
249
254
259
262
267 uint8_t validate_buf[CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE];
268
276};
277
284 union {
294 double f;
295 bool b;
296 };
297};
298
318typedef void *(*lwm2m_engine_get_data_cb_t)(uint16_t obj_inst_id,
319 uint16_t res_id,
320 uint16_t res_inst_id,
321 size_t *data_len);
322
349typedef int (*lwm2m_engine_set_data_cb_t)(uint16_t obj_inst_id,
350 uint16_t res_id, uint16_t res_inst_id,
351 uint8_t *data, uint16_t data_len,
352 bool last_block, size_t total_size);
353
370typedef int (*lwm2m_engine_user_cb_t)(uint16_t obj_inst_id);
371
388typedef int (*lwm2m_engine_execute_cb_t)(uint16_t obj_inst_id,
389 uint8_t *args, uint16_t args_len);
390
396#define LWM2M_DEVICE_PWR_SRC_TYPE_DC_POWER 0
397#define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_INT 1
398#define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_EXT 2
399#define LWM2M_DEVICE_PWR_SRC_TYPE_FUEL_CELL 3
400#define LWM2M_DEVICE_PWR_SRC_TYPE_PWR_OVER_ETH 4
401#define LWM2M_DEVICE_PWR_SRC_TYPE_USB 5
402#define LWM2M_DEVICE_PWR_SRC_TYPE_AC_POWER 6
403#define LWM2M_DEVICE_PWR_SRC_TYPE_SOLAR 7
404#define LWM2M_DEVICE_PWR_SRC_TYPE_MAX 8
414#define LWM2M_DEVICE_ERROR_NONE 0
415#define LWM2M_DEVICE_ERROR_LOW_POWER 1
416#define LWM2M_DEVICE_ERROR_EXT_POWER_SUPPLY_OFF 2
417#define LWM2M_DEVICE_ERROR_GPS_FAILURE 3
418#define LWM2M_DEVICE_ERROR_LOW_SIGNAL_STRENGTH 4
419#define LWM2M_DEVICE_ERROR_OUT_OF_MEMORY 5
420#define LWM2M_DEVICE_ERROR_SMS_FAILURE 6
421#define LWM2M_DEVICE_ERROR_NETWORK_FAILURE 7
422#define LWM2M_DEVICE_ERROR_PERIPHERAL_FAILURE 8
433#define LWM2M_DEVICE_BATTERY_STATUS_NORMAL 0
436#define LWM2M_DEVICE_BATTERY_STATUS_CHARGING 1
437#define LWM2M_DEVICE_BATTERY_STATUS_CHARGE_COMP 2
440#define LWM2M_DEVICE_BATTERY_STATUS_DAMAGED 3
441#define LWM2M_DEVICE_BATTERY_STATUS_LOW 4
442#define LWM2M_DEVICE_BATTERY_STATUS_NOT_INST 5
443#define LWM2M_DEVICE_BATTERY_STATUS_UNKNOWN 6
455
456
468#define STATE_IDLE 0
472#define STATE_DOWNLOADING 1
476#define STATE_DOWNLOADED 2
480#define STATE_UPDATING 3
481
492#define RESULT_DEFAULT 0
493#define RESULT_SUCCESS 1
494#define RESULT_NO_STORAGE 2
495#define RESULT_OUT_OF_MEM 3
496#define RESULT_CONNECTION_LOST 4
497#define RESULT_INTEGRITY_FAILED 5
498#define RESULT_UNSUP_FW 6
499#define RESULT_INVALID_URI 7
500#define RESULT_UPDATE_FAILED 8
501#define RESULT_UNSUP_PROTO 9
505#if defined(CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT) || defined(__DOXYGEN__)
515
522
533
541
551
558
569
577
587
594
605
613#endif
614
615#if defined(CONFIG_LWM2M_SWMGMT_OBJ_SUPPORT) || defined(__DOXYGEN__)
616
629
642
655
668
681
694
705int lwm2m_swmgmt_install_completed(uint16_t obj_inst_id, int error_code);
706
707#endif
708
709#if defined(CONFIG_LWM2M_EVENT_LOG_OBJ_SUPPORT) || defined(__DOXYGEN__)
710
720
721#endif
722
726#define LWM2M_OBJLNK_MAX_ID USHRT_MAX
727
734};
735
752__deprecated
753int lwm2m_engine_update_observer_min_period(struct lwm2m_ctx *client_ctx, const char *pathstr,
754 uint32_t period_s);
755
771 const struct lwm2m_obj_path *path, uint32_t period_s);
772
789__deprecated
790int lwm2m_engine_update_observer_max_period(struct lwm2m_ctx *client_ctx, const char *pathstr,
791 uint32_t period_s);
792
808 const struct lwm2m_obj_path *path, uint32_t period_s);
809
823__deprecated
824int lwm2m_engine_create_obj_inst(const char *pathstr);
825
838
850__deprecated
851int lwm2m_engine_delete_obj_inst(const char *pathstr);
852
863
872
878
890__deprecated
891int lwm2m_engine_set_opaque(const char *pathstr, const char *data_ptr, uint16_t data_len);
892
902int lwm2m_set_opaque(const struct lwm2m_obj_path *path, const char *data_ptr, uint16_t data_len);
903
914__deprecated
915int lwm2m_engine_set_string(const char *pathstr, const char *data_ptr);
916
925int lwm2m_set_string(const struct lwm2m_obj_path *path, const char *data_ptr);
926
937__deprecated
938int lwm2m_engine_set_u8(const char *pathstr, uint8_t value);
939
948int lwm2m_set_u8(const struct lwm2m_obj_path *path, uint8_t value);
949
960__deprecated
961int lwm2m_engine_set_u16(const char *pathstr, uint16_t value);
962
971int lwm2m_set_u16(const struct lwm2m_obj_path *path, uint16_t value);
972
983__deprecated
984int lwm2m_engine_set_u32(const char *pathstr, uint32_t value);
985
994int lwm2m_set_u32(const struct lwm2m_obj_path *path, uint32_t value);
995
1006__deprecated
1007int lwm2m_engine_set_u64(const char *pathstr, uint64_t value);
1008
1021__deprecated
1022int lwm2m_set_u64(const struct lwm2m_obj_path *path, uint64_t value);
1023
1034__deprecated
1035int lwm2m_engine_set_s8(const char *pathstr, int8_t value);
1036
1045int lwm2m_set_s8(const struct lwm2m_obj_path *path, int8_t value);
1046
1057__deprecated
1058int lwm2m_engine_set_s16(const char *pathstr, int16_t value);
1059
1068int lwm2m_set_s16(const struct lwm2m_obj_path *path, int16_t value);
1069
1080__deprecated
1081int lwm2m_engine_set_s32(const char *pathstr, int32_t value);
1082
1091int lwm2m_set_s32(const struct lwm2m_obj_path *path, int32_t value);
1092
1103__deprecated
1104int lwm2m_engine_set_s64(const char *pathstr, int64_t value);
1105
1114int lwm2m_set_s64(const struct lwm2m_obj_path *path, int64_t value);
1115
1126__deprecated
1127int lwm2m_engine_set_bool(const char *pathstr, bool value);
1128
1137int lwm2m_set_bool(const struct lwm2m_obj_path *path, bool value);
1138
1149__deprecated
1150int lwm2m_engine_set_float(const char *pathstr, const double *value);
1151
1160int lwm2m_set_f64(const struct lwm2m_obj_path *path, const double value);
1161
1172__deprecated
1173int lwm2m_engine_set_objlnk(const char *pathstr, const struct lwm2m_objlnk *value);
1174
1183int lwm2m_set_objlnk(const struct lwm2m_obj_path *path, const struct lwm2m_objlnk *value);
1184
1195__deprecated
1196int lwm2m_engine_set_time(const char *pathstr, time_t value);
1197
1206int lwm2m_set_time(const struct lwm2m_obj_path *path, time_t value);
1207
1219__deprecated
1220int lwm2m_engine_get_opaque(const char *pathstr, void *buf, uint16_t buflen);
1221
1231int lwm2m_get_opaque(const struct lwm2m_obj_path *path, void *buf, uint16_t buflen);
1232
1244__deprecated
1245int lwm2m_engine_get_string(const char *pathstr, void *str, uint16_t buflen);
1246
1256int lwm2m_get_string(const struct lwm2m_obj_path *path, void *str, uint16_t buflen);
1257
1268__deprecated
1269int lwm2m_engine_get_u8(const char *pathstr, uint8_t *value);
1270
1279int lwm2m_get_u8(const struct lwm2m_obj_path *path, uint8_t *value);
1280
1291__deprecated
1292int lwm2m_engine_get_u16(const char *pathstr, uint16_t *value);
1293
1302int lwm2m_get_u16(const struct lwm2m_obj_path *path, uint16_t *value);
1303
1314__deprecated
1315int lwm2m_engine_get_u32(const char *pathstr, uint32_t *value);
1316
1325int lwm2m_get_u32(const struct lwm2m_obj_path *path, uint32_t *value);
1326
1337__deprecated
1338int lwm2m_engine_get_u64(const char *pathstr, uint64_t *value);
1339
1352__deprecated
1353int lwm2m_get_u64(const struct lwm2m_obj_path *path, uint64_t *value);
1354
1365__deprecated
1366int lwm2m_engine_get_s8(const char *pathstr, int8_t *value);
1367
1376int lwm2m_get_s8(const struct lwm2m_obj_path *path, int8_t *value);
1377
1388__deprecated
1389int lwm2m_engine_get_s16(const char *pathstr, int16_t *value);
1390
1399int lwm2m_get_s16(const struct lwm2m_obj_path *path, int16_t *value);
1400
1411__deprecated
1412int lwm2m_engine_get_s32(const char *pathstr, int32_t *value);
1413
1422int lwm2m_get_s32(const struct lwm2m_obj_path *path, int32_t *value);
1423
1434__deprecated
1435int lwm2m_engine_get_s64(const char *pathstr, int64_t *value);
1436
1445int lwm2m_get_s64(const struct lwm2m_obj_path *path, int64_t *value);
1446
1457__deprecated
1458int lwm2m_engine_get_bool(const char *pathstr, bool *value);
1459
1468int lwm2m_get_bool(const struct lwm2m_obj_path *path, bool *value);
1469
1480__deprecated
1481int lwm2m_engine_get_float(const char *pathstr, double *buf);
1482
1491int lwm2m_get_f64(const struct lwm2m_obj_path *path, double *value);
1492
1503__deprecated
1504int lwm2m_engine_get_objlnk(const char *pathstr, struct lwm2m_objlnk *buf);
1505
1514int lwm2m_get_objlnk(const struct lwm2m_obj_path *path, struct lwm2m_objlnk *buf);
1515
1526__deprecated
1527int lwm2m_engine_get_time(const char *pathstr, time_t *buf);
1528
1537int lwm2m_get_time(const struct lwm2m_obj_path *path, time_t *buf);
1538
1559__deprecated
1562
1582
1597__deprecated
1600
1615
1638__deprecated
1641
1664
1681__deprecated
1684
1701
1714__deprecated
1717
1729
1742__deprecated
1745
1758
1771__deprecated
1774
1787
1791#define LWM2M_RES_DATA_READ_ONLY 0
1792
1796#define LWM2M_RES_DATA_FLAG_RO BIT(LWM2M_RES_DATA_READ_ONLY)
1797
1801#define LWM2M_HAS_RES_FLAG(res, f) ((res->data_flags & f) == f)
1802
1819__deprecated
1820int lwm2m_engine_set_res_buf(const char *pathstr, void *buffer_ptr, uint16_t buffer_len,
1821 uint16_t data_len, uint8_t data_flags);
1822
1837int lwm2m_set_res_buf(const struct lwm2m_obj_path *path, void *buffer_ptr, uint16_t buffer_len,
1838 uint16_t data_len, uint8_t data_flags);
1839
1856__deprecated
1857int lwm2m_engine_set_res_data(const char *pathstr, void *data_ptr, uint16_t data_len,
1858 uint8_t data_flags);
1859
1872__deprecated
1873int lwm2m_engine_set_res_data_len(const char *pathstr, uint16_t data_len);
1874
1885int lwm2m_set_res_data_len(const struct lwm2m_obj_path *path, uint16_t data_len);
1886
1908__deprecated
1909int lwm2m_engine_get_res_buf(const char *pathstr, void **buffer_ptr, uint16_t *buffer_len,
1910 uint16_t *data_len, uint8_t *data_flags);
1911
1931int lwm2m_get_res_buf(const struct lwm2m_obj_path *path, void **buffer_ptr, uint16_t *buffer_len,
1932 uint16_t *data_len, uint8_t *data_flags);
1933
1949__deprecated
1950int lwm2m_engine_get_res_data(const char *pathstr, void **data_ptr, uint16_t *data_len,
1951 uint8_t *data_flags);
1952
1966__deprecated
1967int lwm2m_engine_create_res_inst(const char *pathstr);
1968
1981
1993__deprecated
1994int lwm2m_engine_delete_res_inst(const char *pathstr);
1995
2006
2018
2032__deprecated
2033bool lwm2m_engine_path_is_observed(const char *pathstr);
2034
2047
2059int lwm2m_engine_stop(struct lwm2m_ctx *client_ctx);
2060
2072int lwm2m_engine_start(struct lwm2m_ctx *client_ctx);
2073
2085void lwm2m_acknowledge(struct lwm2m_ctx *client_ctx);
2086
2110};
2111
2115#define LWM2M_RD_CLIENT_EVENT_REG_UPDATE_FAILURE \
2116 LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT __DEPRECATED_MACRO
2117
2118/*
2119 * LwM2M RD client flags, used to configure LwM2M session.
2120 */
2121
2125#define LWM2M_RD_CLIENT_FLAG_BOOTSTRAP BIT(0)
2126
2148int lwm2m_rd_client_start(struct lwm2m_ctx *client_ctx, const char *ep_name,
2150 lwm2m_observe_cb_t observe_cb);
2151
2167int lwm2m_rd_client_stop(struct lwm2m_ctx *client_ctx,
2168 lwm2m_ctx_event_cb_t event_cb, bool deregister);
2169
2180
2192
2197
2201#define LWM2M_MAX_PATH_STR_SIZE sizeof("/65535/65535/65535/65535")
2202
2211char *lwm2m_path_log_buf(char *buf, struct lwm2m_obj_path *path);
2212
2223};
2224
2229typedef void (*lwm2m_send_cb_t)(enum lwm2m_send_status status);
2230
2244__deprecated
2245int lwm2m_engine_send(struct lwm2m_ctx *ctx, char const *path_list[], uint8_t path_list_size,
2246 bool confirmation_request);
2247
2261__deprecated
2262int lwm2m_send(struct lwm2m_ctx *ctx, const struct lwm2m_obj_path path_list[],
2263 uint8_t path_list_size, bool confirmation_request);
2264
2276int lwm2m_send_cb(struct lwm2m_ctx *ctx, const struct lwm2m_obj_path path_list[],
2277 uint8_t path_list_size, lwm2m_send_cb_t reply_cb);
2278
2286
2302__deprecated
2303int lwm2m_engine_enable_cache(char const *resource_path, struct lwm2m_time_series_elem *data_cache,
2304 size_t cache_len);
2305
2319int lwm2m_enable_cache(const struct lwm2m_obj_path *path, struct lwm2m_time_series_elem *data_cache,
2320 size_t cache_len);
2321
2331};
2332
2342
2354
2355#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_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)
Asynchronous callback when data has been set to a resource buffer.
Definition: lwm2m.h:349
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:2325
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:2219
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:133
void lwm2m_firmware_set_cancel_cb(lwm2m_engine_user_cb_t cb)
Set callback for firmware update cancel.
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_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:318
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:146
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:2229
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:370
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:104
lwm2m_rd_client_event
LwM2M RD client events.
Definition: lwm2m.h:2093
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:121
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:90
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:388
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:2326
@ LWM2M_SECURITY_RAW_PK
Raw Public Key mode.
Definition: lwm2m.h:2327
@ LWM2M_SECURITY_CERT
Certificate mode.
Definition: lwm2m.h:2328
@ LWM2M_SECURITY_CERT_EST
Certificate mode with EST.
Definition: lwm2m.h:2330
@ LWM2M_SECURITY_NOSEC
NoSec mode.
Definition: lwm2m.h:2329
@ LWM2M_SEND_STATUS_SUCCESS
Definition: lwm2m.h:2220
@ LWM2M_SEND_STATUS_FAILURE
Definition: lwm2m.h:2221
@ LWM2M_SEND_STATUS_TIMEOUT
Definition: lwm2m.h:2222
@ LWM2M_SOCKET_STATE_NO_DATA
No more data is expected.
Definition: lwm2m.h:150
@ LWM2M_SOCKET_STATE_ONE_RESPONSE
One response is expected for the next message.
Definition: lwm2m.h:148
@ LWM2M_SOCKET_STATE_ONGOING
Ongoing traffic is expected.
Definition: lwm2m.h:147
@ LWM2M_SOCKET_STATE_LAST
Next message is the last one.
Definition: lwm2m.h:149
@ LWM2M_OBSERVE_EVENT_OBSERVER_ADDED
Observer added.
Definition: lwm2m.h:105
@ LWM2M_OBSERVE_EVENT_NOTIFY_TIMEOUT
Notification timed out.
Definition: lwm2m.h:108
@ LWM2M_OBSERVE_EVENT_NOTIFY_ACK
Notification ACKed.
Definition: lwm2m.h:107
@ LWM2M_OBSERVE_EVENT_OBSERVER_REMOVED
Observer removed.
Definition: lwm2m.h:106
@ LWM2M_RD_CLIENT_EVENT_DEREGISTER_FAILURE
Definition: lwm2m.h:2102
@ LWM2M_RD_CLIENT_EVENT_QUEUE_MODE_RX_OFF
Definition: lwm2m.h:2104
@ LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_TRANSFER_COMPLETE
Definition: lwm2m.h:2097
@ LWM2M_RD_CLIENT_EVENT_SERVER_DISABLED
Definition: lwm2m.h:2109
@ LWM2M_RD_CLIENT_EVENT_REGISTRATION_COMPLETE
Definition: lwm2m.h:2099
@ LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT
Definition: lwm2m.h:2100
@ LWM2M_RD_CLIENT_EVENT_REG_UPDATE_COMPLETE
Definition: lwm2m.h:2101
@ LWM2M_RD_CLIENT_EVENT_DEREGISTER
Definition: lwm2m.h:2108
@ LWM2M_RD_CLIENT_EVENT_REG_UPDATE
Definition: lwm2m.h:2107
@ LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_FAILURE
Definition: lwm2m.h:2095
@ LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_COMPLETE
Definition: lwm2m.h:2096
@ LWM2M_RD_CLIENT_EVENT_DISCONNECT
Definition: lwm2m.h:2103
@ LWM2M_RD_CLIENT_EVENT_NONE
Definition: lwm2m.h:2094
@ LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE
Definition: lwm2m.h:2098
@ LWM2M_RD_CLIENT_EVENT_ENGINE_SUSPENDED
Definition: lwm2m.h:2105
@ LWM2M_RD_CLIENT_EVENT_NETWORK_ERROR
Definition: lwm2m.h:2106
struct _slist sys_slist_t
Single-linked list structure.
Definition: slist.h:49
Public kernel APIs.
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:327
Represents the handler for the reply of a request, it is also used when observing resources.
Definition: coap.h:342
LwM2M context structure to maintain information for a single LwM2M connection.
Definition: lwm2m.h:157
lwm2m_socket_fault_cb_t fault_cb
Socket fault callback.
Definition: lwm2m.h:253
char * desthostname
Destination hostname.
Definition: lwm2m.h:196
bool hostname_verify
Flag to indicate if hostname verification is enabled.
Definition: lwm2m.h:200
lwm2m_observe_cb_t observe_cb
Callback for new or cancelled observations, and acknowledged or timed out notifications.
Definition: lwm2m.h:258
struct sockaddr remote_addr
Destination address storage.
Definition: lwm2m.h:159
uint8_t validate_buf[CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE]
Validation buffer.
Definition: lwm2m.h:267
int(* load_credentials)(struct lwm2m_ctx *client_ctx)
Custom load_credentials function.
Definition: lwm2m.h:206
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:190
int(* set_socketoptions)(struct lwm2m_ctx *client_ctx)
Custom socket options.
Definition: lwm2m.h:214
int srv_obj_inst
Current index of Server Object used in this context.
Definition: lwm2m.h:240
void * processed_req
A pointer to currently processed request, for internal LwM2M engine use.
Definition: lwm2m.h:178
bool bootstrap_mode
Flag to enable BOOTSTRAP interface.
Definition: lwm2m.h:245
lwm2m_ctx_event_cb_t event_cb
Callback for client events.
Definition: lwm2m.h:261
int sec_obj_inst
Current index of Security Object used for server credentials.
Definition: lwm2m.h:237
bool buffer_client_messages
Flag to indicate that the client is buffering Notifications and Send messages.
Definition: lwm2m.h:234
void(* set_socket_state)(int fd, enum lwm2m_socket_states state)
Callback to indicate transmission states.
Definition: lwm2m.h:275
bool use_dtls
Flag to indicate if context should use DTLS.
Definition: lwm2m.h:221
int sock_fd
Socket File Descriptor.
Definition: lwm2m.h:248
uint16_t desthostnamelen
Destination hostname length.
Definition: lwm2m.h:198
bool connection_suspended
Flag to indicate that the socket connection is suspended.
Definition: lwm2m.h:227
LwM2M object path structure.
Definition: lwm2m.h:93
uint16_t obj_inst_id
Object instance ID.
Definition: lwm2m.h:95
uint16_t res_inst_id
Resource instance ID.
Definition: lwm2m.h:97
uint8_t level
Path level (0-4).
Definition: lwm2m.h:98
uint16_t res_id
Resource ID.
Definition: lwm2m.h:96
uint16_t obj_id
Object ID.
Definition: lwm2m.h:94
LWM2M Objlnk resource type structure.
Definition: lwm2m.h:731
uint16_t obj_id
Object ID.
Definition: lwm2m.h:732
uint16_t obj_inst
Object instance ID.
Definition: lwm2m.h:733
LwM2M Time series data structure.
Definition: lwm2m.h:281
int64_t i64
Definition: lwm2m.h:292
int16_t i16
Definition: lwm2m.h:290
double f
Definition: lwm2m.h:294
uint32_t u32
Definition: lwm2m.h:287
int32_t i32
Definition: lwm2m.h:291
int8_t i8
Definition: lwm2m.h:289
uint8_t u8
Definition: lwm2m.h:285
time_t t
Cached data Unix timestamp.
Definition: lwm2m.h:283
uint16_t u16
Definition: lwm2m.h:286
uint64_t u64
Definition: lwm2m.h:288
bool b
Definition: lwm2m.h:295
time_t time
Definition: lwm2m.h:293
Generic sockaddr struct.
Definition: net_ip.h:347