Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Fields
sol_lwm2m_object Struct Reference

A LWM2M object implementation. More...

#include <sol-lwm2m-client.h>

Data Fields

uint16_t api_version
 API version. More...
 
int(* create )(void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, void **instance_data, struct sol_lwm2m_payload payload)
 Creates a new object instance. More...
 
int(* del )(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id)
 Deletes an object instance. More...
 
int(* execute )(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, uint16_t res_id, const struct sol_str_slice args)
 Executes a resource. More...
 
uint16_t id
 The object id. More...
 
int(* read )(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, uint16_t res_id, struct sol_lwm2m_resource *res)
 Reads a resource. More...
 
uint16_t resources_count
 
int(* write_resource )(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, uint16_t res_id, const struct sol_lwm2m_resource *res)
 Writes a resource. More...
 
int(* write_tlv )(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, struct sol_vector *tlvs)
 Writes a resource(s). More...
 

Detailed Description

A LWM2M object implementation.

Every LWM2M client must implement a set of LWM2M objects, This struct is used by the sol-lwm2m to know which objects a LWM2M Client implements.

All the functions in this struct will be called by the sol-lwm2m infra, when the LWM2M server request an operation. For example, when the LWM2M server requests the creation for a LWM2M location object, the create function will be called. When a LWM2M object does not support a certain operation, one must not implement the corresponding method. In order words, if a LWM2M object can't be deleted, the del handle must be ponting to NULL

See Also
sol_lwm2m_client_new()
Examples:
/src/samples/coap/lwm2m-client.c.

Field Documentation

uint16_t sol_lwm2m_object::api_version

API version.

Examples:
/src/samples/coap/lwm2m-client.c.
int(* sol_lwm2m_object::create)(void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, void **instance_data, struct sol_lwm2m_payload payload)

Creates a new object instance.

Parameters
user_dataThe data provided during sol_lwm2m_client_new().
clientThe LWM2M client.
istance_idThe instance ID that is being created.
instance_dataThe pointer where the instance data should be stored.
payloadThe object's initial content.
Returns
0 on success, -errno on error.
int(* sol_lwm2m_object::del)(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id)

Deletes an object instance.

Parameters
instance_dataThe instance data to be freed.
used_dataThe data provided during sol_lwm2m_client_new().
clientThe LWM2M client.
instance_idThe instance ID that is being deleted.
Returns
0 on success or -errno on error.
int(* sol_lwm2m_object::execute)(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, uint16_t res_id, const struct sol_str_slice args)

Executes a resource.

A LWM2M Object resource may be executable. An executable resource means that the LWM2M object instance will initiate some action that was requested by the LWM2M server. As an example, if the LWM2M server wants the client to send an update request, the LWM2M server will send an execute command on the path "/1/AnServerInstanceId/8", this will trigger the LWM2M client, which will send the update request.

Parameters
instance_dataThe instance data.
user_dataThe data provided during sol_lwm2m_client_new().
clientThe LWM2M client.
instance_idThe instance id.
res_idThe resource that should be executed.
argsThe arguments of the execute operation.
Returns
0 on success or -errno on error.
uint16_t sol_lwm2m_object::id

The object id.

int(* sol_lwm2m_object::read)(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, uint16_t res_id, struct sol_lwm2m_resource *res)

Reads a resource.

When the LWM2M server requests to read an object, object instance or a single resource, this function will be triggered. This function will read one resource at time, in case the LWM2M server wants to read an object instance or all instances of an object the LWM2M client infrastructure will call this function several times requesting to read each resource.

Parameters
instance_dataThe instance data.
user_dataThe data provided during sol_lwm2m_client_new().
clientThe LWM2M client.
instance_idThe instance id.
res_idThe resource that should be read.
resThe resource content, it should be set using sol_lwm2m_resource_init()
Returns
0 on success, -ENOENT if the resource is empty, -EINVAL if the resource does not exist or -errno on error.
See Also
sol_lwm2m_resource_init()
uint16_t sol_lwm2m_object::resources_count
int(* sol_lwm2m_object::write_resource)(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, uint16_t res_id, const struct sol_lwm2m_resource *res)

Writes a resource.

When the LWM2M server requests to write a resource and flags that the content type of the request is text, a scalar type or an opaque type, this function will be called.

Parameters
instance_dataThe instance data.
user_dataThe data provided during sol_lwm2m_client_new().
clientThe LWM2M client.
instance_idThe instance id.
res_idThe resource id that is being written.
resThe resource content.
Returns
0 on success or -errno on error.
Note
This function is only called when the LWM2M server explicitly says that the content type of the write operation is a text or an opaque type.
int(* sol_lwm2m_object::write_tlv)(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id, struct sol_vector *tlvs)

Writes a resource(s).

Every time the LWM2M server requests to write a resource or a whole object instance in TLV type, this function will be called. The tlvs arrays contains sol_lwm2m_tlv which is the data that the LWM2M server demands to be written. Since TLV is a binary type, one must call sol_lwm2m_tlv_get_int and friends function to obtain the TLV value.

Parameters
instance_dataThe instance data.
user_dataThe data provided during sol_lwm2m_client_new().
clientThe LWM2M client.
instance_idThe instance id.
tlvsA vector of sol_lwm2m_tlv
Returns
0 on success or -errno on error.
Note
Since TLV does not contains a field to express the data type, it's the user's responsibility to know which function should be used to get the content value.

The documentation for this struct was generated from the following file: