Chapter 4 Description of LWM2M CLIENT Services

This chapter contains a description of all LWM2M Client services listed below in alphabetic order.

In the Return Values section in the following API descriptions, values in BOLD are not affected by the NX_DISABLE_ERROR_CHECKING define that is used to disable API error checking, while non-bold values are completely disabled.

nx_lwm2m_client_create

Creates a LWM2M client.

Prototype

UINT nx_lwm2m_client_create(
    NX_LWM2M_CLIENT client_ptr,
    NX_IP *ip_ptr,
    NX_PACKET_POOL *packet_pool_ptr,
    const CHAR *name_ptr,
    UINT name_length,
    const CHAR *msisdn_ptr,
    UINT msisdn_length,
    UCHAR binding_modes,
    VOID *stack_ptr,
    ULONG stack_size,
    UINT priority);

Description

This service creates a LWM2M Client instance, which runs in the context of its own ThreadX thread.

The LWM2M Client implements the following OMA LWM2M Objects: Security (0), Server (1), Access Control (2) and Device (3). The other objects implementations must be added by the application.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • ip_ptr: Pointer to previously created IP instance.
  • packet_pool_ptr: Pointer to the default packet pool for this LWM2M Client.
  • name_ptr: Pointer to LWM2M Client endpoint name.
  • name_length: Length of LWM2M Client endpoint name.
  • msisdn_ptr: Pointer to the MSISDN where the LWM2M Client can be reached for use with the SMS binding, can be NULL if SMS binding is not supported.
  • msisdn_length: Length of MSISDN number.
  • binding_modes: The binding and modes supported by the LWM2M Client, must be a combination of NX_LWM2M_BINDING_U, NX_LWM2M_BINDING_UQ, NX_LWM2M_BINDING_S and NX_LWM2M_BINDING_SQ flags.
  • stack_ptr: Pointer to LWM2M Client thread stack area.
  • stack_size: The LWM2M Client thread stack size.
  • priority: Priority of LWM2M Client.

Return Values

  • NX_SUCCESS The LWM2M Client has been successfully created.
  • NX_LWM2M_CLIENT_ERROR LWM2M Client create error.
  • NX_LWM2M_CLIENT_PORT_UNAVAILABLE Port is unavailable.
  • NX_PTR_ERROR Invalid pointer.
  • NX_SIZE_ERROR Invalid stack size.
  • NX_OPTION_ERROR Invalid priority.

Allowed From

Threads, Initialization

Example

/* Create LWM2M Client instance.  */
status = nx_lwm2m_client_create(&lwm2m_client, &ip_0, &pool_0, 
  "netxlwm2mclient", sizeof("netxlwm2mclient") - 1,           
                                NX_NULL, 0, NX_LWM2M_CLIENT_BINDING_U, 
                                stack_ptr, stack_size, priority);

/* If status is NX_SUCCESS a LWM2M Client instance was successfully created.  */

nx_lwm2m_client_delete

Deletes a LWM2M Client.

Prototype

UINT nx_lwm2m_client_delete(NX_LWM2M_CLIENT *client_ptr);

Description

This service deletes a previously created LWM2M Client instance.

All sessions currently attached the client are also deleted by this call.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.

Return Values

  • NX_SUCCESS The LWM2M Client has been successfully deleted.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Delete the LWM2M Client instance.  */
status = nx_lwm2m_client_create(&lwm2m_client);

/* If status is NX_SUCCESS a LWM2M Client instance was successfully deleted.  */

nx_lwm2m_client_device_callback_set

Sets a device object's application callback.

Prototype

UINT **nx_lwm2m_client_device_callback_set**(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_CLIENT_DEVICE_OPERATION_CALLBACK operation_callback);

Description

This service installs the application callback for implementing operations on the LWM2M Device Object resources that are not handled by the LWM2M Client.

The LWM2M Client implements the following resources: Error Code (11), Reset Error Code (12) and Supported Binding and Modes (16), operations to the other resources are redirected to the application.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • operation_callback: The operation callback for “Read”, “Discover”, “Write” and “Execute”.

Return Values

  • NX_SUCCESS The operation callback has been successfully set.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set device callback.  */
status = nx_lwm2m_client_device_callback_set(&lwm2m_client, device_operation);

/* If status is NX_SUCCESS a device callback was successfully set.  */

nx_lwm2m_client_device_error_push

Adds an error code to a device object.

Prototype

UINT **nx_lwm2m_client_device_error_push**(
    NX_LWM2M_CLIENT *client_ptr,
    UCHAR code);

Description

This service adds a new instance to the Error Code (11) resource of the Object Device.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • code: The new error code.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BUFFER_TOO_SMALL

The maximum number of stored error codes has

been reached.

NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Push device error 1 (Low battery power) to server.  */
status = nx_lwm2m_client_device_error_push(&lwm2m_client, 1);

/* If status is NX_SUCCESS a device error was successfully pushed.  */

nx_lwm2m_client_device_error_reset

Resets the error codes of Device Object.

Prototype

UINT nx_lwm2m_client_device_error_reset(NX_LWM2M_CLIENT *client_ptr);

Description

This service deletes all error code resource instances from the Device Object. This is equivalent to executing the resource Reset Error Code (12).

Parameters

  • client_ptr: Pointer to LWM2M Client control block.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Delete all device error code.  */
status = nx_lwm2m_client_device_error_reset(&lwm2m_client);

/* If status is NX_SUCCESS, reset device error successfully.  */

nx_lwm2m_client_device_resource_changed

Signals a change to a Device Object resource.

Prototype

UINT nx_lwm2m_client_device_resource_changed(
    NX_LWM2M_CLIENT *client_ptr, 
    const NX_LWM2M_RESOURCE *resource);

Description

The service is used by the application to signal to the LWM2M Client that a resource of the Object Device has changed. The LWM2M Client will send a notification if the resource is observed by a LWM2M Server.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • resource: Pointer to the structure describing the resource that has changed.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Change device resource.  */
status = nx_lwm2m_client_device_resource_changed(&lwm2m_client, &resource);

/* If status is NX_SUCCESS, a device resource was successfully changed.  */

nx_lwm2m_client_firmware_create

Create a LWM2M Client Firmware Object.

Prototype

