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
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions

Routines that handle the LWM2M protocol. More...

Modules

 LWM2M Bootstrap Server
 Routines to create Bootstrap Servers talking the LWM2M protocol.
 
 LWM2M Client
 Routines to create Clients talking the LWM2M protocol.
 
 LWM2M Server
 Routines to create Servers talking the LWM2M protocol.
 

Data Structures

struct  sol_lwm2m_payload
 A payload received from the network used to create a LWM2M object instance. More...
 
struct  sol_lwm2m_resource
 Struct that represents a LWM2M resource. More...
 
struct  sol_lwm2m_security_psk
 Struct that represents a Pre-Shared Key (PSK). More...
 
struct  sol_lwm2m_security_rpk
 Struct that represents a Raw Public Key (RPK) pair. More...
 
struct  sol_lwm2m_tlv
 Struct that represents TLV data. More...
 

Macros

#define SOL_LWM2M_DEFAULT_SERVER_PORT_COAP   (5683)
 Macro that defines the default port for a NoSec LWM2M server. More...
 
#define SOL_LWM2M_DEFAULT_SERVER_PORT_DTLS   (5684)
 Macro that defines the default port for a DTLS-secured LWM2M server. More...
 
#define SOL_LWM2M_RESOURCE_INIT(ret_value_, resource_, id_, type_, resource_len_, data_type_,...)
 Convinent macro to initialize a LWM2M resource. More...
 
#define SOL_LWM2M_RESOURCE_SINGLE_INIT(ret_value_, resource_, id_, data_type_, value_)
 A helper macro to init SINGLE resources. More...
 
#define SOL_LWM2M_RESOURCE_SINGLE_INT_INIT(ret_value_, resource_, id_, value_)
 A helper macro to init int resources. More...
 

Typedefs

typedef struct
sol_lwm2m_client_object 
sol_lwm2m_client_object
 A handle of a client's object. More...
 
typedef struct sol_lwm2m_payload sol_lwm2m_payload
 A payload received from the network used to create a LWM2M object instance. More...
 
typedef struct sol_lwm2m_resource sol_lwm2m_resource
 Struct that represents a LWM2M resource. More...
 
typedef struct
sol_lwm2m_security_psk 
sol_lwm2m_security_psk
 Struct that represents a Pre-Shared Key (PSK). More...
 
typedef struct
sol_lwm2m_security_rpk 
sol_lwm2m_security_rpk
 Struct that represents a Raw Public Key (RPK) pair. More...
 
typedef struct sol_lwm2m_tlv sol_lwm2m_tlv
 Struct that represents TLV data. More...
 

Enumerations

enum  sol_lwm2m_acl_rights {
  SOL_LWM2M_ACL_NONE = 0, SOL_LWM2M_ACL_READ = 1, SOL_LWM2M_ACL_WRITE = 2, SOL_LWM2M_ACL_EXECUTE = 4,
  SOL_LWM2M_ACL_DELETE = 8, SOL_LWM2M_ACL_CREATE = 16, SOL_LWM2M_ACL_ALL = 31
}
 Enum that represents the Access Control Rights. More...
 
enum  sol_lwm2m_binding_mode {
  SOL_LWM2M_BINDING_MODE_U, SOL_LWM2M_BINDING_MODE_UQ, SOL_LWM2M_BINDING_MODE_S, SOL_LWM2M_BINDING_MODE_SQ,
  SOL_LWM2M_BINDING_MODE_US, SOL_LWM2M_BINDING_MODE_UQS, SOL_LWM2M_BINDING_MODE_UNKNOWN = -1
}
 LWM2M Client binding mode. More...
 
enum  sol_lwm2m_content_type { SOL_LWM2M_CONTENT_TYPE_TEXT = 1541, SOL_LWM2M_CONTENT_TYPE_OPAQUE = 1544, SOL_LWM2M_CONTENT_TYPE_TLV = 1542, SOL_LWM2M_CONTENT_TYPE_JSON = 1543 }
 Enum that represents a LWM2M response/request content type. More...
 
