nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
lwm2m_client_utils.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
23#ifndef LWM2M_CLIENT_UTILS_H__
24#define LWM2M_CLIENT_UTILS_H__
25
26#include <zephyr/kernel.h>
27#include <zephyr/device.h>
28#include <zephyr/net/lwm2m.h>
29#include <modem/lte_lc.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35#if defined(CONFIG_LWM2M_CLIENT_UTILS_SECURITY_OBJ_SUPPORT)
44typedef int (*modem_mode_cb_t)(enum lte_lc_func_mode new_mode, void *user_data);
45
55 void *user_data;
56};
57
70int lwm2m_init_security(struct lwm2m_ctx *ctx, char *endpoint, struct modem_mode_change *mmode);
71
87int lwm2m_security_set_psk(uint16_t sec_obj_inst, const void *psk, int psk_len, bool psk_is_hex,
88 const char *psk_id);
89
106int lwm2m_security_set_certificate(uint16_t sec_obj_inst, const void *cert, int cert_len,
107 const void *private_key, int key_len, const void *ca_chain,
108 int ca_len);
116
117#endif
118
119#if defined(CONFIG_LWM2M_CLIENT_UTILS_DEVICE_OBJ_SUPPORT)
131int lwm2m_device_reboot_cb(uint16_t obj_inst_id, uint8_t *args, uint16_t args_len);
132#endif
133
147
151 uint16_t obj_inst_id;
152};
153
157 uint16_t obj_inst_id;
160};
161
165 uint16_t obj_inst_id;
168};
169
173 uint16_t obj_inst_id;
174};
175
179 uint16_t obj_inst_id;
182};
183
187 union {
198 };
199};
200
234typedef int (*lwm2m_firmware_event_cb_t)(struct lwm2m_fota_event *event);
235
239void *firmware_read_cb(uint16_t obj_inst_id, size_t *data_len);
240
249
256
257#define LWM2M_OBJECT_CELLULAR_CONNECTIVITY_ID 10
258
263
273
287 uint64_t maximum_delay_s, uint64_t poll_period_ms);
288
293
305int lwm2m_utils_conneval(struct lwm2m_ctx *client, enum lwm2m_rd_client_event *client_event);
306
316void lwm2m_utils_connection_manage(struct lwm2m_ctx *client,
317 enum lwm2m_rd_client_event *client_event);
318
333void lwm2m_utils_rai_event_cb(struct lwm2m_ctx *client,
334 enum lwm2m_rd_client_event *client_event);
335
336/* Advanced firmare object support */
337uint8_t lwm2m_adv_firmware_get_update_state(uint16_t obj_inst_id);
338void lwm2m_adv_firmware_set_update_state(uint16_t obj_inst_id, uint8_t state);
339uint8_t lwm2m_adv_firmware_get_update_result(uint16_t obj_inst_id);
340void lwm2m_adv_firmware_set_update_result(uint16_t obj_inst_id, uint8_t result);
341void lwm2m_adv_firmware_set_write_cb(uint16_t obj_inst_id, lwm2m_engine_set_data_cb_t cb);
342lwm2m_engine_set_data_cb_t lwm2m_adv_firmware_get_write_cb(uint16_t obj_inst_id);
343void lwm2m_adv_firmware_set_update_cb(uint16_t obj_inst_id, lwm2m_engine_execute_cb_t cb);
344lwm2m_engine_execute_cb_t lwm2m_adv_firmware_get_update_cb(uint16_t obj_inst_id);
345int lwm2m_adv_firmware_create_inst(const char *component,
346 lwm2m_engine_set_data_cb_t write_callback,
347 lwm2m_engine_execute_cb_t update_callback);
348
349#define LWM2M_OBJECT_ADV_FIRMWARE_ID 33629
350#define RESULT_ADV_FOTA_CANCELLED 10
351#define RESULT_ADV_FOTA_DEFERRED 11
352#define RESULT_ADV_CONFLICT_STATE 12
353#define RESULT_ADV_DEPENDENCY_ERR 13
354
355/* Reboot execute possible argument's */
356#define REBOOT_SOURCE_DEVICE_OBJ 0
357#define REBOOT_SOURCE_FOTA_OBJ 1
358
359/* Firmware resource IDs */
360#define LWM2M_FOTA_PACKAGE_ID 0
361#define LWM2M_FOTA_PACKAGE_URI_ID 1
362#define LWM2M_FOTA_UPDATE_ID 2
363#define LWM2M_FOTA_STATE_ID 3
364#define LWM2M_FOTA_UPDATE_RESULT_ID 5
365#define LWM2M_FOTA_PACKAGE_NAME_ID 6
366#define LWM2M_FOTA_PACKAGE_VERSION_ID 7
367#define LWM2M_FOTA_UPDATE_PROTO_SUPPORT_ID 8
368#define LWM2M_FOTA_UPDATE_DELIV_METHOD_ID 9
369/* LwM2M v1.2 extension which are common for advanced fota */
370#define LWM2M_FOTA_CANCEL_ID 10
371#define LWM2M_FOTA_SEVERITY_ID 11
372#define LWM2M_FOTA_LAST_STATE_CHANGE_TIME_ID 12
373#define LWM2M_FOTA_MAXIMUM_DEFERRED_PERIOD_ID 13
374/* Unique resources for advanced fota */
375#define LWM2M_ADV_FOTA_COMPONENT_NAME_ID 14
376#define LWM2M_ADV_FOTA_CURRENT_VERSION_ID 15
377#define LWM2M_ADV_FOTA_LINKED_INSTANCES_ID 16
378#define LWM2M_ADV_FOTA_CONFLICTING_INSTANCES_ID 17
379
380/********** DEPRECATED FUNCTIONS *************/
382__deprecated static inline int lwm2m_init_firmware(void) {return lwm2m_init_firmware_cb(NULL); }
384__deprecated static inline int lwm2m_init_device(void) {return 0; }
386__deprecated static inline int lwm2m_init_cellular_connectivity_object(void) {return 0; }
388__deprecated static inline int lwm2m_init_connmon(void) {return 0; }
390__deprecated static inline int lwm2m_init_location(void) {return 0; }
391
392#ifdef __cplusplus
393}
394#endif
395
396#endif /* LWM2M_CLIENT_UTILS_H__ */
397
lte_lc_func_mode
Definition: lte_lc.h:153
lte_lc_energy_estimate
Definition: lte_lc.h:574
int lwm2m_utils_enable_conneval(enum lte_lc_energy_estimate min_energy_estimate, uint64_t maximum_delay_s, uint64_t poll_period_ms)
Enable connection pre-evaluation module.
uint8_t lwm2m_adv_firmware_get_update_result(uint16_t obj_inst_id)
int lwm2m_rai_req(enum lwm2m_rai_mode mode)
Function for requesting modem to enable or disable use of AS RAI.
uint8_t lwm2m_adv_firmware_get_update_state(uint16_t obj_inst_id)
void lwm2m_adv_firmware_set_update_state(uint16_t obj_inst_id, uint8_t state)
bool lwm2m_security_needs_bootstrap(void)
Check if the client credentials are already stored.
int lwm2m_security_set_psk(uint16_t sec_obj_inst, const void *psk, int psk_len, bool psk_is_hex, const char *psk_id)
Set security object to PSK mode.
lwm2m_rai_mode
Definition: lwm2m_client_utils.h:259
@ LWM2M_RAI_MODE_DISABLED
Definition: lwm2m_client_utils.h:260
@ LWM2M_RAI_MODE_ENABLED
Definition: lwm2m_client_utils.h:261
lwm2m_engine_set_data_cb_t lwm2m_adv_firmware_get_write_cb(uint16_t obj_inst_id)
void lwm2m_utils_connection_manage(struct lwm2m_ctx *client, enum lwm2m_rd_client_event *client_event)
LwM2M utils connection event handler.
void * firmware_read_cb(uint16_t obj_inst_id, size_t *data_len)
Firmware read callback.
lwm2m_fota_event_id
Definition: lwm2m_client_utils.h:135
@ LWM2M_FOTA_UPDATE_IMAGE_REQ
Definition: lwm2m_client_utils.h:141
@ LWM2M_FOTA_UPDATE_ERROR
Definition: lwm2m_client_utils.h:145
@ LWM2M_FOTA_DOWNLOAD_FINISHED
Definition: lwm2m_client_utils.h:139
@ LWM2M_FOTA_UPDATE_MODEM_RECONNECT_REQ
Definition: lwm2m_client_utils.h:143
@ LWM2M_FOTA_DOWNLOAD_START
Definition: lwm2m_client_utils.h:137
void lwm2m_utils_rai_event_cb(struct lwm2m_ctx *client, enum lwm2m_rd_client_event *client_event)
LwM2M utils RAI event handler.
int(* lwm2m_firmware_event_cb_t)(struct lwm2m_fota_event *event)
Firmware update event callback.
Definition: lwm2m_client_utils.h:234
int lwm2m_init_firmware_cb(lwm2m_firmware_event_cb_t cb)
Initialize Firmware update utils library with callback.
int lwm2m_device_reboot_cb(uint16_t obj_inst_id, uint8_t *args, uint16_t args_len)
Reboot handler for a device object.
void lwm2m_adv_firmware_set_write_cb(uint16_t obj_inst_id, lwm2m_engine_set_data_cb_t cb)
int(* modem_mode_cb_t)(enum lte_lc_func_mode new_mode, void *user_data)
Callback to request a modem state change, being it powering off, flight mode etc.
Definition: lwm2m_client_utils.h:44
int lwm2m_security_set_certificate(uint16_t sec_obj_inst, const void *cert, int cert_len, const void *private_key, int key_len, const void *ca_chain, int ca_len)
Set security object to certificate mode.
int lwm2m_init_security(struct lwm2m_ctx *ctx, char *endpoint, struct modem_mode_change *mmode)
Initialize Security object support for nrf91.
static int lwm2m_init_location(void)
Definition: lwm2m_client_utils.h:390
void lwm2m_adv_firmware_set_update_result(uint16_t obj_inst_id, uint8_t result)
void lwm2m_adv_firmware_set_update_cb(uint16_t obj_inst_id, lwm2m_engine_execute_cb_t cb)
static int lwm2m_init_firmware(void)
Definition: lwm2m_client_utils.h:382
void lwm2m_utils_disable_conneval(void)
Disable connection pre-evaluation.
static int lwm2m_init_device(void)
Definition: lwm2m_client_utils.h:384
static int lwm2m_init_cellular_connectivity_object(void)
Definition: lwm2m_client_utils.h:386
int lwm2m_utils_conneval(struct lwm2m_ctx *client, enum lwm2m_rd_client_event *client_event)
Start connection pre-evaluation.
int lwm2m_init_image(void)
Initialize Image Update object.
int lwm2m_adv_firmware_create_inst(const char *component, lwm2m_engine_set_data_cb_t write_callback, lwm2m_engine_execute_cb_t update_callback)
static int lwm2m_init_connmon(void)
Definition: lwm2m_client_utils.h:388
lwm2m_engine_execute_cb_t lwm2m_adv_firmware_get_update_cb(uint16_t obj_inst_id)
int dfu_type
Definition: lwm2m_client_utils.h:159
uint16_t obj_inst_id
Definition: lwm2m_client_utils.h:157
Definition: lwm2m_client_utils.h:155
uint16_t obj_inst_id
Definition: lwm2m_client_utils.h:151
Definition: lwm2m_client_utils.h:149
struct lwm2m_fota_reconnect reconnect_req
Definition: lwm2m_client_utils.h:195
enum lwm2m_fota_event_id id
Definition: lwm2m_client_utils.h:186
struct lwm2m_fota_update_failure failure
Definition: lwm2m_client_utils.h:197
struct lwm2m_fota_download_finished download_ready
Definition: lwm2m_client_utils.h:191
struct lwm2m_fota_download_start download_start
Definition: lwm2m_client_utils.h:189
struct lwm2m_fota_update_request update_req
Definition: lwm2m_client_utils.h:193
Definition: lwm2m_client_utils.h:184
uint16_t obj_inst_id
Definition: lwm2m_client_utils.h:173
Definition: lwm2m_client_utils.h:171
uint16_t obj_inst_id
Definition: lwm2m_client_utils.h:179
uint8_t update_failure
Definition: lwm2m_client_utils.h:181
Definition: lwm2m_client_utils.h:177
int dfu_type
Definition: lwm2m_client_utils.h:167
uint16_t obj_inst_id
Definition: lwm2m_client_utils.h:165
Definition: lwm2m_client_utils.h:163
modem_mode_cb_t cb
Definition: lwm2m_client_utils.h:54
void * user_data
Definition: lwm2m_client_utils.h:55
Callback used for querying permission from the app to proceed when modem's state changes.
Definition: lwm2m_client_utils.h:53
enum state_type state