UINT nx_lwm2m_client_firmware_create(
    NX_LWM2M_CLIENT_FIRMWARE *firmware_ptr, 
    NX_LWM2M_CLIENT *client_ptr, 
    UINT protocols,
    NX_LWM2M_CLIENT_FIRMWARE_PACKAGE_CALLBACK package_callback,
    NX_LWM2M_CLIENT_FIRMWARE_PACKAGE_URI_CALLBACK package_uri_callback,
    NX_LWM2M_CLIENT_FIRMWARE_PACKAGE_URI_CALLBACK update_callback);

Description

The service is used by the application to create firmware object.

Parameters

  • firmware_ptr: Pointer to LWM2M Client Firmware object.
  • client_ptr: Pointer to LWM2M Client control block.
  • protocols: The supported protocols.
  • package_callback: The package callback.
  • package_uri_callback: The package URI callback.
  • update_callback: The update callback.

Return Values

NX_SUCCESS Successful operation. NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Create firmware object.  */
status = nx_lwm2m_client_firmware_create(&firmware, &lwm2m_client,     
                                         NX_LWM2M_CLIENT_FIRMWARE_PROTOCOL_HTTP, 
                                         NX_NULL, firmware_packet_uri,
                                         firmware_update);

/* If status is NX_SUCCESS, firmware object was successfully created.  */

nx_lwm2m_client_firmware_package_info_set

Sets the LWM2M Client Firmware package information.

Prototype

UINT nx_lwm2m_client_firmware_package_info_set(
    NX_LWM2M_CLIENT_FIRMWARE *firmware_ptr, 
    const CHAR *name, 
    UINT name_length, 
    const CHAR *version, 
    UINT version_length);

Description

The service is used by the application to set the package information resources of the firmware update object.

Parameters

  • firmware_ptr: Pointer to LWM2M Client Firmware object.
  • name: The name of firmware package.
  • name_length: The length of name.
  • version: The version of firmware package.
  • version_length: The length of version.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the package information resources of the firmware object.  */
status = nx_lwm2m_client_firmware_package_info_set(&firmware, 2m_client,     
                                    “LWM2M Firmware”, sizeof(“LWM2M Firmware”) -1,
                                    “1.0.0.0”, sizeof(“1.0.0.0”) - 1);

/* If status is NX_SUCCESS, package information resources was successfully set. */

nx_lwm2m_client_firmware_result_set

Sets the update result resource of the firmware update object.

Prototype

UINT nx_lwm2m_client_firmware_result_set(
    NX_LWM2M_CLIENT_FIRMWARE *firmware_ptr, 
    UCHAR result);

Description

The service is used by the application to set the update result resource of the firmware update object.

Parameters

  • firmware_ptr: Pointer to LWM2M Client Firmware object.
  • result: The update result.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the update result resource of the firmware object.  */
status = nx_lwm2m_client_firmware_result_set(&firmware, 
                                         NX_LWM2M_CLIENT_FIRMWARE_RESULT_SUCCESS);

/* If status is NX_SUCCESS, the update result resource was successfully set.  */

nx_lwm2m_client_firmware_state_set

Sets the update result resource of the firmware update object.

Prototype

UINT nx_lwm2m_client_firmware_state_set(
    NX_LWM2M_CLIENT_FIRMWARE *firmware_ptr, 
    UCHAR result);

Description

The service is used by the application to set the state of the firmware update object.

Parameters

  • firmware_ptr: Pointer to LWM2M Client Firmware object.
  • state: The state of the firmware object.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the state of the firmware object.  */
status = nx_lwm2m_client_firmware_state_set(&firmware, 
                                         NX_LWM2M_CLIENT_FIRMWARE_STATE_IDLE);

/* If status is NX_SUCCESS, the state was successfully set.  */

nx_lwm2m_client_lock

Locks the LWM2M Client.

Prototype

UINT **nx_lwm2m_client_lock**(NX_LWM2M_CLIENT *client_ptr);

Description

This service locks the LWM2M Client to prevent concurrent access to the LWM2M objects from the servers or another application thread.

If the LWM2M Client is currently locked by another thread, the function will block until the LWM2M Client is unlocked.

Calls to nx_lwm2m_client_lock/nx_lwm2m_client_unlock pairs can be nested.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Lock the LWM2M client.  */
status = nx_lwm2m_client_lock(&lwm2m_client);

/* If status is NX_SUCCESS, lwm2m client was successfully locked.  */

nx_lwm2m_client_object_add

Adds an Object implementation to the LWM2M Client.

Prototype

UINT **nx_lwm2m_client_object_add**(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_CLIENT_OBJECT *object_ptr,
    NX_LWM2M_ID object_id,
    NX_LWM2M_CLIENT_OBJECT_OPERATION_CALLBACK object_operation);

Description

This service adds a new Object implementation to the LWM2M Client.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_ptr: Pointer to the structure defining the Object implementation.
  • object_id: The object id.
  • object_operation: The object operation callback function.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_ALREADY_EXIST The Object ID already exists.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Add new object to the lwm2m client.  */
status = nx_lwm2m_client_object_add(&lwm2m_client, &object, 
                                    3303, object_operation);

/* If status is NX_SUCCESS, the new object was successfully added.  */

nx_lwm2m_client_object_create

Creates a new Object Instance.

Prototype

UINT nx_lwm2m_client_object_create(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_ID object_id,
    NX_LWM2M_ID *instance_id_ptr,
    UINT num_values,
    const NX_LWM2M_RESOURCE *values_ptr);

Description

This service performs a ‘Create’ operation on an Object of the LWM2M Client to create a new Object Instance.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_id: The Object ID.
  • instance_id_ptr: Pointer to the ID of the new instance, can be NULL if the LWM2M Client must assign an Instance ID. If the ID is the reserved value 65535 the LWM2M Client will assign an Instance ID. If not NULL the assigned ID is returned after the call.
  • num_values: The number of values to set.
  • values_ptr: Pointer to an array of resource values to initialize the new Object Instance.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_ALREADY_EXIST The Object Instance ID already exists.
  • NX_LWM2M_CLIENT_METHOD_NOT_ALLOWED The Object doesn’t support instance creation.
  • NX_LWM2M_CLIENT_NO_MEMORY Cannot allocate memory to store the new instance.
  • NX_LWM2M_CLIENT_NOT_FOUND The Object ID doesn’t exist.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Create new object instance.  */