enum  sol_lwm2m_resource_data_type {
  SOL_LWM2M_RESOURCE_DATA_TYPE_STRING, SOL_LWM2M_RESOURCE_DATA_TYPE_INT, SOL_LWM2M_RESOURCE_DATA_TYPE_FLOAT, SOL_LWM2M_RESOURCE_DATA_TYPE_BOOL,
  SOL_LWM2M_RESOURCE_DATA_TYPE_OPAQUE, SOL_LWM2M_RESOURCE_DATA_TYPE_TIME, SOL_LWM2M_RESOURCE_DATA_TYPE_OBJ_LINK, SOL_LWM2M_RESOURCE_DATA_TYPE_NONE = -1
}
 Enum that represents a LWM2M resource data type. More...
 
enum  sol_lwm2m_resource_type { SOL_LWM2M_RESOURCE_TYPE_SINGLE, SOL_LWM2M_RESOURCE_TYPE_MULTIPLE, SOL_LWM2M_RESOURCE_TYPE_UNKNOWN = -1 }
 Enum data represents if an sol_lwm2m_resource is an array or not. More...
 
enum  sol_lwm2m_security_mode { SOL_LWM2M_SECURITY_MODE_PRE_SHARED_KEY = 0, SOL_LWM2M_SECURITY_MODE_RAW_PUBLIC_KEY = 1, SOL_LWM2M_SECURITY_MODE_CERTIFICATE = 2, SOL_LWM2M_SECURITY_MODE_NO_SEC = 3 }
 Enum that represents the UDP Security Mode. More...
 
enum  sol_lwm2m_tlv_type { SOL_LWM2M_TLV_TYPE_OBJECT_INSTANCE = 0, SOL_LWM2M_TLV_TYPE_RESOURCE_INSTANCE = 64, SOL_LWM2M_TLV_TYPE_MULTIPLE_RESOURCES = 128, SOL_LWM2M_TLV_TYPE_RESOURCE_WITH_VALUE = 192 }
 Enum that represents the TLV type. More...
 

Functions

int sol_lwm2m_client_object_get_id (const struct sol_lwm2m_client_object *object, uint16_t *id)
 Gets the object id. More...
 
const struct sol_ptr_vectorsol_lwm2m_client_object_get_instances (const struct sol_lwm2m_client_object *object)
 Gets the instances of a given object. More...
 
int sol_lwm2m_parse_tlv (const struct sol_str_slice content, struct sol_vector *tlv_values)
 Parses a binary content into TLV. More...
 
void sol_lwm2m_resource_clear (struct sol_lwm2m_resource *resource)
 Clears a sol_lwm2m_resource. More...
 
int sol_lwm2m_resource_init (struct sol_lwm2m_resource *resource, uint16_t id, enum sol_lwm2m_resource_type type, uint16_t resource_len, enum sol_lwm2m_resource_data_type data_type,...)
 Initializes a LWM2M resource. More...
 
int sol_lwm2m_resource_init_vector (struct sol_lwm2m_resource *resource, uint16_t id, enum sol_lwm2m_resource_data_type data_type, struct sol_vector *res_instances)
 Initializes a LWM2M resource of type multiple using a sol_vector. More...
 
void sol_lwm2m_tlv_clear (struct sol_lwm2m_tlv *tlv)
 Clear a TLV. More...
 
int sol_lwm2m_tlv_get_bool (struct sol_lwm2m_tlv *tlv, bool *value)
 Converts an TLV value to boolean value. More...
 
int sol_lwm2m_tlv_get_bytes (struct sol_lwm2m_tlv *tlv, struct sol_buffer *buf)
 Get TLV content is plain bytes. More...
 
int sol_lwm2m_tlv_get_float (struct sol_lwm2m_tlv *tlv, double *value)
 Converts an TLV value to float value. More...
 
int sol_lwm2m_tlv_get_int (struct sol_lwm2m_tlv *tlv, int64_t *value)
 Converts an TLV value to int value. More...
 
int sol_lwm2m_tlv_get_obj_link (struct sol_lwm2m_tlv *tlv, uint16_t *object_id, uint16_t *instance_id)
 Converts an TLV value to object link. More...
 
void sol_lwm2m_tlv_list_clear (struct sol_vector *tlvs)
 Clears an TLV array. More...
 

Detailed Description

Routines that handle the LWM2M protocol.

Supported features:

Unsupported features for now:

Warning
Experimental API. Changes are expected in future releases.

Macro Definition Documentation

#define SOL_LWM2M_DEFAULT_SERVER_PORT_COAP   (5683)

Macro that defines the default port for a NoSec LWM2M server.

Examples:
/src/samples/coap/lwm2m-server.c.

Referenced by main().

#define SOL_LWM2M_DEFAULT_SERVER_PORT_DTLS   (5684)

Macro that defines the default port for a DTLS-secured LWM2M server.

Examples:
/src/samples/coap/lwm2m-server.c.

Referenced by main().

#define SOL_LWM2M_RESOURCE_INIT (   ret_value_,
  resource_,
  id_,
  type_,
  resource_len_,
  data_type_,
  ... 
)
Value:
do { \
(ret_value_) = sol_lwm2m_resource_init((resource_), (id_), (type_), (resource_len_), (data_type_), __VA_ARGS__); \
} while (0)
uint16_t api_version
Definition: sol-http.h:181
int sol_lwm2m_resource_init(struct sol_lwm2m_resource *resource, uint16_t id, enum sol_lwm2m_resource_type type, uint16_t resource_len, enum sol_lwm2m_resource_data_type data_type,...)
Initializes a LWM2M resource.
#define SOL_SET_API_VERSION(expression)
This macro will cope with SOL_NO_API_VERSION and allows easy declaration of api_version fields...
Definition: sol-mainloop.h:660
#define SOL_LWM2M_RESOURCE_API_VERSION
Definition: sol-lwm2m.h:357

Convinent macro to initialize a LWM2M resource.

This macro will first set the LWM2M resource api version then call sol_lwm2m_resource_init().

Parameters
ret_value_The return value of sol_lwm2m_resource_init()
resource_The resource to be initialized.
id_The resource id.
type_The resource type.
resource_len_The resource data size.
data_type_The resource data type.
...The LWM2M resource data, respecting the table according to the resource type.
See Also
sol_lwm2m_resource_init()
#define SOL_LWM2M_RESOURCE_SINGLE_INIT (   ret_value_,
  resource_,
  id_,
  data_type_,
  value_ 
)
Value:
do { \
(ret_value_) = sol_lwm2m_resource_init((resource_), (id_), SOL_LWM2M_RESOURCE_TYPE_SINGLE, 1, (data_type_), value_); \
} while (0)
uint16_t api_version
Definition: sol-http.h:181
int sol_lwm2m_resource_init(struct sol_lwm2m_resource *resource, uint16_t id, enum sol_lwm2m_resource_type type, uint16_t resource_len, enum sol_lwm2m_resource_data_type data_type,...)
Initializes a LWM2M resource.
The resource type has single value.
Definition: sol-lwm2m.h:271
#define SOL_SET_API_VERSION(expression)
This macro will cope with SOL_NO_API_VERSION and allows easy declaration of api_version fields...
Definition: sol-mainloop.h:660
#define SOL_LWM2M_RESOURCE_API_VERSION
Definition: sol-lwm2m.h:357

A helper macro to init SINGLE resources.

Parameters
ret_value_The return value of sol_lwm2m_resource_init()
resource_The resource to be initialized.
id_The resource id.
data_type_The resource data type.
value_The LWM2M resource data, respecting the table according to the resource type.
See Also
sol_lwm2m_resource_init()
Examples:
/src/samples/coap/lwm2m-bs-server.c, /src/samples/coap/lwm2m-client.c, and /src/samples/coap/lwm2m-server.c.

Referenced by create_location_obj(), delete_all_cb(), read_location_obj(), read_security_obj(), read_server_obj(), write_sec_one_cb(), and write_server_one_cb().

#define SOL_LWM2M_RESOURCE_SINGLE_INT_INIT (   ret_value_,
  resource_,
  id_,
  value_ 
)
Value:
do { \
(ret_value_) = sol_lwm2m_resource_init((resource_), (id_), SOL_LWM2M_RESOURCE_TYPE_SINGLE, 1, SOL_LWM2M_RESOURCE_DATA_TYPE_INT, SOL_TYPE_CHECK(int64_t, (value_))); \
} while (0)
uint16_t api_version
Definition: sol-http.h:181
int sol_lwm2m_resource_init(struct sol_lwm2m_resource *resource, uint16_t id, enum sol_lwm2m_resource_type type, uint16_t resource_len, enum sol_lwm2m_resource_data_type data_type,...)
Initializes a LWM2M resource.
The resource type has single value.
Definition: sol-lwm2m.h:271
The resource value is an integer.
Definition: sol-lwm2m.h:237
#define SOL_SET_API_VERSION(expression)
This macro will cope with SOL_NO_API_VERSION and allows easy declaration of api_version fields...
Definition: sol-mainloop.h:660
#define SOL_TYPE_CHECK(type, value)
Macro to check type of given value.
Definition: sol-types.h:95
#define SOL_LWM2M_RESOURCE_API_VERSION
Definition: sol-lwm2m.h:357

A helper macro to init int resources.

This macro will automatically cast the int value to an int64_t, thus avoiding some problems that may happen depending on the platform. The most common case to use this macro is when one wants to set a resource using a literal number. Example:

//Some code...
SOL_LWM2M_RESOUCE_INT_INIT(ret_value, &my_resource, resource_id, 10);
return ret_value;
//More code...
Parameters
ret_value_The return value of sol_lwm2m_resource_init()
resource_The resource to be initialized.
id_The resource id.
value_The int value
See Also
SOL_LWM2M_RESOURCE_INIT()
sol_lwm2m_resource_init()
SOL_TYPE_CHECK()
Note
This can be safely used for SOL_LWM2M_RESOURCE_DATA_TYPE_TIME
Examples:
/src/samples/coap/lwm2m-bs-server.c, and /src/samples/coap/lwm2m-client.c.

Referenced by delete_all_cb(), read_access_control_obj(), read_security_obj(), read_server_obj(), write_sec_one_cb(), write_server_one_cb(), and write_servers_cb().

Typedef Documentation

A handle of a client's object.

See Also
sol_lwm2m_client_info_get_objects()

A payload received from the network used to create a LWM2M object instance.

See Also
sol_lwm2m_content_type
struct sol_lwm2m_object::create

Struct that represents a LWM2M resource.

See Also
sol_lwm2m_resource_init()

Struct that represents a Pre-Shared Key (PSK).

A sol_vector holding elements of this type is used by the LWM2M Server and LWM2M Bootstrap Server to keep a list of known Clients' Pre-Shared Keys.

See Also
sol_lwm2m_server_new()
sol_lwm2m_bootstrap_server_new()

Struct that represents a Raw Public Key (RPK) pair.

An element of this type is used by the LWM2M Server and LWM2M Bootstrap Server to store its own Private and Public keys.

See Also
sol_lwm2m_server_new()
sol_lwm2m_bootstrap_server_new()
typedef struct sol_lwm2m_tlv sol_lwm2m_tlv

Struct that represents TLV data.

The binary format TLV (Type-Length-Value) is used to represent an array of values or a singular value, using a compact binary representation.
It is needed by "Read" and "Write" operations on Object Instance(s) or on a Resource which supports multiple instances (Resource Instances).

The format is an array of the following byte sequence, where each array entry represents an Object Instance, Resource or Resource Instance:

Field Format and Length Description Implemented as
Type 8-bits masked field Bits 7-6: Indicates the type of identifier.
Bits 5-0: All have special meanings as well.
enum sol_lwm2m_tlv.type
Identifier 8-bit or 16-bit unsigned integer
as indicated by Bit 5 from Type
Object Instance, Resource or Resource Instance ID uint16_t sol_lwm2m_tlv.id
Length 0-24bits unsigned integer
as indicated by Bits 4-3 from Type
Length of the following field in bytes size_t sol_buffer.capacity
Value Sequence of bytes of size=Length Value of the tag.
The actual format depends on the Resource's data type
See Also
sol_lwm2m_resource_data_type
void * sol_lwm2m_tlv.content->data
See Also
sol_lwm2m_parse_tlv()

Enumeration Type Documentation

Enum that represents the Access Control Rights.

Setting each bit means the LWM2M Server has the access right for that operation.

Enumerator
SOL_LWM2M_ACL_NONE 

