Loading...
Searching...
No Matches
Common LwM2M Object functionalities

Common functionalities to interact with LwM2M objects. More...

Detailed Description

Common functionalities to interact with LwM2M objects.

Files

file  common.h
 

Functions

static lwm2m_object_t * lwm2m_get_object_by_id (lwm2m_client_data_t *client_data, uint16_t id)
 Get the handle for an object type of the client by its ID.
 
int lwm2m_get_string (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, char *out, size_t *out_len)
 Get the value of a string-type resource, specified by uri.
 
int lwm2m_get_string_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, char *out, size_t *out_len)
 Get the value of a string-type resource, specified by a path path.
 
int lwm2m_get_opaque (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, uint8_t *out, size_t *out_len)
 Get the value of an opaque-type resource, specified by uri.
 
int lwm2m_get_opaque_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, uint8_t *out, size_t *out_len)
 Get the value of an opaque-type resource, specified by a path path.
 
int lwm2m_get_int (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, int64_t *out)
 Get the value of an integer-type resource, specified by uri.
 
int lwm2m_get_int_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, int64_t *out)
 Get the value of an integer-type resource, specified by a path path.
 
int lwm2m_get_float (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, double *out)
 Get the value of an float-type resource, specified by uri.
 
int lwm2m_get_float_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, double *out)
 Get the value of an float-type resource, specified by a path path.
 
int lwm2m_get_bool (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, bool *out)
 Get the value of an boolean-type resource, specified by uri.
 
int lwm2m_get_bool_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, bool *out)
 Get the value of an float-type resource, specified by a path path.
 
int lwm2m_get_objlink (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, uint16_t *object_id_out, uint16_t *instance_id_out)
 Get the value of an objectlink-type resource, specified by uri.
 
int lwm2m_get_objlink_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, uint16_t *object_id_out, uint16_t *instance_id_out)
 Get the value of an objectlink-type resource, specified by a path path.
 
int lwm2m_set_string (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, char *val, size_t val_len)
 Set the value of a string-type resource, specified by uri.
 
int lwm2m_set_string_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, char *val, size_t val_len)
 Set the value of a string-type resource, specified by a path path.
 
int lwm2m_set_opaque (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, uint8_t *val, size_t val_len)
 Set the value of an opaque-type resource, specified by uri.
 
int lwm2m_set_opaque_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, uint8_t *val, size_t val_len)
 Set the value of an opaque-type resource, specified by a path path.
 
int lwm2m_set_int (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, int64_t val)
 Set the value of an integer-type resource, specified by uri.
 
int lwm2m_set_int_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, int64_t val)
 Set the value of an integer-type resource, specified by a path path.
 
int lwm2m_set_float (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, double val)
 Set the value of an float-type resource, specified by uri.
 
int lwm2m_set_float_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, double val)
 Set the value of an float-type resource, specified by a path path.
 
int lwm2m_set_bool (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, bool val)
 Set the value of an boolean-type resource, specified by uri.
 
int lwm2m_set_bool_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, bool val)
 Set the value of an float-type resource, specified by a path path.
 
int lwm2m_set_objlink (lwm2m_client_data_t *client_data, const lwm2m_uri_t *uri, uint16_t object_id_in, uint16_t instance_id_in)
 Set the value of an objectlink-type resource, specified by uri.
 
int lwm2m_set_objlink_by_path (lwm2m_client_data_t *client_data, const char *path, size_t path_len, uint16_t object_id_in, uint16_t instance_id_in)
 Set the value of an objectlink-type resource, specified by a path path.
 

Function Documentation

◆ lwm2m_get_bool()

int lwm2m_get_bool ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
bool *  out 
)

Get the value of an boolean-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to get.
[out]outPointer where to place the value.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALwhen the resource cannot be read or has an unexpected type

◆ lwm2m_get_bool_by_path()

int lwm2m_get_bool_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
bool *  out 
)

Get the value of an float-type resource, specified by a path path.

Convenience function to call lwm2m_get_bool with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to get.
[in]path_lenLength of path.
[out]outPointer where to place the value.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALif the path is malformed, the resource cannot be read or has an unexpected type

◆ lwm2m_get_float()

int lwm2m_get_float ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
double *  out 
)

Get the value of an float-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to get.
[out]outPointer where to place the value.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALwhen the resource cannot be read or has an unexpected type

◆ lwm2m_get_float_by_path()

int lwm2m_get_float_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
double *  out 
)

Get the value of an float-type resource, specified by a path path.

Convenience function to call lwm2m_get_float with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to get.
[in]path_lenLength of path.
[out]outPointer where to place the value.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALif the path is malformed, the resource cannot be read or has an unexpected type