status = nx_lwm2m_client_object_create(&lwm2m_client, 3303, 0, 2, &resource);

/* If status is NX_SUCCESS, a new object instance was successfully created.  */

nx_lwm2m_client_object_delete

Deletes an Object Instance.

Prototype

UINT nx_lwm2m_client_object_delete(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_ID object_id,
    NX_LWM2M_ID instance_id);

Description

This service performs a ‘Delete’ operation on an Object Instance of the LWM2M Client.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_id: The Object ID.
  • instance_id: The Object Instance ID.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_METHOD_NOT_ALLOWED The Object doesn’t support instance deletion.
  • NX_LWM2M_CLIENT_NOT_FOUND The Object ID or Object Instance ID doesn’t exist.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Delete an object instance.  */
status = nx_lwm2m_client_object_delete(&lwm2m_client, 3303, 0);

/* If status is NX_SUCCESS, an object instance was successfully deleted.  */

nx_lwm2m_client_object_discover

Discovers resources of an Object Instance.

Prototype

UINT nx_lwm2m_client_object_discover(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_ID object_id,
    NX_LWM2M_ID instance_id,
    UINT *num_resources,
    NX_LWM2M_CLIENT_RESOURCE *resources);

Description

This service performs a ‘Discover’ operation on an Object Instance of the LWM2M Client, this returns the list of resources implemented by the Object.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_id: The Object ID.
  • instance_id: The Object Instance ID.
  • num_resources: On input the size of the destination buffer, on output the number of elements written to the buffer.
  • resources: Pointer to the destination buffer.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BUFFER_TOO_SMALL The resources buffer is too small to store the list of resources.
  • NX_LWM2M_CLIENT_NOT_FOUND The Object ID or Object Instance ID doesn’t exist.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

NX_LWM2M_CLIENT_RESOURCE resources[10]
UINT num_resources = 10;

/* Discover object resources.  */
status = nx_lwm2m_client_object_discover(&lwm2m_client, 3303, 0, 
                                         &num_resources, resource);

/* If status is NX_SUCCESS, discover object resources successfully.  */

nx_lwm2m_client_object_execute

Performs an 'Execute' operation on a resource of an Object Instance.

Prototype

UINT **nx_lwm2m_client_object_execute**(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_ID object_id,
    NX_LWM2M_ID instance_id,
    NX_LWM2M_ID resource_id,
    const CHAR *arguments_ptr,
    UINT arguments_length);

Description

This service performs the ‘Execute’ operation on an Object Instance Resource of the LWM2M Client.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_id: The Object ID.
  • instance_id: The Object Instance ID.
  • resource_id: The Resource ID.
  • arguments_ptr: Pointer to the arguments of the execute operation. Can be NULL if arguments_length is zero.
  • arguments_length: The length of the arguments.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BUFFER_TOO_SMALL The resources buffer is too small to store the list of resources.
  • NX_LWM2M_CLIENT_NOT_FOUND The Object ID or Object Instance ID doesn’t exist.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Execute object resource.  */
status = nx_lwm2m_client_object_execute (&lwm2m_client, 3303, 0, 0,  
                                         “5”, 1);

/* If status is NX_SUCCESS, an object resource was successfully executed.  */

nx_lwm2m_client_object_instance_add

Adds an Object instance implementation to an object.

Prototype

UINT nx_lwm2m_client_object_instance_add(
    NX_LWM2M_CLIENT_OBJECT *object_ptr,
    NX_LWM2M_CLIENT_OBJECT_INSTANCE *instance_ptr,
    NX_LWM2M_ID *instance_id_ptr);

Description

This service adds a new Object instance implementation to the LWM2M Client. If the value of instance_id_ptr is NX_LWM2M_CLIENT_RESERVED_ID, LWM2M Client will automatically assign an unused instance id, otherwise, LWM2M Client will use the value application set. Once new instance was added successfully, the instance_id will be filled in instance_id_ptr to return to application.

Parameters

  • object_ptr: Pointer to the structure defining the Object implementation.
  • instance_ptr: Pointer to the structure defining the Object instance implementation.
  • instance_id_ptr: Pointer to the object instance id.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_CLIENT_LWM2M_ALREADY_EXIST The Object ID already exists.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Add new object instance to the object.  */
status = nx_lwm2m_client_object_instance_add(&object, &object_instance,
                                             &instance_id);

/* If status is NX_SUCCESS, the new object instance was successfully added.  */

nx_lwm2m_client_object_instance_next_get

Gets the next instance of an Object.

Prototype

UINT nx_lwm2m_client_object_instance_next_get(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_ID object_id,
    NX_LWM2M_ID *instance_id_ptr);

Description

This service returns the ID of the next Object Instance of the given Object. If the current Instance ID is set to NX_LWM2M_RESERVED_ID (65535) the ID of the first instance is returned.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_id: The Object ID.
  • instance_id_ptr: Pointer to the current Object Instance ID. On return contains the next Instance ID of the Object.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_CLIENT_LWM2M_NOT_FOUND The given Instance ID is the last of the object, or the Object ID is not implemented.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the next instance of an object.  */
status = nx_lwm2m_client_object_instance_next_get(&lwm2m_client, 3303, 
                                                  &instance_id);

/* If status is NX_SUCCESS, get the next instance successfully.  */

nx_lwm2m_client_object_instance_remove

Removes an Object instance implementation from an object.

Prototype

UINT nx_lwm2m_client_object_instance_remove(
    NX_LWM2M_CLIENT_OBJECT *object_ptr,
    NX_LWM2M_CLIENT_OBJECT_INSTANCE *instance_ptr);

Description

This service removes an Object instance from an object.

Parameters

  • object_ptr*: Pointer to the structure defining the Object implementation.
  • instance_ptr: Pointer to the structure defining the Object instance implementation.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_ALREADY_EXIST The Object ID already exists.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Remove object instance from an object.  */
status = nx_lwm2m_client_object_instance_remove(&object, &object_instance);

/* If status is NX_SUCCESS, the object instance was successfully removed.  */

nx_lwm2m_client_object_next_get