No bit is set (No access rights for any operation)

SOL_LWM2M_ACL_READ 

1st lsb: R (Read, Observe, Discover, Write Attributes)

SOL_LWM2M_ACL_WRITE 

2nd lsb: W (Write)

SOL_LWM2M_ACL_EXECUTE 

3rd lsb: E (Execute)

SOL_LWM2M_ACL_DELETE 

4th lsb: D (Delete)

SOL_LWM2M_ACL_CREATE 

5th lsb: C (Create)

SOL_LWM2M_ACL_ALL 

All 5 lsbs: Full Access Rights.

LWM2M Client binding mode.

A LWM2M server may support multiple forms of binding. The binding mode is requested by a client during its registration.

In Queue binding mode a client flags to the server that it may not be available for communication all the time, thus the server must wait until it receives a heartbeat from the client until it can send requests. The queue binding mode is useful, because the client may enter in deep sleep and save battery and only wake up in certain times.

Note
The default binding mode is SOL_LWM2M_BINDING_MODE_U and is the only one supported right know.
See Also
sol_lwm2m_client_info_get_binding_mode()
Enumerator
SOL_LWM2M_BINDING_MODE_U 

Indicates that the client is reacheable all the time and all the communication must be done using UDP.

SOL_LWM2M_BINDING_MODE_UQ 

Indicate that the client is using Queued UDP binding and all the communication must be done using UDP.

SOL_LWM2M_BINDING_MODE_S 

Indicates that the client is reacheable all the time and all the communication must be done using SMS.

SOL_LWM2M_BINDING_MODE_SQ 

Indicates that the client is using Queued SMS binding and all the communication must be done using SMS.

SOL_LWM2M_BINDING_MODE_US 

Indicates that the client is using UDP and SMS binding.

When the server sends an UDP request the client must send the response using UDP. When the server sends a SMS request the client must send the response using SMS.

SOL_LWM2M_BINDING_MODE_UQS 

Indicates that the client using Queued SMS and UDP binding.

When the server sends an UDP request the client must send the response using UDP. When the server sends a SMS request the client must send the response using SMS.

SOL_LWM2M_BINDING_MODE_UNKNOWN 

It was not possible to determine the client binding.

Enum that represents a LWM2M response/request content type.

Enumerator
SOL_LWM2M_CONTENT_TYPE_TEXT 

The content type message is pure text.

SOL_LWM2M_CONTENT_TYPE_OPAQUE 

The content type of the message is undeterminated, in other words, it is an array of bytes.

SOL_LWM2M_CONTENT_TYPE_TLV 

The content type of the message is in TLV format.

SOL_LWM2M_CONTENT_TYPE_JSON 

The content type of the message is in JSON.

JSON content types are not supported right now.

Enum that represents a LWM2M resource data type.

See Also
sol_lwm2m_resource
Enumerator
SOL_LWM2M_RESOURCE_DATA_TYPE_STRING 

The resource value is a string.

SOL_LWM2M_RESOURCE_DATA_TYPE_INT 

The resource value is an integer.

SOL_LWM2M_RESOURCE_DATA_TYPE_FLOAT 

The resource value is a float.

SOL_LWM2M_RESOURCE_DATA_TYPE_BOOL 

The resource value is a boolean.

SOL_LWM2M_RESOURCE_DATA_TYPE_OPAQUE 

The resource value is opaque.

SOL_LWM2M_RESOURCE_DATA_TYPE_TIME 

The resource value is a timestamp (Unix time).

SOL_LWM2M_RESOURCE_DATA_TYPE_OBJ_LINK 

The resource value is an object link.

SOL_LWM2M_RESOURCE_DATA_TYPE_NONE 

The resource value is undeterminated.

Enum data represents if an sol_lwm2m_resource is an array or not.

Enumerator
SOL_LWM2M_RESOURCE_TYPE_SINGLE 

The resource type has single value.

SOL_LWM2M_RESOURCE_TYPE_MULTIPLE 

The resource type is an array.

SOL_LWM2M_RESOURCE_TYPE_UNKNOWN 

The resource type is unknown.

Enum that represents the UDP Security Mode.

