Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
lwm2m.h File Reference
#include <kernel.h>
#include <sys/mutex.h>
#include <net/coap.h>
#include <net/lwm2m_path.h>

Go to the source code of this file.

Data Structures

struct  lwm2m_ctx
 LwM2M context structure to maintain information for a single LwM2M connection. More...
 
struct  float32_value
 32-bit variant of the LwM2M float structure More...
 
struct  lwm2m_objlnk
 LWM2M ObjLnk resource type structure. More...
 

Macros

#define LWM2M_OBJECT_SECURITY_ID   0
 LwM2M Objects managed by OMA for LwM2M tech specification. Objects in this range have IDs from 0 to 1023. For more information refer to Technical Specification OMA-TS-LightweightM2M-V1_0_2-20180209-A. More...
 
#define LWM2M_OBJECT_SERVER_ID   1
 
#define LWM2M_OBJECT_ACCESS_CONTROL_ID   2
 
#define LWM2M_OBJECT_DEVICE_ID   3
 
#define LWM2M_OBJECT_CONNECTIVITY_MONITORING_ID   4
 
#define LWM2M_OBJECT_FIRMWARE_ID   5
 
#define LWM2M_OBJECT_LOCATION_ID   6
 
#define LWM2M_OBJECT_CONNECTIVITY_STATISTICS_ID   7
 
#define IPSO_OBJECT_GENERIC_SENSOR_ID   3300
 LwM2M Objects produced by 3rd party Standards Development Organizations. Objects in this range have IDs from 2048 to 10240 Refer to the OMA LightweightM2M (LwM2M) Object and Resource Registry: http://www.openmobilealliance.org/wp/OMNA/LwM2M/LwM2MRegistry.html. More...
 
#define IPSO_OBJECT_TEMP_SENSOR_ID   3303
 
#define IPSO_OBJECT_HUMIDITY_SENSOR_ID   3304
 
#define IPSO_OBJECT_LIGHT_CONTROL_ID   3311
 
#define IPSO_OBJECT_ACCELEROMETER_ID   3313
 
#define IPSO_OBJECT_PRESSURE_ID   3323
 
#define IPSO_OBJECT_BUZZER_ID   3338
 
#define IPSO_OBJECT_TIMER_ID   3340
 
#define IPSO_OBJECT_ONOFF_SWITCH_ID   3342
 
#define IPSO_OBJECT_PUSH_BUTTON_ID   3347
 
#define LWM2M_DEVICE_PWR_SRC_TYPE_DC_POWER   0
 Power source types used for the "Available Power Sources" resource of the LwM2M Device object. More...
 
#define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_INT   1
 
#define LWM2M_DEVICE_PWR_SRC_TYPE_BAT_EXT   2
 
#define LWM2M_DEVICE_PWR_SRC_TYPE_UNUSED   3
 
#define LWM2M_DEVICE_PWR_SRC_TYPE_PWR_OVER_ETH   4
 
#define LWM2M_DEVICE_PWR_SRC_TYPE_USB   5
 
#define LWM2M_DEVICE_PWR_SRC_TYPE_AC_POWER   6
 
#define LWM2M_DEVICE_PWR_SRC_TYPE_SOLAR   7
 
#define LWM2M_DEVICE_PWR_SRC_TYPE_MAX   8
 
#define LWM2M_DEVICE_ERROR_NONE   0
 Error codes used for the "Error Code" resource of the LwM2M Device object. An LwM2M client can register one of the following error codes via the lwm2m_device_add_err() function. More...
 
#define LWM2M_DEVICE_ERROR_LOW_POWER   1
 
#define LWM2M_DEVICE_ERROR_EXT_POWER_SUPPLY_OFF   2
 
#define LWM2M_DEVICE_ERROR_GPS_FAILURE   3
 
#define LWM2M_DEVICE_ERROR_LOW_SIGNAL_STRENGTH   4
 