Gets the next object of the LWM2M Client.

Prototype

UINT nx_lwm2m_client_object_next_get(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_ID \*object_id_ptr);

Description

This service returns the ID of the next Object implemented by the LWM2M Client. If the current Object ID is set to NX_LWM2M_RESERVED_ID (65535) the first Object ID is returned.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_id_ptr: Pointer to the current Object ID. On return contains the next Object ID implemented by the LWM2M Client.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_NOT_FOUND The given Object ID is the last of the database. NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the next object of lwm2m client.  */
status = nx_lwm2m_client_object_next_get(&lwm2m_client, &object_id);

/* If status is NX_SUCCESS, get the next object successfully.  */

nx_lwm2m_client_object_read

Reads an Object Instance's resource's values.

Prototype

UINT nx_lwm2m_client_object_read(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_ID object_id,
    NX_LWM2M_ID instance_id,
    UINT num_values,
    NX_LWM2M_RESOURCE *values);

Description

This service performs a ‘Read’ operation on an Object Instance of the LWM2M Client.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_id: The Object ID.
  • instance_id: The Object Instance ID.
  • num_values: The number of resources to read.
  • values_ptr: Pointer to an array of NX_LWM2M_RESOURCE containing the IDs of the resources to read. On return the array is filled with the corresponding types and values.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_METHOD_NOT_ALLOWED A resource doesn’t support the read operation.
  • NX_LWM2M_CLIENT_NOT_FOUND The Object ID, Object Instance ID or a resource ID doesn’t exist.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Read the object resources.  */
status = nx_lwm2m_client_object_read(&lwm2m_client, 3303, 0, 2, &resource);

/* If status is NX_SUCCESS, the resources were successfully read.  */

nx_lwm2m_client_object_remove

Removes an Object instance implementation from an object.

Prototype

UINT nx_lwm2m_client_object_remove(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_CLIENT_OBJECT *object_ptr);

Description

This service removes an Object from the LWM2M Client.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_ptr: Pointer to the structure defining the Object implementation.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_ALREADY_EXIST The Object ID already exists.
  • NX_PTR_ERROR Invalid pointer.
  • NX_LWM2M_CLIENT_FORBIDDEN Removing internal object is forbidden.

Allowed From

Threads, Initialization

Example

/* Remove object from lwm2m client.  */
status = nx_lwm2m_client_object_remove(&lwm2m_client, &object);

/* If status is NX_SUCCESS, the object was successfully removed.  */

nx_lwm2m_client_object_resource_changed

Signals a change of an Object resource.

Prototype

UINT nx_lwm2m_client_object_resource_changed(
    NX_LWM2M_CLIENT_OBJECT *object_ptr,
    NX_LWM2M_CLIENT_OBJECT_INSTANCE *instance_ptr,
    const NX_LWM2M_RESOURCE *resource);

Description

The service is used by the application to signal to the LWM2M Client that a resource of the Object has changed. The LWM2M Client will send a notification if the resource is observed by a LWM2M Server.

Parameters

  • object_ptr: Pointer to the structure defining the Object implementation.
  • instance_ptr*: Pointer to the structure defining the Object instance implementation.
  • resource: Pointer to the structure describing the resource that has changed.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Change object resource.  */
status = nx_lwm2m_client_object_resource_changed(&object, &instance, &resource);

/* If status is NX_SUCCESS, a resource was successfully changed.  */

nx_lwm2m_client_object_write

Changes resource's values of an Object instance.

Prototype

UINT nx_lwm2m_client_object_write(
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_ID object_id,
    NX_LWM2M_ID instance_id,
    UINT num_values,
    const NX_LWM2M_RESOURCE *values_ptr,
    UINT write_op);

Description

This service performs a ‘Write’ operation on an Object Instance of the LWM2M Client.

The following write operations can be specified to the write_op parameter.

Value Write Operation Description
0 Partial Update Adds or updates Resources provided in the new value and leaves other existing Resources unchanged.
NX_LWM2M_CLIENT_OBJECT_WRITE_REPLACE_INSTANCE Replace Instance Replaces the Object Instance with the new provided resource values.
NX_LWM2M_CLIENT_OBJECT_WRITE_REPLACE_RESOURCE Replace Resource Replaces the Resources with the new provided resource values (used to replace Multiple Resources).
NX_LWM2M_CLIENT_OBJECT_WRITE_BOOTSTRAP Bootstrap Write Indicates a call from a Bootstrap sequence.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.
  • object_id: The Object ID.
  • instance_id: The Object Instance ID.
  • num_values: The number of resources to write.
  • values_ptr: Pointer to an array of NX_LWM2M_RESOURCE containing the IDs of the resources, the types and the values to write.
  • write_op: The type of write operation.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The type of a resource is not valid.
  • NX_LWM2M_CLIENT_BUFFER_TOO_SMALL The length of a value is too big to be stored in the instance.
  • NX_LWM2M_CLIENT_METHOD_NOT_ALLOWED A resource doesn’t support the write operation.
  • NX_LWM2M_CLIENT_NO_MEMORY Cannot allocate memory to store a resource value.
  • NX_LWM2M_CLIENT_NOT_ACCEPTABLE The value of a resource is not valid.
  • NX_LWM2M_CLIENT_NOT_FOUND The Object ID, Object Instance ID or a resource ID doesn’t exist.
  • NX_OPTION_ERROR Invalid type of write operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Write object resources.  */
status = nx_lwm2m_client_object_write(&lwm2m_client, 3303, 0, 2, &resource,
                                      NX_LWM2M_CLIENT_OBJECT_WRITE_UPDATE);

/* If status is NX_SUCCESS, write object resources successfully.  */

nx_lwm2m_client_resource_boolean_get

Gets the value of a Boolean Resource.

Prototype

UINT nx_lwm2m_client_resource_boolean_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_BOOL *bool_ptr);

Description

The service retrieves the value of a Boolean Resource.

Parameters

  • resource: Pointer to Resource value description.
  • bool_ptr: Pointer to the destination Boolean value.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not a Boolean value.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the value of a Boolean resource.  */
status = nx_lwm2m_client_resource_boolean_get(&resource, &bool);

/* If status is NX_SUCCESS, the value of Boolean resource was successfully get. */