◆ lwm2m_get_int()

int lwm2m_get_int ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
int64_t *  out 
)

Get the value of an integer-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to get.
[out]outPointer where to place the value.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALwhen the resource cannot be read or has an unexpected type

◆ lwm2m_get_int_by_path()

int lwm2m_get_int_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
int64_t *  out 
)

Get the value of an integer-type resource, specified by a path path.

Convenience function to call lwm2m_get_int with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to get.
[in]path_lenLength of path.
[out]outPointer where to place the value.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALif the path is malformed, the resource cannot be read or has an unexpected type

◆ lwm2m_get_object_by_id()

static lwm2m_object_t * lwm2m_get_object_by_id ( lwm2m_client_data_t client_data,
uint16_t  id 
)
inlinestatic

Get the handle for an object type of the client by its ID.

Note
This is not a single instance of a given object, but the object type representation.
Parameters
[in]client_dataPointer to the client data
[in]idID of the object to get
Returns
Pointer to the object type

Definition at line 41 of file common.h.

◆ lwm2m_get_objlink()

int lwm2m_get_objlink ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
uint16_t *  object_id_out,
uint16_t *  instance_id_out 
)

Get the value of an objectlink-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL) && (object_id_out != NULL) && (instance_id_out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to get.
[out]object_id_outPointer where to place the object ID.
[out]instance_id_outPointer where to place the instance ID.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALwhen the resource cannot be read or has an unexpected type

◆ lwm2m_get_objlink_by_path()

int lwm2m_get_objlink_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
uint16_t *  object_id_out,
uint16_t *  instance_id_out 
)

Get the value of an objectlink-type resource, specified by a path path.

Convenience function to call lwm2m_get_objlink with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL) && (object_id_out != NULL) && (instance_id_out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to get.
[in]path_lenLength of path.
[out]object_id_outPointer where to place the object ID.
[out]instance_id_outPointer where to place the instance ID.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALif the path is malformed, the resource cannot be read or has an unexpected type

◆ lwm2m_get_opaque()

int lwm2m_get_opaque ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
uint8_t *  out,
size_t *  out_len 
)

Get the value of an opaque-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to get.
[out]outBuffer to place the resource in. Must not be NULL.
[in,out]out_lenAvailable space in out, returns the amount of read bytes.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALwhen the resource cannot be read or has an unexpected type

◆ lwm2m_get_opaque_by_path()

int lwm2m_get_opaque_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
uint8_t *  out,
size_t *  out_len 
)

Get the value of an opaque-type resource, specified by a path path.

Convenience function to call lwm2m_get_opaque with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to get.
[in]path_lenLength of path.
[out]outBuffer to place the resource in. Must not be NULL.
[in,out]out_lenAvailable space in out, returns the amount of read bytes.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALif the path is malformed, the resource cannot be read or has an unexpected type

◆ lwm2m_get_string()

int lwm2m_get_string ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
char *  out,
size_t *  out_len 
)

Get the value of a string-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to get.
[out]outBuffer to place the resource in. Must not be NULL.
[in,out]out_lenAvailable space in out, returns the amount of read bytes.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALwhen the resource cannot be read or has an unexpected type

◆ lwm2m_get_string_by_path()

int lwm2m_get_string_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
char *  out,
size_t *  out_len 
)

Get the value of a string-type resource, specified by a path path.

Convenience function to call lwm2m_get_string with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL) && (out != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to get.
[in]path_lenLength of path.
[out]outBuffer to place the resource in. Must not be NULL.
[in,out]out_lenAvailable space in out, returns the amount of read bytes.
Return values
0on success
-ENOMEMwhen there is not enough space in buffer or can not allocate a data structure
-ENOENTwhen the resource is not found
-EINVALif the path is malformed, the resource cannot be read or has an unexpected type

◆ lwm2m_set_bool()

int lwm2m_set_bool ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
bool  val 
)

Set the value of an boolean-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to set.
[in]valValue to set.
Return values
0on success
-ENOMEMwhen data structure can not be allocated
-ENOENTwhen the resource is not found
-EINVALwhen the value can not be set

◆ lwm2m_set_bool_by_path()

int lwm2m_set_bool_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
bool  val 
)

Set the value of an float-type resource, specified by a path path.

Convenience function to call lwm2m_set_bool with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to set.
[in]path_lenLength of path.
[in]valValue to set.
Return values
0on success
-EINVALwhen the path is malformed, the value can not be set
-ENOENTwhen the resource is not found
-ENOMEMwhen data structure can not be allocated

◆ lwm2m_set_float()

int lwm2m_set_float ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
double  val 
)