#define LWM2M_DEVICE_ERROR_OUT_OF_MEMORY   5
 
#define LWM2M_DEVICE_ERROR_SMS_FAILURE   6
 
#define LWM2M_DEVICE_ERROR_NETWORK_FAILURE   7
 
#define LWM2M_DEVICE_ERROR_PERIPHERAL_FAILURE   8
 
#define LWM2M_DEVICE_BATTERY_STATUS_NORMAL   0
 Battery status codes used for the "Battery Status" resource (3/0/20) of the LwM2M Device object. As the battery status changes, an LwM2M client can set one of the following codes via: lwm2m_engine_set_u8("3/0/20", [battery status]) More...
 
#define LWM2M_DEVICE_BATTERY_STATUS_CHARGING   1
 
#define LWM2M_DEVICE_BATTERY_STATUS_CHARGE_COMP   2
 
#define LWM2M_DEVICE_BATTERY_STATUS_DAMAGED   3
 
#define LWM2M_DEVICE_BATTERY_STATUS_LOW   4
 
#define LWM2M_DEVICE_BATTERY_STATUS_NOT_INST   5
 
#define LWM2M_DEVICE_BATTERY_STATUS_UNKNOWN   6
 
#define STATE_IDLE   0
 LWM2M Firmware Update object states. More...
 
#define STATE_DOWNLOADING   1
 
#define STATE_DOWNLOADED   2
 
#define STATE_UPDATING   3
 
#define RESULT_DEFAULT   0
 LWM2M Firmware Update object result codes. More...
 
#define RESULT_SUCCESS   1
 
#define RESULT_NO_STORAGE   2
 
#define RESULT_OUT_OF_MEM   3
 
#define RESULT_CONNECTION_LOST   4
 
#define RESULT_INTEGRITY_FAILED   5
 
#define RESULT_UNSUP_FW   6
 
#define RESULT_INVALID_URI   7
 
#define RESULT_UPDATE_FAILED   8
 
#define RESULT_UNSUP_PROTO   9
 
#define LWM2M_FLOAT32_DEC_MAX   1000000
 Data structure used to represent the LwM2M float type: val1 is the whole number portion of the decimal val2 is the decimal portion *1000000 for 32bit, *1000000000 for 64bit Example: 123.456 == val1: 123, val2:456000 Example: 123.000456 = val1: 123, val2:456. More...
 
#define LWM2M_OBJLNK_MAX_ID   USHRT_MAX
 Maximum value for ObjLnk resource fields. More...
 
#define LWM2M_RES_DATA_READ_ONLY   0
 Resource read-only value bit. More...
 
#define LWM2M_RES_DATA_FLAG_RO   BIT(LWM2M_RES_DATA_READ_ONLY)
 Resource read-only flag. More...
 
#define LWM2M_HAS_RES_FLAG(res, f)   ((res->data_flags & f) == f)
 Read resource flags helper macro. More...
 
#define LWM2M_RD_CLIENT_FLAG_BOOTSTRAP   BIT(0)
 Run bootstrap procedure in current session. More...
 

Typedefs

typedef void(* lwm2m_socket_fault_cb_t) (int error)
 
typedef void(* lwm2m_notify_timeout_cb_t) (void)
 
typedef 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. More...
 
typedef 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. More...
 
typedef int(* lwm2m_engine_user_cb_t) (uint16_t obj_inst_id)
 Asynchronous event notification callback. More...
 
typedef int(* lwm2m_engine_execute_cb_t) (uint16_t obj_inst_id, uint8_t *args, uint16_t args_len)
 Asynchronous execute notification callback. More...
 
typedef struct float32_value float32_value_t
 32-bit variant of the LwM2M float structure More...
 
typedef void(* lwm2m_ctx_event_cb_t) (struct lwm2m_ctx *ctx, enum lwm2m_rd_client_event event)
 Asynchronous RD client event callback. More...
 