nx_lwm2m_client_resource_boolean_set

Sets the value of a Boolean Resource.

Prototype

UINT nx_lwm2m_client_resource_boolean_set(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_BOOL bool_data);

Description

The service sets the value of a Boolean Resource.

Parameters

  • resource: Pointer to Resource.
  • bool_data: Boolean data.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the value of a Boolean resource.  */
status = nx_lwm2m_client_resource_boolean_set(&resource, NX_TRUE);

/* If status is NX_SUCCESS, the value of Boolean resource was successfully set. */

nx_lwm2m_client_resource_dim_get

Gets the resource dimension for multiple Resource

Prototype

UINT nx_lwm2m_client_resource_dim_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    UCHAR *dim);

Description

The service retrieves the resource dimension for multiple resource.

Parameters

  • resource: Pointer to Resource.
  • dim: Pointer to the destination dimension.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not a Boolean value.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the resource dimension for multiple resource.  */
status = nx_lwm2m_client_resource_dim_get(&resource, &dim);

/* If status is NX_SUCCESS, the resource dimension was successfully get. */

nx_lwm2m_client_resource_dim_set

Sets the resource dimension for multiple resource.

Prototype

UINT nx_lwm2m_client_resource_dim_set(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    CHAR dim);

Description

The service sets the resource dimension for multiple resource.

Parameters

  • value: Pointer to Resource value description.
  • dim: Dimension value.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the resource dimension.  */
status = nx_lwm2m_client_resource_dim_set(&resource, 3);

/* If status is NX_SUCCESS, the resource dimension was successfully set. */

nx_lwm2m_client_resource_float32_get

Gets the value of a 32-Bit float Resource

Prototype

UINT nx_lwm2m_client_resource_float32_get(
    NX_LWM2M_CLIENT_RESOURCE *resource,
    NX_LWM2M_FLOAT32 *float32_ptr);

Description

The service retrieves the value of a 32-Bit float Resource.

Parameters

  • resource: Pointer to Resource.
  • float32_ptr: Pointer to the destination 32-Bit float value.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not a Boolean value.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the value of a 32-Bit float resource.  */
status = nx_lwm2m_client_resource_float32_get(&resource, &float32);

/* If status is NX_SUCCESS, the value of 32-Bit float resource was successfully get. */

nx_lwm2m_client_resource_float32_set

Sets the value of a 32-Bit float Resource

Prototype

UINT nx_lwm2m_client_resource_float32_set(
    NX_LWM2M_CLIENT_RESOURCE *resource,
    NX_LWM2M_FLOAT32 float32_data);

Description

The service sets the value of a 32-Bit float Resource.

Parameters

  • resource: Pointer to Resource.
  • float32_data: 32-Bit float data.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the value of a 32-Bit float resource.  */
status = nx_lwm2m_client_resource_float32_set(&resource, 1.24);

/* If status is NX_SUCCESS, the value of 32-Bit float resource was successfully set. */

nx_lwm2m_client_resource_float64_get

Gets the value of a 64-Bit float Resource.

Prototype

UINT nx_lwm2m_client_resource_float64_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_FLOAT64 *float64_ptr);

Description

The service retrieves the value of a 64-Bit *float: Resource.

Parameters

  • resource* Pointer to Resource.
  • float64_ptr* Pointer to the destination 64-Bit float value.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not a float value.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the value of a 64-Bit float resource.  */
status = nx_lwm2m_client_resource_float64_get(&resource, &float64);

/* If status is NX_SUCCESS, the value of 64-Bit float resource was successfully get. */

nx_lwm2m_client_resource_float64_set

Sets the value of a 64-Bit float Resource.

Prototype

UINT nx_lwm2m_client_resource_float64_set(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_FLOAT64 float64_data);

Description

The service sets the value of a 64-Bit float Resource.

Parameters

  • resource: Pointer to Resource.
  • float64_data: 64-bit float data.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the value of a 64-Bit float resource.  */
status = nx_lwm2m_client_resource_float64_set(&resource, 1.24);

/* If status is NX_SUCCESS, the value of 64-Bit float resource was successfully set. */

nx_lwm2m_client_resource_info_get

Gets the resource info.

Prototype

UINT nx_lwm2m_client_resource_info_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_ID *resource_id, 
    ULONG *operation);

Description

The service retrieves the resource information of Resource.

Parameters

  • resource: Pointer to Resource.
  • resource_id: Pointer to the destination resource ID.
  • operation: Pointer to the destination resource operation.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the resource information.  */
status = nx_lwm2m_client_resource_info_get(&resource, &resource_id, &operation);

/* If status is NX_SUCCESS, the resource information was successfully get. */

nx_lwm2m_client_resource_info_set

Sets the resource information.

Prototype

UINT nx_lwm2m_client_resource_info_set(
    NX_LWM2M_CLIENT_RESOURCE *value, 
    NX_LWM2M_FLOAT64 float64_data);

Description

The service sets the resource information.

Parameters

  • resource: Pointer to Resource.
  • resource_id: ID of the resource.
  • operation: Operation of the resource.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the resource information.  */
status = nx_lwm2m_client_resource_info_set(&resource, 0, NX_LWM2M_CLIENT_RESOURCE_OPERATION_READ);

/* If status is NX_SUCCESS, the resource information was successfully set. */

nx_lwm2m_client_resource_instances_get

Gets the instance of multiple resource.

Prototype

UINT nx_lwm2m_client_resource_instances_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_CLIENT_RESOURCE *resource_instances, 
    UINT *count);

Description

The service retrieves the resource information of Resource.

Parameters

  • resource: Pointer to Resource.
  • resource_instances: Pointer to the destination resource ID.
  • count: Pointer to the count.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not a Boolean value.
  • NX_LWM2M_CLIENT_NO_MEMORY No memory to fill out instances.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the resource information.  */
status = nx_lwm2m_client_resource_instances_get(&resource, &resource_instances,
                                                &count);

/* If status is NX_SUCCESS, the instances of multiple resource information were successfully get. */

nx_lwm2m_client_resource_instances_set

Sets the resource instances.

Prototype

UINT nx_lwm2m_client_resource_instances_set(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_CLIENT_RESOURCE *resource_instances, 
    UINT count);