Note
Certificate mode is not supported yet.
Enumerator
SOL_LWM2M_SECURITY_MODE_PRE_SHARED_KEY 

Pre-Shared Key security mode with Cipher Suite TLS_PSK_WITH_AES_128_CCM_8 In this case, the following Resource IDs have to be filled as well: /3 "Public Key or Identity": PSK Identity [16 bytes; UTF-8 String]; /5 "Secret Key": PSK [128-bit AES Key; 16 Opaque bytes];.

SOL_LWM2M_SECURITY_MODE_RAW_PUBLIC_KEY 

Raw Public Key security mode with Cipher Suite TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 In this case, the following Resource IDs have to be filled as well: /3 "Public Key or Identity": Client's Raw Public Key [2x256-bit ECC key (one for each ECC Coordinate); 64 Opaque bytes]; /4 "Server Public Key or Identity Resource": [Expected] Server's Raw Public Key [2x256-bit ECC key (one for each ECC Coordinate); 64 Opaque bytes]; /5 "Secret Key": Client's Private Key [256-bit ECC key; 32 Opaque bytes];.

SOL_LWM2M_SECURITY_MODE_CERTIFICATE 

Certificate security mode with Cipher Suite TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 In this case, the following Resource IDs have to be filled as well: /3 "Public Key or Identity": X.509v3 Certificate [Opaque]; /4 "Server Public Key or Identity Resource": [Expected] Server's X.509v3 Certificate [Opaque]; /5 "Secret Key": Client's Private Key [256-bit ECC key; 32 Opaque bytes];.

SOL_LWM2M_SECURITY_MODE_NO_SEC 

No security ("NoSec") mode (CoAP without DTLS)

Enum that represents the TLV type.

See Also
sol_lwm2m_tlv
Enumerator
SOL_LWM2M_TLV_TYPE_OBJECT_INSTANCE 

The TLV represents an object instance.

SOL_LWM2M_TLV_TYPE_RESOURCE_INSTANCE 

The TLV represents a resource instance.

SOL_LWM2M_TLV_TYPE_MULTIPLE_RESOURCES 

The TLV is composed of multiple resources.

SOL_LWM2M_TLV_TYPE_RESOURCE_WITH_VALUE 

The TLV is a resource.

Function Documentation

int sol_lwm2m_client_object_get_id ( const struct sol_lwm2m_client_object object,
uint16_t *  id 
)

Gets the object id.

Parameters
objectThe LWM2M object to get the id.
idThe object id to be filled.
Returns
0 success, negative errno on error.
Examples:
/src/samples/coap/lwm2m-server.c.

Referenced by get_location_object_status().

const struct sol_ptr_vector* sol_lwm2m_client_object_get_instances ( const struct sol_lwm2m_client_object object)

Gets the instances of a given object.

Parameters
objectThe LWM2M object to get the instances.
Returns
An array of uint16_t or NULL on error.
Note
Be advised that it's not recommended to store object instances pointers, because they might be deleted by other LWM2M servers, thus removed from the returned list.
Examples:
/src/samples/coap/lwm2m-server.c.

Referenced by get_location_object_status().

int sol_lwm2m_parse_tlv ( const struct sol_str_slice  content,
struct sol_vector tlv_values 
)

Parses a binary content into TLV.

Parameters
contentA binary data that contains the TLV.
tlv_valuesAn array of sol_lwm2m_tlv that will be filled.
Returns
0 on success, -errno on error.
Examples:
/src/samples/coap/lwm2m-server.c.

Referenced by location_changed_cb().

void sol_lwm2m_resource_clear ( struct sol_lwm2m_resource resource)
int sol_lwm2m_resource_init ( struct sol_lwm2m_resource resource,
uint16_t  id,
enum sol_lwm2m_resource_type  type,
uint16_t  resource_len,
enum sol_lwm2m_resource_data_type  data_type,
  ... 
)

Initializes a LWM2M resource.

This function makes it easier to init a LWM2M resource, it will set the proper fields and fill its data. Note that the last argument type varies with the resource type and one must follow the table below.

