Soletta™ Framework
|
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... | |
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
uint16_t sol_lwm2m_object::api_version |
API version.
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.
user_data | The data provided during sol_lwm2m_client_new(). |
client | The LWM2M client. |
istance_id | The instance ID that is being created. |
instance_data | The pointer where the instance data should be stored. |
payload | The object's initial content. |
int(* sol_lwm2m_object::del)(void *instance_data, void *user_data, struct sol_lwm2m_client *client, uint16_t instance_id) |
Deletes an object instance.
instance_data | The instance data to be freed. |
used_data | The data provided during sol_lwm2m_client_new(). |
client | The LWM2M client. |
instance_id | The instance ID that is being deleted. |
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.
instance_data | The instance data. |
user_data | The data provided during sol_lwm2m_client_new(). |
client | The LWM2M client. |
instance_id | The instance id. |
res_id | The resource that should be executed. |
args | The arguments of the execute operation. |
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.
instance_data | The instance data. |
user_data | The data provided during sol_lwm2m_client_new(). |
client | The LWM2M client. |
instance_id | The instance id. |
res_id | The resource that should be read. |
res | The resource content, it should be set using 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.
instance_data | The instance data. |
user_data | The data provided during sol_lwm2m_client_new(). |
client | The LWM2M client. |
instance_id | The instance id. |
res_id | The resource id that is being written. |
res | The resource content. |
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.
instance_data | The instance data. |
user_data | The data provided during sol_lwm2m_client_new(). |
client | The LWM2M client. |
instance_id | The instance id. |
tlvs | A vector of sol_lwm2m_tlv |