Description

The service sets the resource instances for multiple resource.

Parameters

  • resource: Pointer to Resource.
  • resource_instance: Pointer to resource instances.
  • count: Count of resource instances.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the resource information.  */
status = nx_lwm2m_client_resource_instances_set(&resource, &resource_instance, 2);

/* If status is NX_SUCCESS, the resource instances were successfully set. */

nx_lwm2m_client_resource_integer32_get

Gets the value of a 32-Bit integer Resource.

Prototype

UINT nx_lwm2m_client_resource_integer32_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_INTEGER32 *integer32_ptr);

Description

The service retrieves the value of a 32-Bit integer Resource.

Parameters

  • resource: Pointer to Resource.
  • integer32_ptr: Pointer to the 32-Bit integer value.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not integer value.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the value of a 32-Bit integer resource.  */
status = nx_lwm2m_client_resource_integer32_get(&resource, &integer32);

/* If status is NX_SUCCESS, the value of 32-Bit integer resource was successfully get. */

nx_lwm2m_client_resource_integer32_set

Sets the value of a 32-Bit integer Resource.

Prototype

UINT nx_lwm2m_client_resource_integer32_set(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_INTEGER32 integer32_data);

Description

The service sets the value of a 32-Bit integer Resource.

Parameters

  • resource: Pointer to Resource.
  • integer32_data: 32-Bit integer data.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the value of a 32-Bit integer resource.  */
status = nx_lwm2m_client_resource_integer32_set(&resource, 8);

/* If status is NX_SUCCESS, the value of 32-Bit integer resource was successfully set. */

nx_lwm2m_client_resource_integer64_get

Gets the value of a 64-Bit integer Resource.

Prototype

UINT nx_lwm2m_client_resource_integer64_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_INTEGER64 *integer64_ptr);

Description

The service retrieves the value of a 64-Bit integer Resource.

Parameters

  • resource: Pointer to Resource.
  • integer64_ptr: Pointer to the 64-Bit integer value.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not 64-Bit integer value.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the value of a 64-Bit integer resource.  */
status = nx_lwm2m_client_resource_integer64_get(&resource, &integer64);

/* If status is NX_SUCCESS, the value of 64-Bit integer resource was successfully get. */

nx_lwm2m_client_resource_integer64_set

Set the value of a 64-Bit integer Resource

Prototype

UINT nx_lwm2m_client_resource_integer64_set(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_INTEGER64 integer64_data);

Description

The service sets the value of a 64-Bit integer Resource.

Parameters

  • resource: Pointer to Resource.
  • integer64_data: 64-bit integer.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the value of a 64-Bit integer resource.  */
status = nx_lwm2m_client_resource_integer64_set(&resource, 32323);

/* If status is NX_SUCCESS, the value of 64-Bit integer resource was successfully set. */

nx_lwm2m_client_resource_objlnk_get

Gets the value of an object link resource.

Prototype

UINT nx_lwm2m_client_resource_objlnk_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    NX_LWM2M_ID *object_id, 
    NX_LWM2M_ID *instance_id);

Description

The service retrieves the value of object link.

Parameters

  • resource: Pointer to Resource.
  • object_id: Pointer to the object ID.
  • instance_id: Pointer to the object instance ID.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not an object link value.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the value of the object link resource.  */
status = nx_lwm2m_client_resource_objlnk_get(&resource, &object_id, &instance_id);

/* If status is NX_SUCCESS, the object link value was successfully get. */

nx_lwm2m_client_resource_objlnk_set

Sets the resource instances

Prototype

UINT nx_lwm2m_client_resource_objlnk_set(
    NX_LWM2M_CLIENT_RESOURCE *value, 
    NX_LWM2M_ID object_id, 
    NX_LWM2M_ID instance_id);

Description

The service sets the value of the object link resource.

Parameters

  • resource: Pointer to Resource.
  • object_id: Object ID.
  • instance_id: Object instance ID.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the value of object link resource.  */
status = nx_lwm2m_client_resource_objlnk_set(&resource, 3303, 2);

/* If status is NX_SUCCESS, the value of object link resource was successfully set. */

nx_lwm2m_client_resource_opaque_get

Gets the value of an opaque Resource.

Prototype

UINT nx_lwm2m_client_resource_opaque_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    const VOID **opaque_ptr, 
    UINT \*opaque_length);

Description

The service retrieves the value of an opaque Resource. An opaque resource value consists of a pointer to a buffer and a length.

Parameters

  • resource: Pointer to Resource.
  • opaque_ptr: Pointer to the opaque data.
  • opaque_length: Pointer to the opaque data length.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not an opaque resource.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the value of an opaque resource.  */
status = nx_lwm2m_client_resource_opaque_get(&resource, &opaque_ptr, &opaque_length);

/* If status is NX_SUCCESS, the value of opaque resource was successfully get. */

nx_lwm2m_client_resource_opaque_set

Sets the value of an opaque Resource.

Prototype

UINT nx_lwm2m_client_resource_opaque_set(
    NX_LWM2M_CLIENT_RESOURCE *value, 
    VOID *opaque_ptr, 
    UINT opaque_length);

Description

The service sets the value of an opaque Resource.

Parameters

  • resource: Pointer to Resource.
  • opaque_ptr: Pointer to the opaque data.
  • opaque_length: Length of the opaque data.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the value of an opaque resource.  */
status = nx_lwm2m_client_resource_opaque_set(&resource, “AQIDBAU=”, 8);

/* If status is NX_SUCCESS, the value of opaque resource was successfully set. */

nx_lwm2m_client_resource_string_get

Gets the value of a string Resource.

Prototype

UINT nx_lwm2m_client_resource_string_get(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    const CHAR **string_ptr, 
    UINT *string_length);

Description

The service retrieves the value of a string Resource.

Parameters

  • resource: Pointer to Resource.
  • string_ptr: Pointer to the destination string pointer.
  • string_length: Pointer to the destination string length. Can be NULL if the string is null-terminated.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_BAD_ENCODING The resource value is not a string value.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the value of a string resource.  */
status = nx_lwm2m_client_resource_string_get(&resource, &string_ptr, &string_length);

/* If status is NX_SUCCESS, the value of string resource was successfully get. */

