Standard Object Factory
Pre-built factory functions for OMA LWM2M standard objects.
This module provides convenient factory functions that create fully configured wb_lwm2m_object_def_t instances for the standard OMA LWM2M objects. Each factory function:
Supported Standard Objects
| Object | ID | Factory Function |
|---|---|---|
| Security | /0 | wb_lwm2m_create_security_object() |
| Server | /1 | wb_lwm2m_create_server_object() |
| Device | /3 | wb_lwm2m_create_device_object() |
| Connectivity Monitoring | /4 | wb_lwm2m_create_conn_mon_object() |
| Firmware Update | /5 | wb_lwm2m_create_firmware_object() |
| Location | /6 | wb_lwm2m_create_location_object() |
| Connectivity Statistics | /7 | wb_lwm2m_create_conn_stats_object() |
Usage Pattern
// Create objects
wb_lwm2m_object_def_t *dev = wb_lwm2m_create_device_object(&dev_info, NULL);
wb_lwm2m_object_def_t *srv = wb_lwm2m_create_server_object(&srv_info, 0, NULL, NULL, NULL);
// Register with client
wb_lwm2m_add_object(client, dev);
wb_lwm2m_add_object(client, srv);
// ... use client ...
// Cleanup
wb_lwm2m_destroy_std_object(dev);
wb_lwm2m_destroy_std_object(srv);
Data Structures
wb_lwm2m_conn_mon_info_t
Configuration for the Connectivity Monitoring Object (/4)
All resource values are provided by the user’s read callback. Typical values include network bearer type, signal strength, IP addresses, and link quality.
| Field | Type | Description |
|---|---|---|
read_cb |
wb_lwm2m_read_cb_t |
Read callback for all resources (mandatory) |
wb_lwm2m_conn_stats_info_t
Configuration for the Connectivity Statistics Object (/7)
Tracks network traffic statistics. The read callback provides counters, while start/stop execute callbacks control the measurement period.
| Field | Type | Description |
|---|---|---|
read_cb |
wb_lwm2m_read_cb_t |
Read callback for statistics. |
start_cb |
wb_lwm2m_execute_cb_t |
Start (res 6) execute callback. |
stop_cb |
wb_lwm2m_execute_cb_t |
Stop (res 7) execute callback. |
wb_lwm2m_device_info_t
Configuration for the LWM2M Device Object (/3)
Provides device identity and diagnostic information. Mandatory fields (manufacturer, model_number, serial_number, binding) are always included. Optional fields are included only when non-NULL.
Dynamic resources (battery level, free memory, current time, error code) are auto-populated by a built-in read callback unless overridden via the read_cb field.
| Field | Type | Description |
|---|---|---|
binding |
const char * |
Supported binding modes (mandatory, res 16) |
device_type |
const char * |
Device type (res 17) |
factory_reset_cb |
wb_lwm2m_execute_cb_t |
Factory Reset execute callback (res 5) |
firmware_version |
const char * |
Firmware version (res 3) |
hardware_version |
const char * |
Hardware version (res 18) |
manufacturer |
const char * |
Manufacturer name (mandatory, res 0) |
model_number |
const char * |
Model number (mandatory, res 1) |
read_cb |
wb_lwm2m_read_cb_t |
Custom read callback for dynamic resources. |
reboot_cb |
wb_lwm2m_execute_cb_t |
Reboot execute callback (res 4) |
reset_error_cb |
wb_lwm2m_execute_cb_t |
Reset Error Code execute callback (res 12) |
serial_number |
const char * |
Serial number (mandatory, res 2) |
software_version |
const char * |
Software version (res 19) |
timezone |
const char * |
IANA timezone, e.g. “Europe/Berlin” (res 15) |
utc_offset |
const char * |
UTC offset, e.g. “+02:00” (res 14) |
wb_lwm2m_firmware_info_t
Configuration for the Firmware Update Object (/5)
Enables OTA firmware updates via the LWM2M server. The user provides callbacks for reading state/result, writing the package URI, and executing the update.
| Field | Type | Description |
|---|---|---|
read_cb |
wb_lwm2m_read_cb_t |
Read callback for state/result/pkg info. |
update_cb |
wb_lwm2m_execute_cb_t |
Execute callback for Update (res 2) |
write_cb |
wb_lwm2m_write_cb_t |
Write callback for Package (0) and Package URI (1) |
wb_lwm2m_location_info_t
Configuration for the Location Object (/6)
Provides GPS/GNSS position data. The user’s read callback must supply at minimum latitude, longitude, and timestamp (mandatory resources).
| Field | Type | Description |
|---|---|---|
read_cb |
wb_lwm2m_read_cb_t |
Read callback for location data (mandatory) |
wb_lwm2m_security_info_t
Configuration for the LWM2M Security Object (/0)
Contains all parameters needed to create a Security Object instance. The Security Object defines the keying material and server URI used to establish the DTLS session with the LWM2M server.
| Field | Type | Description |
|---|---|---|
is_bootstrap |
bool |
true if this is a Bootstrap server |
mode |
wb_lwm2m_security_mode_t |
Security mode (PSK, Cert, NoSec, …) |
pub_key_identity |
const uint8_t * |
Public key or PSK identity (may be NULL) |
pub_key_identity_len |
size_t |
|
secret_key |
const uint8_t * |
Secret key or PSK (may be NULL) |
secret_key_len |
size_t |
|
server_pub_key |
const uint8_t * |
Server public key (may be NULL) |
server_pub_key_len |
size_t |
|
server_uri |
const char * |
LWM2M Server URI (mandatory) |
short_server_id |
uint16_t |
Short Server ID (1-65534) |
wb_lwm2m_server_info_t
Configuration for the LWM2M Server Object (/1)
Defines the server registration parameters: lifetime, binding mode, and notification behavior. The Short Server ID must match the value used in the corresponding Security Object.
| Field | Type | Description |
|---|---|---|
binding |
const char * |
Binding mode: “U”, “UQ”, “S”, “SQ”, “US”. |
default_max_period |
uint32_t |
Default Maximum Period (0 = disabled) |
default_min_period |
uint32_t |
Default Minimum Period (0 = disabled) |
disable_timeout |
uint32_t |
Disable Timeout (0 = disabled) |
lifetime |
uint32_t |
Registration Lifetime in seconds. |
notification_storing |
bool |
Store notifications while offline? |
short_server_id |
uint16_t |
Short Server ID (must match Security obj) |
Functions
wb_lwm2m_create_conn_mon_object
Create a Connectivity Monitoring Object (/4) definition.
wb_lwm2m_object_def_t * wb_lwm2m_create_conn_mon_object(const wb_lwm2m_conn_mon_info_t *info, void *user_ctx)
Parameters:
- info (
const wb_lwm2m_conn_mon_info_t *): Config with read callback - user_ctx (
void *): User context
Returns:
Heap-allocated object def, or NULL. Caller owns the memory.
Resources: Network Bearer (0), Avail Bearers (1), Signal Strength (2), Link Quality (3), IP Addresses (4), Router IPs (5), Link Utilization (6), APN (7), Cell ID (8), SMNC (9), SMCC (10)
wb_lwm2m_create_conn_stats_object
Create a Connectivity Statistics Object (/7) definition.
wb_lwm2m_object_def_t * wb_lwm2m_create_conn_stats_object(const wb_lwm2m_conn_stats_info_t *info, void *user_ctx)
Parameters:
- info (
const wb_lwm2m_conn_stats_info_t *): Config with callbacks - user_ctx (
void *): User context
Returns:
Heap-allocated object def, or NULL. Caller owns the memory.
Resources: SMS Tx Counter (0), SMS Rx Counter (1), Tx Data (2), Rx Data (3), Max Message Size (4), Average Message Size (5), Start/Reset (6), Stop (7), Collection Period (8)
wb_lwm2m_create_device_object
Create an LWM2M Device Object (/3) definition.
wb_lwm2m_object_def_t * wb_lwm2m_create_device_object(const wb_lwm2m_device_info_t *info, void *user_ctx)
Parameters:
- info (
const wb_lwm2m_device_info_t *): Device info - user_ctx (
void *): User context for callbacks
Returns:
Heap-allocated object def, or NULL on error. Caller owns the memory.
All mandatory resources (0, 1, 2, 11, 16) are always included. Optional resources are included when the corresponding field in info is non-NULL.
Dynamic resources (battery level, free memory, error code, current time) use a built-in read callback. Override with info->read_cb if needed.
wb_lwm2m_create_firmware_object
Create a Firmware Update Object (/5) definition.
wb_lwm2m_object_def_t * wb_lwm2m_create_firmware_object(const wb_lwm2m_firmware_info_t *info, void *user_ctx)
Parameters:
- info (
const wb_lwm2m_firmware_info_t *): Config with callbacks - user_ctx (
void *): User context
Returns:
Heap-allocated object def, or NULL. Caller owns the memory.
Resources: Package (0), Package URI (1), Update (2), State (3), Update Result (5), Pkg Name (6), Pkg Version (7), Protocol Support (8), Delivery Method (9)
wb_lwm2m_create_location_object
Create a Location Object (/6) definition.
wb_lwm2m_object_def_t * wb_lwm2m_create_location_object(const wb_lwm2m_location_info_t *info, void *user_ctx)
Parameters:
- info (
const wb_lwm2m_location_info_t *): Config with read callback - user_ctx (
void *): User context
Returns:
Heap-allocated object def, or NULL. Caller owns the memory.
Resources: Latitude (0, mandatory), Longitude (1, mandatory), Altitude (2), Radius (3), Velocity (4), Timestamp (5, mandatory), Speed (6)
wb_lwm2m_create_security_object
Create an LWM2M Security Object (/0) definition.
wb_lwm2m_object_def_t * wb_lwm2m_create_security_object(const wb_lwm2m_security_info_t *info, uint16_t inst_id)
Parameters:
- info (
const wb_lwm2m_security_info_t *): Security parameters - inst_id (
uint16_t): Instance ID (typically 0)
Returns:
Heap-allocated object def, or NULL on error. Caller owns the memory.
wb_lwm2m_create_server_object
Create an LWM2M Server Object (/1) definition.
wb_lwm2m_object_def_t * wb_lwm2m_create_server_object(const wb_lwm2m_server_info_t *info, uint16_t inst_id, wb_lwm2m_execute_cb_t reg_update_cb, wb_lwm2m_execute_cb_t disable_cb, void *user_ctx)
Parameters:
- info (
const wb_lwm2m_server_info_t *): Server parameters - inst_id (
uint16_t): Instance ID (typically 0) - reg_update_cb (
wb_lwm2m_execute_cb_t): Optional execute callback for Reg Update Trigger (res 8) - disable_cb (
wb_lwm2m_execute_cb_t): Optional execute callback for Disable (res 4) - user_ctx (
void *): User context for callbacks
Returns:
Heap-allocated object def, or NULL on error. Caller owns the memory.
wb_lwm2m_destroy_std_object
Free a standard object definition previously created by wb_lwm2m_create_*.
void wb_lwm2m_destroy_std_object(wb_lwm2m_object_def_t *obj)
Parameters:
- obj (
wb_lwm2m_object_def_t *): Object definition to free (may be NULL)
Safe to call with NULL (no-op). Must be called after the client is destroyed, as the client holds a reference to the object definition.
