Zephyr API Documentation 4.0.0
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
36#ifdef __cplusplus
37extern "C" {
38#endif
39
46/* clang-format off */
47#define LWM2M_OBJECT_SECURITY_ID 0
48#define LWM2M_OBJECT_SERVER_ID 1
49#define LWM2M_OBJECT_ACCESS_CONTROL_ID 2
50#define LWM2M_OBJECT_DEVICE_ID 3
51#define LWM2M_OBJECT_CONNECTIVITY_MONITORING_ID 4
52#define LWM2M_OBJECT_FIRMWARE_ID 5
53#define LWM2M_OBJECT_LOCATION_ID 6
54#define LWM2M_OBJECT_CONNECTIVITY_STATISTICS_ID 7
55#define LWM2M_OBJECT_SOFTWARE_MANAGEMENT_ID 9
56#define LWM2M_OBJECT_PORTFOLIO_ID 16
57#define LWM2M_OBJECT_BINARYAPPDATACONTAINER_ID 19
58#define LWM2M_OBJECT_EVENT_LOG_ID 20
59#define LWM2M_OBJECT_OSCORE_ID 21
60#define LWM2M_OBJECT_GATEWAY_ID 25
61/* clang-format on */
62
73/* clang-format off */
74#define IPSO_OBJECT_GENERIC_SENSOR_ID 3300
75#define IPSO_OBJECT_TEMP_SENSOR_ID 3303
76#define IPSO_OBJECT_HUMIDITY_SENSOR_ID 3304
77#define IPSO_OBJECT_LIGHT_CONTROL_ID 3311
78#define IPSO_OBJECT_ACCELEROMETER_ID 3313
79#define IPSO_OBJECT_VOLTAGE_SENSOR_ID 3316
80#define IPSO_OBJECT_CURRENT_SENSOR_ID 3317
81#define IPSO_OBJECT_PRESSURE_ID 3323
82#define IPSO_OBJECT_BUZZER_ID 3338
83#define IPSO_OBJECT_TIMER_ID 3340
84#define IPSO_OBJECT_ONOFF_SWITCH_ID 3342
85#define IPSO_OBJECT_PUSH_BUTTON_ID 3347
86#define UCIFI_OBJECT_BATTERY_ID 3411
87#define IPSO_OBJECT_FILLING_LEVEL_SENSOR_ID 3435
88/* clang-format on */
89
97typedef void (*lwm2m_socket_fault_cb_t)(int error);
98
107
117
128typedef void (*lwm2m_observe_cb_t)(enum lwm2m_observe_event event, struct lwm2m_obj_path *path,
129 void *user_data);
130
131
132struct lwm2m_ctx;
133
174
175
182typedef void (*lwm2m_ctx_event_cb_t)(struct lwm2m_ctx *ctx,
183 enum lwm2m_rd_client_event event);
184
185
201
206struct lwm2m_ctx {
209
213 struct coap_pending pendings[CONFIG_LWM2M_ENGINE_MAX_PENDING + 1];
214 struct coap_reply replies[CONFIG_LWM2M_ENGINE_MAX_REPLIES + 1];
215 sys_slist_t pending_sends;
216#if defined(CONFIG_LWM2M_QUEUE_MODE_ENABLED)
217 sys_slist_t queued_messages;
218#endif
219 sys_slist_t observer;
220 struct k_mutex lock;
229
230#if defined(CONFIG_LWM2M_DTLS_SUPPORT) || defined(__DOXYGEN__)
241
249
254 int (*load_credentials)(struct lwm2m_ctx *client_ctx);
256#endif
262 int (*set_socketoptions)(struct lwm2m_ctx *client_ctx);
263
270
276
277#if defined(CONFIG_LWM2M_QUEUE_MODE_ENABLED) || defined(__DOXYGEN__)
283#endif
286
289
294
297
302
307
310
315 uint8_t validate_buf[CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE];
316
324};
325
333 union {
335 uint8_t u8;
336 uint16_t u16;
337 uint32_t u32;
338 uint64_t u64;
339 int8_t i8;
340 int16_t i16;
341 int32_t i32;
342 int64_t i64;
343 time_t time;
344 double f;
345 bool b;
347 };
348};
349
369typedef void *(*lwm2m_engine_get_data_cb_t)(uint16_t obj_inst_id,
370 uint16_t res_id,
371 uint16_t res_inst_id,
372 size_t *data_len);
373
405typedef int (*lwm2m_engine_set_data_cb_t)(uint16_t obj_inst_id,
406 uint16_t res_id, uint16_t res_inst_id,
407 uint8_t *data, uint16_t data_len,
408 bool last_block, size_t total_size, size_t offset);
409
426typedef int (*lwm2m_engine_user_cb_t)(uint16_t obj_inst_id);
427
444typedef int (*lwm2m_engine_execute_cb_t)(uint16_t obj_inst_id,
445 uint8_t *args, uint16_t args_len);
446
452#define LWM2M_DEVICE_PWR_SRC_TYPE_DC_POWER 0
453#define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_INT 1
454#define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_EXT 2
455#define LWM2M_DEVICE_PWR_SRC_TYPE_FUEL_CELL 3
456#define LWM2M_DEVICE_PWR_SRC_TYPE_PWR_OVER_ETH 4
457#define LWM2M_DEVICE_PWR_SRC_TYPE_USB 5
458#define LWM2M_DEVICE_PWR_SRC_TYPE_AC_POWER 6
459#define LWM2M_DEVICE_PWR_SRC_TYPE_SOLAR 7
460#define LWM2M_DEVICE_PWR_SRC_TYPE_MAX 8
470#define LWM2M_DEVICE_ERROR_NONE 0
471#define LWM2M_DEVICE_ERROR_LOW_POWER 1
472#define LWM2M_DEVICE_ERROR_EXT_POWER_SUPPLY_OFF 2
473#define LWM2M_DEVICE_ERROR_GPS_FAILURE 3
474#define LWM2M_DEVICE_ERROR_LOW_SIGNAL_STRENGTH 4
475#define LWM2M_DEVICE_ERROR_OUT_OF_MEMORY 5
476#define LWM2M_DEVICE_ERROR_SMS_FAILURE 6
477#define LWM2M_DEVICE_ERROR_NETWORK_FAILURE 7
478#define LWM2M_DEVICE_ERROR_PERIPHERAL_FAILURE 8
489#define LWM2M_DEVICE_BATTERY_STATUS_NORMAL 0
492#define LWM2M_DEVICE_BATTERY_STATUS_CHARGING 1
493#define LWM2M_DEVICE_BATTERY_STATUS_CHARGE_COMP 2
496#define LWM2M_DEVICE_BATTERY_STATUS_DAMAGED 3
497#define LWM2M_DEVICE_BATTERY_STATUS_LOW 4
498#define LWM2M_DEVICE_BATTERY_STATUS_NOT_INST 5
499#define LWM2M_DEVICE_BATTERY_STATUS_UNKNOWN 6
511
512
524#define STATE_IDLE 0
528#define STATE_DOWNLOADING 1
532#define STATE_DOWNLOADED 2
536#define STATE_UPDATING 3
537
548#define RESULT_DEFAULT 0
549#define RESULT_SUCCESS 1
550#define RESULT_NO_STORAGE 2
551#define RESULT_OUT_OF_MEM 3
552#define RESULT_CONNECTION_LOST 4
553#define RESULT_INTEGRITY_FAILED 5
554#define RESULT_UNSUP_FW 6
555#define RESULT_INVALID_URI 7
556#define RESULT_UPDATE_FAILED 8
557#define RESULT_UNSUP_PROTO 9
561#if defined(CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT) || defined(__DOXYGEN__)
571
578
589
597
607
614
625
633
643
650
661
669#endif
670
671#if defined(CONFIG_LWM2M_SWMGMT_OBJ_SUPPORT) || defined(__DOXYGEN__)
672
685
698
711
724
737
750
761int lwm2m_swmgmt_install_completed(uint16_t obj_inst_id, int error_code);
762
763#endif
764
765#if defined(CONFIG_LWM2M_EVENT_LOG_OBJ_SUPPORT) || defined(__DOXYGEN__)
766
776
777#endif
778
782#define LWM2M_OBJLNK_MAX_ID USHRT_MAX
783
791
807 const struct lwm2m_obj_path *path, uint32_t period_s);
808
824 const struct lwm2m_obj_path *path, uint32_t period_s);
825
838
849
858
864
874int lwm2m_set_opaque(const struct lwm2m_obj_path *path, const char *data_ptr, uint16_t data_len);
875
884int lwm2m_set_string(const struct lwm2m_obj_path *path, const char *data_ptr);
885
894int lwm2m_set_u8(const struct lwm2m_obj_path *path, uint8_t value);
895
904int lwm2m_set_u16(const struct lwm2m_obj_path *path, uint16_t value);
905
914int lwm2m_set_u32(const struct lwm2m_obj_path *path, uint32_t value);
915
924int lwm2m_set_s8(const struct lwm2m_obj_path *path, int8_t value);
925
934int lwm2m_set_s16(const struct lwm2m_obj_path *path, int16_t value);
935
944int lwm2m_set_s32(const struct lwm2m_obj_path *path, int32_t value);
945
954int lwm2m_set_s64(const struct lwm2m_obj_path *path, int64_t value);
955
964int lwm2m_set_bool(const struct lwm2m_obj_path *path, bool value);
965
974int lwm2m_set_f64(const struct lwm2m_obj_path *path, const double value);
975
984int lwm2m_set_objlnk(const struct lwm2m_obj_path *path, const struct lwm2m_objlnk *value);
985
994int lwm2m_set_time(const struct lwm2m_obj_path *path, time_t value);
995
1027
1040int lwm2m_set_bulk(const struct lwm2m_res_item res_list[], size_t res_list_size);
1041
1051int lwm2m_get_opaque(const struct lwm2m_obj_path *path, void *buf, uint16_t buflen);
1052
1062int lwm2m_get_string(const struct lwm2m_obj_path *path, void *str, uint16_t buflen);
1063
1072int lwm2m_get_u8(const struct lwm2m_obj_path *path, uint8_t *value);
1073
1082int lwm2m_get_u16(const struct lwm2m_obj_path *path, uint16_t *value);
1083
1092int lwm2m_get_u32(const struct lwm2m_obj_path *path, uint32_t *value);
1093
1102int lwm2m_get_s8(const struct lwm2m_obj_path *path, int8_t *value);
1103
1112int lwm2m_get_s16(const struct lwm2m_obj_path *path, int16_t *value);
1113
1122int lwm2m_get_s32(const struct lwm2m_obj_path *path, int32_t *value);
1123
1132int lwm2m_get_s64(const struct lwm2m_obj_path *path, int64_t *value);
1133
1142int lwm2m_get_bool(const struct lwm2m_obj_path *path, bool *value);
1143
1152int lwm2m_get_f64(const struct lwm2m_obj_path *path, double *value);
1153
1162int lwm2m_get_objlnk(const struct lwm2m_obj_path *path, struct lwm2m_objlnk *buf);
1163
1172int lwm2m_get_time(const struct lwm2m_obj_path *path, time_t *buf);
1173
1193
1208
1231
1248
1260
1273
1286
1290#define LWM2M_RES_DATA_READ_ONLY 0
1291
1295#define LWM2M_RES_DATA_FLAG_RO BIT(LWM2M_RES_DATA_READ_ONLY)
1296
1300#define LWM2M_HAS_RES_FLAG(res, f) ((res->data_flags & f) == f)
1301
1316int lwm2m_set_res_buf(const struct lwm2m_obj_path *path, void *buffer_ptr, uint16_t buffer_len,
1317 uint16_t data_len, uint8_t data_flags);
1318
1329int lwm2m_set_res_data_len(const struct lwm2m_obj_path *path, uint16_t data_len);
1330
1350int lwm2m_get_res_buf(const struct lwm2m_obj_path *path, void **buffer_ptr, uint16_t *buffer_len,
1351 uint16_t *data_len, uint8_t *data_flags);
1352
1365
1376
1388
1401
1413int lwm2m_engine_stop(struct lwm2m_ctx *client_ctx);
1414
1426int lwm2m_engine_start(struct lwm2m_ctx *client_ctx);
1427
1439void lwm2m_acknowledge(struct lwm2m_ctx *client_ctx);
1440
1441/*
1442 * LwM2M RD client flags, used to configure LwM2M session.
1443 */
1444
1448#define LWM2M_RD_CLIENT_FLAG_BOOTSTRAP BIT(0)
1449
1471int lwm2m_rd_client_start(struct lwm2m_ctx *client_ctx, const char *ep_name,
1473 lwm2m_observe_cb_t observe_cb);
1474
1490int lwm2m_rd_client_stop(struct lwm2m_ctx *client_ctx,
1491 lwm2m_ctx_event_cb_t event_cb, bool deregister);
1492
1503
1515
1520
1524#define LWM2M_MAX_PATH_STR_SIZE sizeof("/65535/65535/65535/65535")
1525
1534char *lwm2m_path_log_buf(char *buf, struct lwm2m_obj_path *path);
1535
1547
1552typedef void (*lwm2m_send_cb_t)(enum lwm2m_send_status status);
1553
1565int lwm2m_send_cb(struct lwm2m_ctx *ctx, const struct lwm2m_obj_path path_list[],
1566 uint8_t path_list_size, lwm2m_send_cb_t reply_cb);
1567
1575
1589int lwm2m_enable_cache(const struct lwm2m_obj_path *path, struct lwm2m_time_series_elem *data_cache,
1590 size_t cache_len);
1591
1602
1612
1624
1625#ifdef __cplusplus
1626}
1627#endif
1628
1629#endif /* ZEPHYR_INCLUDE_NET_LWM2M_H_ */
_TIME_T_ time_t
Definition _timespec.h:14
CoAP implementation for Zephyr.
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)
int lwm2m_engine_stop(struct lwm2m_ctx *client_ctx)
Stop the LwM2M engine.
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.
lwm2m_security_mode_e
Security modes as defined in LwM2M Security object.
Definition lwm2m.h:1595
int lwm2m_get_s8(const struct lwm2m_obj_path *path, int8_t *value)
Get resource (instance) value (s8)
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)
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:1542
int lwm2m_get_string(const struct lwm2m_obj_path *path, void *str, uint16_t buflen)
Get resource (instance) value (string)
int lwm2m_get_s16(const struct lwm2m_obj_path *path, int16_t *value)
Get resource (instance) value (s16)
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_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_set_s32(const struct lwm2m_obj_path *path, int32_t value)
Set resource (instance) value (s32)
int lwm2m_set_f64(const struct lwm2m_obj_path *path, const double value)
Set resource (instance) value (double)
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)
void(* lwm2m_ctx_event_cb_t)(struct lwm2m_ctx *ctx, enum lwm2m_rd_client_event event)
Asynchronous RD client event callback.
Definition lwm2m.h:182
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:405
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_set_bulk(const struct lwm2m_res_item res_list[], size_t res_list_size)
Set multiple resource (instance) values.
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_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.
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:369
void lwm2m_firmware_set_update_cb(lwm2m_engine_execute_cb_t cb)
Set data callback to handle firmware update execute events.
void lwm2m_firmware_set_write_cb(lwm2m_engine_set_data_cb_t cb)
Set data callback for firmware block transfer.
int lwm2m_enable_cache(const struct lwm2m_obj_path *path, struct lwm2m_time_series_elem *data_cache, size_t cache_len)
 
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_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)
lwm2m_socket_states
Different traffic states of the LwM2M socket.
Definition lwm2m.h:195
int lwm2m_swmgmt_set_deactivate_cb(uint16_t obj_inst_id, lwm2m_engine_execute_cb_t cb)
Set callback to handle software deactivation requests.
struct lwm2m_ctx * lwm2m_rd_client_ctx(void)
&#160;
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.
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.
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:426
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_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:111
lwm2m_rd_client_event
LwM2M RD client events.
Definition lwm2m.h:140
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_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:128
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)
void(* lwm2m_socket_fault_cb_t)(int error)
Callback function called when a socket error is encountered.
Definition lwm2m.h:97
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:444
int lwm2m_register_read_callback(const struct lwm2m_obj_path *path, lwm2m_engine_get_data_cb_t cb)
Set resource (instance) read callback.
void(* lwm2m_send_cb_t)(enum lwm2m_send_status status)
Callback returning send status.
Definition lwm2m.h:1552
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)
@ LWM2M_SECURITY_PSK
Pre-Shared Key mode.
Definition lwm2m.h:1596
@ LWM2M_SECURITY_RAW_PK
Raw Public Key mode.
Definition lwm2m.h:1597
@ LWM2M_SECURITY_CERT
Certificate mode.
Definition lwm2m.h:1598
@ LWM2M_SECURITY_CERT_EST
Certificate mode with EST.
Definition lwm2m.h:1600
@ LWM2M_SECURITY_NOSEC
NoSec mode.
Definition lwm2m.h:1599
@ LWM2M_SEND_STATUS_SUCCESS
Succeed.
Definition lwm2m.h:1543
@ LWM2M_SEND_STATUS_FAILURE
Failure.
Definition lwm2m.h:1544
@ LWM2M_SEND_STATUS_TIMEOUT
Timeout.
Definition lwm2m.h:1545
@ LWM2M_SOCKET_STATE_NO_DATA
No more data is expected.
Definition lwm2m.h:199
@ LWM2M_SOCKET_STATE_ONE_RESPONSE
One response is expected for the next message.
Definition lwm2m.h:197
@ LWM2M_SOCKET_STATE_ONGOING
Ongoing traffic is expected.
Definition lwm2m.h:196
@ LWM2M_SOCKET_STATE_LAST
Next message is the last one.
Definition lwm2m.h:198
@ LWM2M_OBSERVE_EVENT_OBSERVER_ADDED
Observer added.
Definition lwm2m.h:112
@ LWM2M_OBSERVE_EVENT_NOTIFY_TIMEOUT
Notification timed out.
Definition lwm2m.h:115
@ LWM2M_OBSERVE_EVENT_NOTIFY_ACK
Notification ACKed.
Definition lwm2m.h:114
@ LWM2M_OBSERVE_EVENT_OBSERVER_REMOVED
Observer removed.
Definition lwm2m.h:113
@ LWM2M_RD_CLIENT_EVENT_DEREGISTER_FAILURE
De-registration failure.
Definition lwm2m.h:158
@ LWM2M_RD_CLIENT_EVENT_QUEUE_MODE_RX_OFF
Queue mode RX off.
Definition lwm2m.h:162
@ LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_TRANSFER_COMPLETE
Bootstrap transfer complete.
Definition lwm2m.h:148
@ LWM2M_RD_CLIENT_EVENT_SERVER_DISABLED
Server disabled.
Definition lwm2m.h:172
@ LWM2M_RD_CLIENT_EVENT_REGISTRATION_COMPLETE
Registration complete.
Definition lwm2m.h:152
@ LWM2M_RD_CLIENT_EVENT_REG_TIMEOUT
Registration timeout.
Definition lwm2m.h:154
@ LWM2M_RD_CLIENT_EVENT_REG_UPDATE_COMPLETE
Registration update complete.
Definition lwm2m.h:156
@ LWM2M_RD_CLIENT_EVENT_DEREGISTER
De-register.
Definition lwm2m.h:170
@ LWM2M_RD_CLIENT_EVENT_REG_UPDATE
Registration update.
Definition lwm2m.h:168
@ LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_FAILURE
Bootstrap registration failure.
Definition lwm2m.h:144
@ LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_COMPLETE
Bootstrap registration complete.
Definition lwm2m.h:146
@ LWM2M_RD_CLIENT_EVENT_DISCONNECT
Disconnected.
Definition lwm2m.h:160
@ LWM2M_RD_CLIENT_EVENT_NONE
Invalid event.
Definition lwm2m.h:142
@ LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE
Registration failure.
Definition lwm2m.h:150
@ LWM2M_RD_CLIENT_EVENT_ENGINE_SUSPENDED
Engine suspended.
Definition lwm2m.h:164
@ LWM2M_RD_CLIENT_EVENT_NETWORK_ERROR
Network error.
Definition lwm2m.h:166
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:376
Represents the handler for the reply of a request, it is also used when observing resources.
Definition coap.h:391
Mutex Structure.
Definition kernel.h:2994
LwM2M context structure to maintain information for a single LwM2M connection.
Definition lwm2m.h:206
lwm2m_socket_fault_cb_t fault_cb
Socket fault callback.
Definition lwm2m.h:301
char * desthostname
Destination hostname.
Definition lwm2m.h:246
lwm2m_observe_cb_t observe_cb
Callback for new or cancelled observations, and acknowledged or timed out notifications.
Definition lwm2m.h:306
struct sockaddr remote_addr
Destination address storage.
Definition lwm2m.h:208
uint8_t validate_buf[CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE]
Validation buffer.
Definition lwm2m.h:315
int(* load_credentials)(struct lwm2m_ctx *client_ctx)
Custom load_credentials function.
Definition lwm2m.h:254
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:240
int(* set_socketoptions)(struct lwm2m_ctx *client_ctx)
Custom socket options.
Definition lwm2m.h:262
int srv_obj_inst
Current index of Server Object used in this context.
Definition lwm2m.h:288
void * processed_req
A pointer to currently processed request, for internal LwM2M engine use.
Definition lwm2m.h:228
bool bootstrap_mode
Flag to enable BOOTSTRAP interface.
Definition lwm2m.h:293
lwm2m_ctx_event_cb_t event_cb
Callback for client events.
Definition lwm2m.h:309
int sec_obj_inst
Current index of Security Object used for server credentials.
Definition lwm2m.h:285
bool buffer_client_messages
Flag to indicate that the client is buffering Notifications and Send messages.
Definition lwm2m.h:282
void(* set_socket_state)(int fd, enum lwm2m_socket_states state)
Callback to indicate transmission states.
Definition lwm2m.h:323
bool use_dtls
Flag to indicate if context should use DTLS.
Definition lwm2m.h:269
int sock_fd
Socket File Descriptor.
Definition lwm2m.h:296
uint16_t desthostnamelen
Destination hostname length.
Definition lwm2m.h:248
bool connection_suspended
Flag to indicate that the socket connection is suspended.
Definition lwm2m.h:275
LwM2M object path structure.
Definition lwm2m.h:100
uint16_t obj_inst_id
Object instance ID.
Definition lwm2m.h:102
uint16_t res_inst_id
Resource instance ID.
Definition lwm2m.h:104
uint8_t level
Path level (0-4).
Definition lwm2m.h:105
uint16_t res_id
Resource ID.
Definition lwm2m.h:103
uint16_t obj_id
Object ID.
Definition lwm2m.h:101
LWM2M Objlnk resource type structure.
Definition lwm2m.h:787
uint16_t obj_id
Object ID.
Definition lwm2m.h:788
uint16_t obj_inst
Object instance ID.
Definition lwm2m.h:789
LwM2M resource item structure.
Definition lwm2m.h:1019
uint16_t size
Size of the value.
Definition lwm2m.h:1025
void * value
Pointer to resource value.
Definition lwm2m.h:1023
struct lwm2m_obj_path * path
Pointer to LwM2M path as a struct.
Definition lwm2m.h:1021
LwM2M Time series data structure.
Definition lwm2m.h:329
time_t t
Cached data Unix timestamp.
Definition lwm2m.h:331
Generic sockaddr struct.
Definition net_ip.h:388