Set the value of an float-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to set.
[in]valValue to set.
Return values
0on success
-ENOMEMwhen data structure can not be allocated
-ENOENTwhen the resource is not found
-EINVALwhen the value can not be set

◆ lwm2m_set_float_by_path()

int lwm2m_set_float_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
double  val 
)

Set the value of an float-type resource, specified by a path path.

Convenience function to call lwm2m_set_float with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to set.
[in]path_lenLength of path.
[in]valValue to set.
Return values
0on success
-EINVALwhen the path is malformed, the value can not be set
-ENOENTwhen the resource is not found
-ENOMEMwhen data structure can not be allocated

◆ lwm2m_set_int()

int lwm2m_set_int ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
int64_t  val 
)

Set the value of an integer-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to set.
[in]valValue to set.
Return values
0on success
-ENOMEMwhen data structure can not be allocated
-ENOENTwhen the resource is not found
-EINVALwhen the value can not be set

◆ lwm2m_set_int_by_path()

int lwm2m_set_int_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
int64_t  val 
)

Set the value of an integer-type resource, specified by a path path.

Convenience function to call lwm2m_set_int with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to set.
[in]path_lenLength of path.
[in]valValue to set.
Return values
0on success
-EINVALwhen the path is malformed, the value can not be set
-ENOENTwhen the resource is not found
-ENOMEMwhen data structure can not be allocated

◆ lwm2m_set_objlink()

int lwm2m_set_objlink ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
uint16_t  object_id_in,
uint16_t  instance_id_in 
)

Set the value of an objectlink-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to set.
[in]object_id_inObject ID value to set.
[in]instance_id_inInstance ID value to set.
Return values
0on success
-ENOMEMwhen data structure can not be allocated
-ENOENTwhen the resource is not found
-EINVALwhen the value can not be set

◆ lwm2m_set_objlink_by_path()

int lwm2m_set_objlink_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
uint16_t  object_id_in,
uint16_t  instance_id_in 
)

Set the value of an objectlink-type resource, specified by a path path.

Convenience function to call lwm2m_set_objlink with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to set.
[in]path_lenLength of path.
[in]object_id_inObject ID value to set.
[in]instance_id_inInstance ID value to set.
Return values
0on success
-EINVALwhen the path is malformed, the value can not be set
-ENOENTwhen the resource is not found
-ENOMEMwhen data structure can not be allocated

◆ lwm2m_set_opaque()

int lwm2m_set_opaque ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
uint8_t *  val,
size_t  val_len 
)

Set the value of an opaque-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL) && (val != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to set.
[in]valBuffer with the value to set. Must not be NULL.
[in]val_lenLength of val.
Return values
0on success
-ENOMEMwhen data structure can not be allocated
-ENOENTwhen the resource is not found
-EINVALwhen the value can not be set

◆ lwm2m_set_opaque_by_path()

int lwm2m_set_opaque_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
uint8_t *  val,
size_t  val_len 
)

Set the value of an opaque-type resource, specified by a path path.

Convenience function to call lwm2m_set_opaque with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL) && (val != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to set.
[in]path_lenLength of path.
[in]valBuffer with the value to set. Must not be NULL.
[in]val_lenLength of val.
Return values
0on success
-EINVALwhen the path is malformed, the value can not be set
-ENOENTwhen the resource is not found
-ENOMEMwhen data structure can not be allocated

◆ lwm2m_set_string()

int lwm2m_set_string ( lwm2m_client_data_t client_data,
const lwm2m_uri_t *  uri,
char *  val,
size_t  val_len 
)

Set the value of a string-type resource, specified by uri.

Precondition
(client_data != NULL) && (uri != NULL) && (val != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]uriInitialized URI structure specifying the resource to set.
[in]valBuffer with the value to set. Must not be NULL.
[in]val_lenLength of val.
Return values
0on success
-ENOMEMwhen data structure can not be allocated
-ENOENTwhen the resource is not found
-EINVALwhen the value can not be set

◆ lwm2m_set_string_by_path()

int lwm2m_set_string_by_path ( lwm2m_client_data_t client_data,
const char *  path,
size_t  path_len,
char *  val,
size_t  val_len 
)

Set the value of a string-type resource, specified by a path path.

Convenience function to call lwm2m_set_string with a string representing the resource's path.

Precondition
(client_data != NULL) && (path != NULL) && (val != NULL)
Parameters
[in]client_dataPointer to the LwM2M client data.
[in]pathArray containing the path to the resource to set.
[in]path_lenLength of path.
[in]valBuffer with the value to set. Must not be NULL.
[in]val_lenLength of val.
Return values
0on success
-EINVALwhen the path is malformed, the value can not be set
-ENOENTwhen the resource is not found
-ENOMEMwhen data structure can not be allocated