Enumerations

enum  lwm2m_rd_client_event {
  LWM2M_RD_CLIENT_EVENT_NONE , LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_FAILURE , LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_REG_COMPLETE , LWM2M_RD_CLIENT_EVENT_BOOTSTRAP_TRANSFER_COMPLETE ,
  LWM2M_RD_CLIENT_EVENT_REGISTRATION_FAILURE , LWM2M_RD_CLIENT_EVENT_REGISTRATION_COMPLETE , LWM2M_RD_CLIENT_EVENT_REG_UPDATE_FAILURE , LWM2M_RD_CLIENT_EVENT_REG_UPDATE_COMPLETE ,
  LWM2M_RD_CLIENT_EVENT_DEREGISTER_FAILURE , LWM2M_RD_CLIENT_EVENT_DISCONNECT , LWM2M_RD_CLIENT_EVENT_QUEUE_MODE_RX_OFF , LWM2M_RD_CLIENT_EVENT_NETWORK_ERROR
}
 LwM2M RD client events. More...
 

Functions

int lwm2m_device_add_err (uint8_t error_code)
 Register a new error code with LwM2M Device object. More...
 
int lwm2m_engine_update_observer_min_period (char *pathstr, uint32_t period_s)
 Change an observer's pmin value. More...
 
int lwm2m_engine_update_observer_max_period (char *pathstr, uint32_t period_s)
 Change an observer's pmax value. More...
 
int lwm2m_engine_create_obj_inst (char *pathstr)
 Create an LwM2M object instance. More...
 
int lwm2m_engine_delete_obj_inst (char *pathstr)
 Delete an LwM2M object instance. More...
 
int lwm2m_engine_set_opaque (char *pathstr, char *data_ptr, uint16_t data_len)
 Set resource (instance) value (opaque buffer) More...
 
int lwm2m_engine_set_string (char *pathstr, char *data_ptr)
 Set resource (instance) value (string) More...
 
int lwm2m_engine_set_u8 (char *pathstr, uint8_t value)
 Set resource (instance) value (u8) More...
 
int lwm2m_engine_set_u16 (char *pathstr, uint16_t value)
 Set resource (instance) value (u16) More...
 
int lwm2m_engine_set_u32 (char *pathstr, uint32_t value)
 Set resource (instance) value (u32) More...
 
int lwm2m_engine_set_u64 (char *pathstr, uint64_t value)
 Set resource (instance) value (u64) More...
 
int lwm2m_engine_set_s8 (char *pathstr, int8_t value)
 Set resource (instance) value (s8) More...
 
int lwm2m_engine_set_s16 (char *pathstr, int16_t value)
 Set resource (instance) value (s16) More...
 
int lwm2m_engine_set_s32 (char *pathstr, int32_t value)
 Set resource (instance) value (s32) More...
 
int lwm2m_engine_set_s64 (char *pathstr, int64_t value)
 Set resource (instance) value (s64) More...
 
int lwm2m_engine_set_bool (char *pathstr, bool value)
 Set resource (instance) value (bool) More...
 
int lwm2m_engine_set_float32 (char *pathstr, float32_value_t *value)
 Set resource (instance) value (32-bit float structure) More...
 
int lwm2m_engine_set_objlnk (char *pathstr, struct lwm2m_objlnk *value)
 Set resource (instance) value (ObjLnk) More...
 
int lwm2m_engine_get_opaque (char *pathstr, void *buf, uint16_t buflen)
 Get resource (instance) value (opaque buffer) More...
 
int lwm2m_engine_get_string (char *pathstr, void *str, uint16_t strlen)
 Get resource (instance) value (string) More...
 
int lwm2m_engine_get_u8 (char *pathstr, uint8_t *value)
 Get resource (instance) value (u8) More...
 
int lwm2m_engine_get_u16 (char *pathstr, uint16_t *value)
 Get resource (instance) value (u16) More...
 