nx_lwm2m_client_resource_string_set

Sets the value of a string Resource.

Prototype

UINT nx_lwm2m_client_resource_string_set(
    NX_LWM2M_CLIENT_RESOURCE *resource, 
    CHAR *string_ptr, 
    UINT string_length);

Description

The service sets the value of a 64-Bit integer Resource.

Parameters

  • resource: Pointer to Resource.
  • string_ptr: Pointer to the string.
  • string_length: Length of the string.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Set the value of a string resource.  */
status = nx_lwm2m_client_resource_string_set(&resource, “test”, sizeof(“test”) - 1);

/* If status is NX_SUCCESS, the value of string resource was successfully set. */

nx_lwm2m_client_session_bootstrap

Starts a session with a Bootstrap Server.

Prototype

UINT nx_lwm2m_client_session_bootstrap(
    NX_LWM2M_CLIENT_SESSION *session_ptr, 
    NX_LWM2M_ID security_id, 
    ULONG ip_address, 
    UINT port);

Description

This service starts a session with a Bootstrap Server. The server should have a corresponding security instance in the Security Object.

If the ‘Hold Off’ resource is different than zero in the Security Instance associated with this server the session will wait for a Server Initiated Bootstrap, If no bootstrap is initiated by the server after this period of time a Client Initiated Boostrap will be performed.

Any current active session is aborted by this call and replaced by the new Bootstrap Server session.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.
  • security_id: The Security Instance ID of the Bootstrap Server, must be set to NX_LWM2M_RESERVED_ID (65535) if the Bootstrap Server has no Security Instance defined.
  • ip_address: The IP address of the server.
  • port: The UDP port of the server.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_ERROR Bootstrap error.
  • NX_LWM2M_CLIENT_PORT_UNAVAILABLE Port is unavailable.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Start bootstrap.  */
status = nx_lwm2m_client_session_bootstrap(&lwm2m_client, 0, &ip_address, 5783);

/* If status is NX_SUCCESS, start bootstrap successfully.  */

nx_lwm2m_client_session_bootstrap_dtls

Starts a secure session with a Bootstrap Server

Prototype

UINT nx_lwm2m_client_session_bootstrap_dtls(
    NX_LWM2M_CLIENT_SESSION *session_ptr, 
    NX_LWM2M_ID security_id, 
    ULONG ip_address, 
    UINT port, 
    NX_SECURE_DTLS_SESSION *dtls_session_ptr);

Description

This service start a session with a Bootstrap Server using a secure DTLS connection. The server should have a corresponding security instance in the Security Object.

The DTLS session must have been configured with the proper cipher suites and key material before calling this function. NX_SECURE_ENABLE_DTLS must be defined.

If the ‘Hold Off’ resource is different than zero in the Security Instance associated with this server the session will wait for a Server Initiated Bootstrap, if no bootstrap is initiated by the server after this period of time a Client Initiated Boostrap will be performed.

Any current active session is aborted by this call and replaced by the new Bootstrap Server session.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.
  • security_id: The Security Instance ID of the Bootstrap Server, must be set to NX_LWM2M_RESERVED_ID (65535) if the Bootstrap Server has no Security Instance defined.
  • ip_address: The IP address of the server.
  • port: The UDP port of the server.
  • dtls_session_ptr: The DTLS session to use for the Bootstrap session.
  • dtls_local_port: The local UDP port used for the DTLS session.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_ERROR Bootstrap error.
  • NX_LWM2M_CLIENT_PORT_UNAVAILABLE Port is unavailable.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Start bootstrap with DTLS.  */
status = nx_lwm2m_client_session_bootstrap_dtls(&lwm2m_client, 0, &ip_address, 5784, &dtls_session);

/* If status is NX_SUCCESS, start bootstrap successfully.  */

nx_lwm2m_client_session_create

Creates a LWM2M Client Session.

Prototype

UINT nx_lwm2m_client_session_create(
    NX_LWM2M_CLIENT_SESSION *session_ptr, 
    NX_LWM2M_CLIENT *client_ptr,
    NX_LWM2M_CLIENT_SESSION_STATE_CALLBACK state_callback);

Description

This service creates a new LWM2M Client Session attached to an existing LWM2M Client. The session is used by the LWM2M Client to communicate with a Bootstrap Server or a LWM2M Server.

The application must provide a callback function that will be called when the state of the session is updated.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.
  • client_ptr: Pointer to the previously created LWM2M Client.
  • state_callback: Application callback that is called when the state of the session has changed.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Create session.  */
status = nx_lwm2m_client_session_create(&session, &lwm2m_client, session_callback);

/* If status is NX_SUCCESS, a session was successfully created.  */

nx_lwm2m_client_session_delete

Deletes a LWM2M Client Session.

Prototype

UINT nx_lwm2m_client_session_delete(NX_LWM2M_CLIENT_SESSION *session_ptr);

Description

This service deletes a LWM2M Client Session.

When a LWM2M Client is deleted by calling nx_lwm2m_client_delete all sessions attached to the client are also deleted.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Delete session.  */
status = nx_lwm2m_client_session_delete(&session);

/* If status is NX_SUCCESS, a session was successfully deleted.  */

nx_lwm2m_client_session_deregister

Terminates a session with a LWM2M Server.

Prototype

UINT nx_lwm2m_client_session_deregister(NX_LWM2M_CLIENT_SESSION *session_ptr);

Description

This service performs a ‘De-Register’ operation to a LWM2M Server.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_NOT_REGISTERED The client is not registered to the server.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* De-register session.  */
status = nx_lwm2m_client_session_deregister(&session);

/* If status is NX_SUCCESS, session was successfully de-registered.  */

nx_lwm2m_client_session_error_get

Gets the last error of a session.

Prototype

UINT nx_lwm2m_client_session_error_get(NX_LWM2M_CLIENT_SESSION *session_ptr);

Description

This service returns the error code of the session when the session is in an error state.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.

