Chapter 4 - Description of Azure RTOS NetX LWM2M services
This chapter contains a description of all Azure RTOS NetX LWM2M 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
Create LWM2M Client
Prototype
UINT nx_lwm2m_client_create(
NX_LWM2M_CLIENT *client_ptr,
NX_IP *ip_ptr,
NX_PACKET_POOL *packet_pool_ptr,
UINT local_port,
const CHAR *name_ptr,
const CHAR *msisdn_ptr,
UCHAR binding_modes,
VOID *stack_ptr,
ULONG stack_size);
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.
- local_port: The local UDP port used for non-secure communication.
- name_ptr: Pointer to 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 if SMS binding is not supported.
- 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.
Return Values
- NX_SUCCESS: The LWM2M Client has been successfully created.
- NX_LWM2M_ERROR: LWM2M Client create error.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_delete
Delete 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.
nx_lwm2m_client_device_callbacks_set
Set Device Object application callbacks
Prototype
UINT nx_lwm2m_client_device_callbacks_set(
NX_LWM2M_CLIENT *client_ptr,
NX_LWM2M_CLIENT_DEVICE_READ_CALLBACK read_callback,
NX_LWM2M_CLIENT_DEVICE_DISCOVER_CALLBACK discover_callback,
NX_LWM2M_CLIENT_DEVICE_WRITE_CALLBACK write_callback,
NX_LWM2M_CLIENT_DEVICE_EXECUTE_CALLBACK execute_callback);
Description
This service installs the application callbacks 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.
- read_callback: The 'Read' method callback.
- discover_callback: The 'Discover' method callback.
- write_callback: The 'Write' method callback.
- execute_callback: The 'Execute' method callback.
Return Values
- NX_SUCCESS: Successful operation.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_device_error_push
Add error code to 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_BUFFER_TOO_SMALL: The maximum number of stored error codes has been reached.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_device_error_reset
Reset 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.
nx_lwm2m_client_device_resource_changed
Signal change of 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.
nx_lwm2m_client_lock
Lock 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.
nx_lwm2m_client_object_add
Add Object implementation to the LWM2M Client
Prototype
UINT nx_lwm2m_client_object_add(
NX_LWM2M_CLIENT *client_ptr,
NX_LWM2M_OBJECT *object_ptr);
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.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_ALREADY_EXIST: The Object ID already exists.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_object_create
Create 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_ALREADY_EXIST: The Object Instance ID already exists.
- NX_LWM2M_METHOD_NOT_ALLOWED: The Object doesn't support instance creation.
- NX_LWM2M_NO_MEMORY: Cannot allocate memory to store the new instance.
- NX_LWM2M_NOT_FOUND: The Object ID doesn't exist.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_object_delete
Delete 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_METHOD_NOT_ALLOWED: The Object doesn't support instance deletion.
- NX_LWM2M_NOT_FOUND: The Object ID or Object Instance ID doesn't exist.
- NX_PTR_ERROR Invalid pointer.
nx_lwm2m_client_object_discover
Discover 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_ptr,
NX_LWM2M_RESOURCE_INFO *resources_ptr);
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_ptr: On input the size of the destination buffer, on output the number of elements written to the buffer.
- resources_ptr: Pointer to the destination buffer.
Return Values
- NX_SUCCESS: Successful operation..
- NX_LWM2M_BUFFER_TOO_SMALL: The resources buffer is too small to store the list of resources.
- NX_LWM2M_NOT_FOUND: The Object ID or Object Instance ID doesn't exist.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_object_execute
Execute 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_METHOD_NOT_ALLOWED: The resource doesn't support the execute operation.
- NX_LWM2M_NOT_FOUND: The Object ID, Object Instance ID or the resource ID doesn't exist.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_object_get_next
Get the list of Objects implemented by the LWM2M Client
Prototype
UINT nx_lwm2m_client_object_get_next(
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_NOT_FOUND: The given Object ID is the last of the database.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_object_instance_get_next
Get the list of Instances of an Object
Prototype
UINT nx_lwm2m_client_object_instance_get_next(
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_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.
nx_lwm2m_client_object_read
Read resources values of an Object Instance
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_METHOD_NOT_ALLOWED: A resource doesn't support the read operation.
- NX_LWM2M_NOT_FOUND: The Object ID, Object Instance ID or a resource ID doesn't exist.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_object_write
Change resources 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:
0 — Partial Update: adds or updates Resources provided in the new value and leaves other existing Resources unchanged,
NX_LWM2M_OBJECT_WRITE_REPLACE_INSTANCE — Replace Instance: replaces the Object Instance with the new provided resource values.
NX_LWM2M_OBJECT_WRITE_REPLACE_RESOURCE — Replace Resource: replaces the Resources with the new provided resource values (used to replace Multiple Resources).
NX_LWM2M_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_BAD_ENCODING: The type of a resource is not valid.
- NX_LWM2M_BUFFER_TOO_SMALL: The length of a value is too big to be stored in the instance.
- NX_LWM2M_METHOD_NOT_ALLOWED: A resource doesn't support the write operation.
- NX_LWM2M_NO_MEMORY: Cannot allocate memory to store a resource value.
- NX_LWM2M_NOT_ACCEPTABLE: The value of a resource is not valid.
- NX_LWM2M_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.
nx_lwm2m_client_security_key_callbacks_set
Set Security Object key management callbacks
Prototype
UINT nx_lwm2m_client_security_key_callbacks_set(
NX_LWM2M_CLIENT *client_ptr,
NX_LWM2M_CLIENT_SECURITY_KEY_WRITE_CALLBACK write_callback,
NX_LWM2M_CLIENT_SECURITY_KEY_DELETE_CALLBACK delete_callback);
Description
This service installs the application callbacks for implementing operations on the LWM2M Security Object resources related to the security keys.
The LWM2M Client delegates the security key management to the application during the Bootstrap sessions, the callbacks will be called when the Bootstrap Server writes or deletes the following resources on a Security Object Instance: Public Key or Identity (3), Server Public Key (4), Secret Key (5).
The application is responsible for storing the keys data and for configuring the DTLS sessions used by the LWM2M client.
Parameters
- client_ptr: Pointer to LWM2M Client control block.
- write_callback: The 'Write' key method callback.
- delete_callback: The 'Delete' key method callback.
Return Values
- NX_SUCCESS: Successful operation.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_session_bootstrap
Start 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 start 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 bootstrap 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_NOT_FOUND: There is No Security Object instance corresponding to the Security Instance ID.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_session_bootstrap_dtls
Start 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,
UINT dtls_local_port);
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 bootstrap 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_NOT_FOUND: There is No Security Object instance corresponding to the Security Instance ID.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_session_create
Create 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.
nx_lwm2m_client_session_delete
Delete 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.
nx_lwm2m_client_session_deregister
Terminate 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_NOT_REGISTERED: The client is not registered to the server.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_session_error_get
Get 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_ADDRESS_ERROR: Invalid server address.
- NX_LWM2M_BUFFER_TOO_SMALL: Payload of request doesn't fit in network buffer.
- NX_LWM2M_DTLS_ERROR: Failed to establish secured connection with server.
- NX_LWM2M_ERROR: Unspecified error.
- NX_LWM2M_FORBIDDEN: Registration refused by server.
- NX_LWM2M_NOT_FOUND: Client not found by server when updating/unregistering.
- NX_LWM2M_SERVER_INSTANCE_DELETED: The Server Object Instance corresponding to the session has been deleted.
- NX_LWM2M_TIMED_OUT: No answer from server.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_session_register
Start 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 successful 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_NOT_FOUND: There is No Server Object instance corresponding to the Short Server ID.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_session_register_dtls
Start 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,
UINT dtls_local_port);
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.
Each DTLS session uses its own UDP socket for communication, so the local port dtls_local_port must be different for each session if the application creates several secure sessions.
If the registration is successful 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.
- dtls_local_port: The local UDP port used for the DTLS session.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_NOT_FOUND: There is No Server Object instance corresponding to the Short Server ID.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_session_update
Update 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_NOT_REGISTERED: The client is not registered to the server.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_client_unlock
Unlock 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.
nx_lwm2m_firmware_create
Create Firmware Update Object
Prototype
UINT nx_lwm2m_firmware_create(
NX_LWM2M_FIRMWARE *firmware_ptr,
NX_LWM2M_CLIENT *client_ptr, UINT protocols,
NX_LWM2M_FIRMWARE_PACKAGE_CALLBACK package_callback,
NX_LWM2M_FIRMWARE_PACKAGE_URI_CALLBACK package_uri_callback,
NX_LWM2M_FIRMWARE_UPDATE_CALLBACK update_callback);
Description
This service initializes a Firmware Update Object and adds the Object to a previously created LWM2M Client. The Firmware Update Object implements the resources for communicating with a LWM2M Server but the application must provide callbacks for implementing the actual operations on the firmware (downloading, storing, and updating the firmware).
The protocols parameter indicates which protocols are supported by the application for retrieving the firmware with the 'Package URI' resource, the following flags are defined:
- NX_LWM2M_FIRMWARE_PROTOCOL_COAP,
- NX_LWM2M_FIRMWARE_PROTOCOL_COAPS,
- NX_LWM2M_FIRMWARE_PROTOCOL_HTTP,
- NX_LWM2M_FIRMWARE_PROTOCOL_HTPPS.
Parameters
- firmware_ptr: Pointer to the Firmware Object control block.
- client_ptr: Pointer to previously created LWM2M Client.
- protocols: Flags indicating which protocols are supported by the Package URI resource.
- package_callback: Must be NULL [TBD].
- package_uri_callback: Callback used to implement the Package URI resource.
- update_callback: Callback used to implement the Update resource.
Return Values
- NX_SUCCESS: Successful operation.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_firmware_package_info_set
Set Firmware Update Package Information
Prototype
UINT nx_lwm2m_firmware_package_info_set(
NX_LWM2M_FIRMWARE *firmware_ptr,
const CHAR *name,
const CHAR *version);
Description
This service changes the values of the 'PkgName' (6) and 'PkgVersion' (7) resources of the Firmware Update Object.
Parameters
- firmware_ptr: Pointer to the Firmware Update Object.
- name: The new value of the Package Name.
- version: The new value of the Package Version.
Return Values
- NX_SUCCESS: Successful operation.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_firmware_result_set
Set Firmware Update Result
Prototype
UINT nx_lwm2m_firmware_result_set(
NX_LWM2M_FIRMWARE *firmware_ptr,
UCHAR result);
Description
This service changes the value of the 'Update Result' (5) resource of the Firmware Update Object.
Parameters
- firmware_ptr: Pointer to the Firmware Update Object.
- result: The new value of the Update Result resource.
Return Values
- NX_SUCCESS: Successful operation.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_firmware_state_set
Set Firmware Update State
Prototype
UINT nx_lwm2m_firmware_state_set(
NX_LWM2M_FIRMWARE *firmware_ptr,
UCHAR state);
Description
This service changes the value of the 'State' (3) resource of the Firmware Update Object.
Parameters
- firmware_ptr: Pointer to the Firmware Update Object.
- state: The new value of the State resource.
Return Values
- NX_SUCCESS: Successful operation.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_object_resource_changed
Signal change of a resource value of an Object Instance
Prototype
UINT nx_lwm2m_object_resource_changed(
NX_LWM2M_OBJECT *object_ptr,
NX_LWM2M_OBJECT_INSTANCE *instance_ptr,
const NX_LWM2M_RESOURCE *resource);
Description
This service is used by an Object implementation to signals the LWM2M Client that one of its resource value has changed. The LWM2M Client will send a notification if the resource is observed by a LWM2M Server.
Parameters
- object_ptr: Pointer to the Object implementation.
- instance_ptr: Pointer to the Object Instance.
- resource: Pointer to the structure describing the resource that has changed.
Return Values
- NX_SUCCESS: Successful operation.
- NX_PTR_ERROR: Invalid pointer.
nx_lwm2m_resource_get_boolean
Get the value of a Boolean Resource
Prototype
UINT nx_lwm2m_resource_get_boolean(
const NX_LWM2M_RESOURCE *value,
NX_LWM2M_BOOL *bool_ptr);
Description
The service retrieves the value of a Boolean Resource.
Parameters
- value: Pointer to Resource value description.
- bool_ptr: Pointer to the destination Boolean value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_ENCODING: The resource value is not a Boolean value.
nx_lwm2m_resource_get_float32
Get the value of a 32-bit Floating Point Resource
Prototype
UINT nx_lwm2m_resource_get_float32(
const NX_LWM2M_RESOURCE *value,
NX_LWM2M_FLOAT32 *float32_ptr);
Description
The service retrieves the value of a 32-bit Floating Point Resource.
Parameters
- value: Pointer to Resource value description.
- float32_ptr: Pointer to the destination 32-Bit Floating Point value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_ENCODING: The resource value is not a Floating Point value.
nx_lwm2m_resource_get_float64
Get the value of a 64-bit Floating Point Resource
Prototype
UINT nx_lwm2m_resource_get_float64(
const NX_LWM2M_RESOURCE *value,
NX_LWM2M_FLOAT64 *float64_ptr);
Description
The service retrieves the value of a 64-bit Floating Point Resource.
Parameters
- value: Pointer to Resource value description.
- float64_ptr: Pointer to the destination 64-Bit Floating Point value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_ENCODING: The resource value is not a Floating Point value.
nx_lwm2m_resource_get_integer32
Get the value of a 32-Bit Integer Resource
Prototype
UINT nx_lwm2m_resource_get_integer32(
const NX_LWM2M_RESOURCE *value,
NX_LWM2M_INT32 *int32_ptr);
Description
The service retrieves the value of a 32-Bit Integer Resource.
Parameters
- value: Pointer to Resource value description.
- int32_ptr: Pointer to the destination 32-Bit Integer value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_ENCODING: The resource value is not an Integer value, or the Integer value doesn't fit in a 32-Bit number.
nx_lwm2m_resource_get_integer64
Get the value of a 64-Bit Integer Resource
Prototype
UINT nx_lwm2m_resource_get_integer64(
const NX_LWM2M_RESOURCE *value,
NX_LWM2M_INT64 *int64_ptr);
Description
The service retrieves the value of a 64-Bit Integer Resource.
Parameters
- value: Pointer to Resource value description.
- int64_ptr: Pointer to the destination 64-Bit Integer value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_ENCODING: The resource value is not an Integer value.
nx_lwm2m_resource_get_objlnk
Get the value of an Object Link Resource
Prototype
UINT nx_lwm2m_resource_get_objlnk(
const NX_LWM2M_RESOURCE *value,
NX_LWM2M_OBJLNK *objlnk_ptr);
Description
The service retrieves the value of an Object Link Resource.
Parameters
- value: Pointer to Resource value description.
- objlnk_ptr: Pointer to the destination Object Link value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_ENCODING: The resource value is not an Object Link value.
nx_lwm2m_resource_get_opaque
Get the value of an Opaque Resource
Prototype
UINT nx_lwm2m_resource_get_opaque(
const NX_LWM2M_RESOURCE *value,
const VOID **opaque_ptr_ptr,
UINT *opaque_length_ptr);
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
- value: Pointer to Resource value description.
- opaque_ptr_ptr: Pointer to the destination opaque buffer pointer.
- opaque_length_ptr: Pointer to the destination opaque buffer length.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_ENCODING: The resource value is not an Opaque value.
nx_lwm2m_resource_get_string
Get the value of a String Resource
Prototype
UINT nx_lwm2m_resource_get_string(
const NX_LWM2M_RESOURCE *value,
const CHAR **string_ptr_ptr,
UINT *string_length_ptr);
Description
The service retrieves the value of a String Resource.
Parameters
- value: Pointer to Resource value description.
- string_ptr_ptr: Pointer to the destination string pointer.
- string_length_ptr: Pointer to the destination string length. Can be NULL if the string is null-terminated.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_ENCODING: The resource value is not a String value.
nx_lwm2m_resource_multiple_get_boolean
Get the value of a Boolean Resource Multiple Resource Instance
Prototype
UINT nx_lwm2m_resource_multiple_get_boolean(
const NX_LWM2M_RESOURCE *value,
int index,
NX_LWM2M_ID *instance_id_ptr,
NX_LWM2M_BOOL *bool_ptr);
Description
The service retrieves the value of a Boolean Resource Instance from a Multiple Resource.
Parameters
- value: Pointer to the Multiple Resource value description.
- index: Index of the Instance to retrieve in the Resource value array.
- instance_id_ptr: Pointer to the destination Instance ID.
- bool_ptr: Pointer to the destination Boolean value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_PARAMETER: The index is out of range.
- NX_LWM2M_BAD_ENCODING: The resource is not a multiple resource, or the resource value is not a Boolean value.
nx_lwm2m_resource_multiple_get_float32
Get the value of a 32-bit Floating Point Multiple Resource Instance
Prototype
UINT nx_lwm2m_resource_multiple_get_float32(
const NX_LWM2M_RESOURCE *value,
int index,
NX_LWM2M_ID *instance_id_ptr,
NX_LWM2M_FLOAT32 *float32_ptr);
Description
The service retrieves the value of a 32-bit Floating Point Resource Instance from a Multiple Resource.
Parameters
- value: Pointer to the Multiple Resource value description.
- index: Index of the Instance to retrieve in the Resource value array.
- instance_id_ptr: Pointer to the destination Instance ID.
- float32_ptr: Pointer to the destination 32-Bit Floating Point value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_PARAMETER: The index is out of range.
- NX_LWM2M_BAD_ENCODING: The resource is not a multiple resource, or the resource value is not a Floating Point value.
nx_lwm2m_resource_multiple_get_float64
Get the value of a 64-bit Floating Point Multiple Resource Instance
Prototype
UINT nx_lwm2m_resource_multiple_get_float64(
const NX_LWM2M_RESOURCE *value,
int index,
NX_LWM2M_ID *instance_id_ptr,
NX_LWM2M_FLOAT64 *float64_ptr);
Description
The service retrieves the value of a 64-bit Floating Point Resource Instance from a Multiple Resource.
Parameters
- value: Pointer to the Multiple Resource value description.
- index: Index of the Instance to retrieve in the Resource value array.
- instance_id_ptr: Pointer to the destination Instance ID.
- float64_ptr: Pointer to the destination 64-Bit Floating Point value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_PARAMETER: The index is out of range.
- NX_LWM2M_BAD_ENCODING: The resource is not a multiple resource, or the resource value is not a Floating Point value.
nx_lwm2m_resource_multiple_get_integer32
Get the value of a 32-Bit Integer Multiple Resource Instance
Prototype
UINT nx_lwm2m_resource_multiple_get_integer32(
const NX_LWM2M_RESOURCE *value,
int index,
NX_LWM2M_ID *instance_id_ptr,
NX_LWM2M_INT32 *int32_ptr);
Description
The service retrieves the value of a 32-Bit Integer Resource Instance from a Multiple Resource.
Parameters
- value: Pointer to the Multiple Resource value description.
- index: Index of the Instance to retrieve in the Resource value array.
- instance_id_ptr: Pointer to the destination Instance ID.
- int32_ptr: Pointer to the destination 32-Bit Integer value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_PARAMETER: The index is out of range.
- NX_LWM2M_BAD_ENCODING: The resource is not a multiple resource, or the resource value is not an Integer value, or the Integer value doesn't fit in a 32-Bit number.
nx_lwm2m_resource_multiple_get_integer64
Get the value of a 64-Bit Integer Multiple Resource Instance
Prototype
UINT nx_lwm2m_resource_multiple_get_integer64(
const NX_LWM2M_RESOURCE *value,
int index,
NX_LWM2M_ID *instance_id_ptr,
NX_LWM2M_INT64 *int64_ptr);
Description
The service retrieves the value of a 64-Bit Integer Resource Instance from a Multiple Resource.
Parameters
- value: Pointer to the Multiple Resource value description.
- index: Index of the Instance to retrieve in the Resource value array.
- instance_id_ptr: Pointer to the destination Instance ID.
- int64_ptr: Pointer to the destination 64-Bit Integer value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_PARAMETER: The index is out of range.
- NX_LWM2M_BAD_ENCODING: The resource is not a multiple resource, or the resource value is not an Integer value.
nx_lwm2m_resource_multiple_get_objlnk
Get the value of an Object Link Multiple Resource Instance
Prototype
UINT nx_lwm2m_resource_multiple_get_objlnk(
const NX_LWM2M_RESOURCE *value,
int index,
NX_LWM2M_ID *instance_id_ptr,
NX_LWM2M_OBJLNK *objlnk_ptr);
Description
The service retrieves the value of an Object Link Resource Instance from a Multiple Resource.
Parameters
- value: Pointer to the Multiple Resource value description.
- index: Index of the Instance to retrieve in the Resource value array.
- instance_id_ptr: Pointer to the destination Instance ID.
- objlnk_ptr: Pointer to the destination Object Link value.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_PARAMETER: The index is out of range.
- NX_LWM2M_BAD_ENCODING: The resource is not a multiple resource, or the resource value is not an Object Link value.
nx_lwm2m_resource_multiple_get_opaque
Get the value of an Opaque Multiple Resource Instance
Prototype
UINT nx_lwm2m_resource_multiple_get_opaque(
const NX_LWM2M_RESOURCE *value,
int index,
NX_LWM2M_ID *instance_id_ptr,
const VOID **opaque_ptr_ptr,
UINT *opaque_length_ptr);
Description
The service retrieves the value of an Opaque Resource Instance from a Multiple Resource.
An opaque resource value consists of a pointer to a buffer and a length.
Parameters
- value: Pointer to the Multiple Resource value description.
- index: Index of the Instance to retrieve in the Resource value array.
- instance_id_ptr: Pointer to the destination Instance ID.
- opaque_ptr_ptr: Pointer to the destination opaque buffer pointer.
- opaque_length_ptr: Pointer to the destination opaque buffer length.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_PARAMETER: The index is out of range.
- NX_LWM2M_BAD_ENCODING: The resource is not a multiple resource, or the resource value is not an Opaque value.
nx_lwm2m_resource_multiple_get_string
Get the value of a String Multiple Resource Instance
Prototype
UINT nx_lwm2m_resource_multiple_get_string(
const NX_LWM2M_RESOURCE *value,
int index,
NX_LWM2M_ID *instance_id_ptr,
const CHAR **string_ptr_ptr,
UINT *string_length_ptr);
Description
The service retrieves the value of a String Resource Instance from a Multiple Resource.
Parameters
- value: Pointer to the Multiple Resource value description.
- index: Index of the Instance to retrieve in the Resource value array.
- instance_id_ptr: Pointer to the destination Instance ID.
- string_ptr_ptr: Pointer to the destination string pointer.
- string_length_ptr: Pointer to the destination string length. Can be NULL if the string is null-terminated.
Return Values
- NX_SUCCESS: Successful operation.
- NX_LWM2M_BAD_PARAMETER: The index is out of range.
- NX_LWM2M_BAD_ENCODING: The resource is not a multiple resource, or the instance value is not a String value.