int lwm2m_engine_get_u32 (char *pathstr, uint32_t *value)
 Get resource (instance) value (u32) More...
 
int lwm2m_engine_get_u64 (char *pathstr, uint64_t *value)
 Get resource (instance) value (u64) More...
 
int lwm2m_engine_get_s8 (char *pathstr, int8_t *value)
 Get resource (instance) value (s8) More...
 
int lwm2m_engine_get_s16 (char *pathstr, int16_t *value)
 Get resource (instance) value (s16) More...
 
int lwm2m_engine_get_s32 (char *pathstr, int32_t *value)
 Get resource (instance) value (s32) More...
 
int lwm2m_engine_get_s64 (char *pathstr, int64_t *value)
 Get resource (instance) value (s64) More...
 
int lwm2m_engine_get_bool (char *pathstr, bool *value)
 Get resource (instance) value (bool) More...
 
int lwm2m_engine_get_float32 (char *pathstr, float32_value_t *buf)
 Get resource (instance) value (32-bit float structure) More...
 
int lwm2m_engine_get_objlnk (char *pathstr, struct lwm2m_objlnk *buf)
 Get resource (instance) value (ObjLnk) More...
 
int lwm2m_engine_register_read_callback (char *pathstr, lwm2m_engine_get_data_cb_t cb)
 Set resource (instance) read callback. More...
 
int lwm2m_engine_register_pre_write_callback (char *pathstr, lwm2m_engine_get_data_cb_t cb)
 Set resource (instance) pre-write callback. More...
 
int lwm2m_engine_register_validate_callback (char *pathstr, lwm2m_engine_set_data_cb_t cb)
 Set resource (instance) validation callback. More...
 
int lwm2m_engine_register_post_write_callback (char *pathstr, lwm2m_engine_set_data_cb_t cb)
 Set resource (instance) post-write callback. More...
 
int lwm2m_engine_register_exec_callback (char *pathstr, lwm2m_engine_execute_cb_t cb)
 Set resource execute event callback. More...
 
int lwm2m_engine_register_create_callback (uint16_t obj_id, lwm2m_engine_user_cb_t cb)
 Set object instance create event callback. More...
 
int lwm2m_engine_register_delete_callback (uint16_t obj_id, lwm2m_engine_user_cb_t cb)
 Set object instance delete event callback. More...
 
int lwm2m_engine_set_res_data (char *pathstr, void *data_ptr, uint16_t data_len, uint8_t data_flags)
 Set data buffer for a resource. More...
 
int lwm2m_engine_get_res_data (char *pathstr, void **data_ptr, uint16_t *data_len, uint8_t *data_flags)
 Get data buffer for a resource. More...
 
int lwm2m_engine_create_res_inst (char *pathstr)
 Create a resource instance. More...
 
int lwm2m_engine_delete_res_inst (char *pathstr)
 Delete a resource instance. More...
 
int lwm2m_engine_update_service_period (k_work_handler_t service, uint32_t period_ms)
 Update the period of a given service. More...
 
int lwm2m_engine_start (struct lwm2m_ctx *client_ctx)
 Start the LwM2M engine. More...
 
void lwm2m_acknowledge (struct lwm2m_ctx *client_ctx)
 Acknowledge the currently processed request with an empty ACK. More...
 
void lwm2m_rd_client_start (struct lwm2m_ctx *client_ctx, const char *ep_name, uint32_t flags, lwm2m_ctx_event_cb_t event_cb)
 Start the LwM2M RD (Registration / Discovery) Client. More...
 
void lwm2m_rd_client_stop (struct lwm2m_ctx *client_ctx, lwm2m_ctx_event_cb_t event_cb)
 Stop the LwM2M RD (De-register) Client. More...
 
void lwm2m_rd_client_update (void)
 Trigger a Registration Update of the LwM2M RD Client. More...