Resource type Last argument type
SOL_LWM2M_RESOURCE_DATA_TYPE_STRING struct sol_blob *
SOL_LWM2M_RESOURCE_DATA_TYPE_INT int64_t
SOL_LWM2M_RESOURCE_DATA_TYPE_FLOAT double
SOL_LWM2M_RESOURCE_DATA_TYPE_BOOL bool
SOL_LWM2M_RESOURCE_DATA_TYPE_OPAQUE struct sol_blob *
SOL_LWM2M_RESOURCE_DATA_TYPE_TIME int64_t
SOL_LWM2M_RESOURCE_DATA_TYPE_OBJ_LINK uint16_t, uint16_t
Parameters
resourceThe resource to be initialized.
idThe resource id.
typeThe resource type.
resource_lenThe resource data size.
data_typeThe resource data type.
...The LWM2M resource data, respecting the table according to the resource data type.
Returns
0 on success, negative errno on error.
See Also
sol_lwm2m_resource_clear()
SOL_LWM2M_RESOURCE_INIT()
Note
The LWM2M resource api_version must be set, before calling this function.
int sol_lwm2m_resource_init_vector ( struct sol_lwm2m_resource resource,
uint16_t  id,
enum sol_lwm2m_resource_data_type  data_type,
struct sol_vector res_instances 
)

Initializes a LWM2M resource of type multiple using a sol_vector.

This function makes it easier to init a LWM2M resource of type multiple, dynamically setting the amount of Resource Instances desired. The last argument is a sol_vector holding elements of type sol_lwm2m_resource_data, each element carrying the Resource Instance ID and related Resource Instance value.

Parameters
resourceThe resource to be initialized.
idThe resource id.
data_typeThe resource data type.
res_instancesThe list of Resource Instances. Each Resource Instance value must respect the table according to the resource data type.
Returns
0 on success, negative errno on error.
See Also
sol_lwm2m_resource_clear()
sol_lwm2m_resource_init()
Note
The LWM2M resource api_version must be set, before calling this function.
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by read_access_control_obj().

void sol_lwm2m_tlv_clear ( struct sol_lwm2m_tlv tlv)

Clear a TLV.

Parameters
tlvThe TLV the be cleared.
int sol_lwm2m_tlv_get_bool ( struct sol_lwm2m_tlv tlv,
bool *  value 
)

Converts an TLV value to boolean value.

Parameters
tlvThe tlv data.
valueThe converted value.
Returns
0 on success, -errno on error.
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by create_security_obj(), and write_security_tlv().

int sol_lwm2m_tlv_get_bytes ( struct sol_lwm2m_tlv tlv,
struct sol_buffer buf 
)

Get TLV content is plain bytes.

Parameters
tlvThe tlv data.
bufThe buffer to store the content.
Returns
0 on succes, -errno on error.
Examples:
/src/samples/coap/lwm2m-client.c, and /src/samples/coap/lwm2m-server.c.

Referenced by create_location_obj(), create_security_obj(), create_server_obj(), location_changed_cb(), write_security_tlv(), and write_server_tlv().

int sol_lwm2m_tlv_get_float ( struct sol_lwm2m_tlv tlv,
double *  value 
)

Converts an TLV value to float value.

Parameters
tlvThe tlv data.
valueThe converted value.
Returns
0 on success, -errno on error.
int sol_lwm2m_tlv_get_int ( struct sol_lwm2m_tlv tlv,
int64_t *  value 
)

Converts an TLV value to int value.

Parameters
tlvThe tlv data.
valueThe converted value.
Returns
0 on success, -errno on error.
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by create_access_control_obj(), create_location_obj(), create_security_obj(), create_server_obj(), write_access_control_tlv(), write_or_create_acl(), write_security_tlv(), and write_server_tlv().

int sol_lwm2m_tlv_get_obj_link ( struct sol_lwm2m_tlv tlv,
uint16_t *  object_id,
uint16_t *  instance_id 
)

Converts an TLV value to object link.

Parameters
tlvThe tlv data.
object_idThe object id.
instance_idthe instance id.
Returns
0 on success, -errno on error.
void sol_lwm2m_tlv_list_clear ( struct sol_vector tlvs)

Clears an TLV array.

Parameters
tlvsThe TLVs array to be cleared.
Examples:
/src/samples/coap/lwm2m-server.c.

Referenced by location_changed_cb().