Return Values

  • NX_SUCCESS The session is not in error state.
  • NX_LWM2M_CLIENT_ADDRESS_ERROR Invalid server address.
  • NX_LWM2M_ CLIENT_BUFFER_TOO_SMALL Payload of request doesn’t fit in network buffer.
  • NX_LWM2M_ CLIENT_DTLS_ERROR Failed to establish secured connection with server.
  • NX_LWM2M_ CLIENT_ERROR Unspecified error.
  • NX_LWM2M_ CLIENT_FORBIDDEN Registration refused by server.
  • NX_LWM2M_ CLIENT_NOT_FOUND Client not found by server when updating/deregistering.
  • NX_LWM2M_ CLIENT_SERVER_INSTANCE_DELETED The Server Object Instance corresponding to the session has been deleted.
  • NX_LWM2M_ CLIENT_TIMED_OUT No answer from server.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the error.  */
status = nx_lwm2m_client_session_error_get(&session);

nx_lwm2m_client_session_register

Starts a session with a LWM2M Server.

Prototype

UINT nx_lwm2m_client_session_register(
    NX_LWM2M_CLIENT_SESSION *session_ptr, 
    NX_LWM2M_ID server_id, 
    ULONG ip_address, 
    UINT port);

Description

This service performs a ‘Register’ operation to a LWM2M Server. The server must have a corresponding server instance in the Server Object.

If the registration is successfully the LWM2M Client will process further operations from the server and will periodically send ‘Update’ messages until the client is de-registered.

Any current active session is aborted by this call and replaced by the new LWM2M Server session.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.
  • server_id: The Short Server ID of the LWM2M Server.
  • ip_address: The IP address of the server.
  • port: The UDP port of the server.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_ERROR Bootstrap error.
  • NX_LWM2M_CLIENT_PORT_UNAVAILABLE Port is unavailable.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Start register.  */
status = nx_lwm2m_client_session_register (&lwm2m_client, 123, &ip_address, 5683);

/* If status is NX_SUCCESS, start register successfully.  */

nx_lwm2m_client_session_register_dtls

Starts a secure session with a LWM2M Server.

Prototype

UINT nx_lwm2m_client_session_register_dtls(
    NX_LWM2M_CLIENT_SESSION *session_ptr, 
    NX_LWM2M_ID server_id, 
    ULONG ip_address, 
    UINT port,
    NX_SECURE_DTLS_SESSION *dtls_session_ptr);

Description

This service performs a ‘Register’ operation to a LWM2M Server using a secure DTLS connection. The server must have a corresponding server instance in the Server Object.

The DTLS session must have been configured with the proper cipher suites and key material before calling this function. NX_SECURE_ENABLE_DTLS must be defined.

If the registration is successfully the LWM2M Client will process further operations from the server and will periodically send ‘Update’ messages until the client is de-registered.

Any current active session is aborted by this call and replaced by the new LWM2M Server session.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.
  • server_id: The Short Server ID of the LWM2M Server.
  • ip_address: The IP address of the server.
  • port: The UDP port of the server.
  • dtls_session_ptr: The DTLS session to use for the LWM2M session.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_ERROR Bootstrap error.
  • NX_LWM2M_CLIENT_PORT_UNAVAILABLE Port is unavailable.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Start register with DTLS.  */
status = nx_lwm2m_client_session_register_dtls(&lwm2m_client, 123, &ip_address, 5683, &dtls_session);

/* If status is NX_SUCCESS, start register with DTLS successfully.  */

nx_lwm2m_client_session_register_info_get

Starts a secure session with a LWM2M Server.

Prototype

UINT nx_lwm2m_client_session_register_dtls(
    NX_LWM2M_CLIENT_SESSION *session_ptr, 
    UINT security_instance_id, 
    NX_LWM2M_ID *server_id,
    CHAR **server_uri, 
    UINT *server_uri_length, 
    UCHAR *security_mode, 
    UCHAR **pub_key_or_id, 
    UINT *pub_key_or_id_len, 
    UCHAR **server_pub_key, 
    UINT *server_pub_key_len, 
    UCHAR **secret_key, 
    UINT *secret_key_len);

Description

Once a communication session with a Bootstrap server was established. Application can call this api to get the server and security information for the next registration step.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.
  • security_instance_id: Security instance ID.
  • server_id: Pointer to destination server ID.
  • server_uri: Pointer to destination server uri.
  • server_uri_len: Pointer to destination server uri length.
  • security_mode: Pointer to destination security mode.
  • pub_key_or_id: Pointer to destination public key or identity.
  • pub_key_or_id_len: Pointer to destination public key or identity length.
  • server_pub_key: Pointer to destination server public key.
  • server_pub_key_len: Pointer to destination server public key length.
  • secret_key: Pointer to destination secret key.
  • secret_key_len: Pointer to destination secret key length.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_NOT_FOUND There is no security Object instance.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Get the register information.  */
status = nx_lwm2m_client_session_register_info_get(&session, NX_LWM2M_CLIENT_RESERVED_ID, &server_id, &server_uri, &server_uri_length, &security_mode, &pub_key_or_id, &pub_key_or_id_len, NX_NULL, NX_NULL, &secret_key, &secret_key_len);

/* If status is NX_SUCCESS, the register information was successfully gotten.  */

nx_lwm2m_client_session_update

Updates a session with a LWM2M Server.

Prototype

UINT nx_lwm2m_client_session_update(NX_LWM2M_CLIENT_SESSION *session_ptr);

Description

This service performs an ‘Update’ operation to a LWM2M Server.

Parameters

  • session_ptr: Pointer to LWM2M Client Session control block.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_LWM2M_CLIENT_NOT_REGISTERED The client is not registered to the server.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Update a session.  */
status = nx_lwm2m_client_session_update(&session);

/* If status is NX_SUCCESS, a session was successfully updated.  */

nx_lwm2m_client_unlock

Unlocks a LWM2M Client.

Prototype

UINT nx_lwm2m_client_unlock(NX_LWM2M_CLIENT *client_ptr);

Description

This service unlocks the LWM2M Client previously locked by a call to nx_lwm2m_client_unlock.

Parameters

  • client_ptr: Pointer to LWM2M Client control block.

Return Values

  • NX_SUCCESS Successful operation.
  • NX_PTR_ERROR Invalid pointer.

Allowed From

Threads, Initialization

Example

/* Unlock lwm2m client.  */
status = nx_lwm2m_client_unlock(&lwm2m_client);

/* If status is NX_SUCCESS, unlock lwm2m client successfully.  */