Soletta™ Framework
|
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... | |
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_vector * | sol_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... | |
Routines that handle the LWM2M protocol.
Supported features:
Unsupported features for now:
#define SOL_LWM2M_DEFAULT_SERVER_PORT_COAP (5683) |
Macro that defines the default port for a NoSec LWM2M server.
Referenced by main().
#define SOL_LWM2M_DEFAULT_SERVER_PORT_DTLS (5684) |
Macro that defines the default port for a DTLS-secured LWM2M server.
Referenced by main().
#define SOL_LWM2M_RESOURCE_INIT | ( | ret_value_, | |
resource_, | |||
id_, | |||
type_, | |||
resource_len_, | |||
data_type_, | |||
... | |||
) |
Convinent macro to initialize a LWM2M resource.
This macro will first set the LWM2M resource api version then call sol_lwm2m_resource_init().
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. |
#define SOL_LWM2M_RESOURCE_SINGLE_INIT | ( | ret_value_, | |
resource_, | |||
id_, | |||
data_type_, | |||
value_ | |||
) |
A helper macro to init SINGLE resources.
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. |
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_ | |||
) |
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:
ret_value_ | The return value of sol_lwm2m_resource_init() |
resource_ | The resource to be initialized. |
id_ | The resource id. |
value_ | The int value |
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().
A handle of a client's object.
typedef struct sol_lwm2m_payload sol_lwm2m_payload |
A payload received from the network used to create a LWM2M object instance.
typedef struct sol_lwm2m_resource sol_lwm2m_resource |
Struct that represents a LWM2M resource.
typedef struct sol_lwm2m_security_psk sol_lwm2m_security_psk |
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.
typedef struct sol_lwm2m_security_rpk sol_lwm2m_security_rpk |
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.
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
| void * sol_lwm2m_tlv.content->data |
enum sol_lwm2m_acl_rights |
Enum that represents the Access Control Rights.
Setting each bit means the LWM2M Server has the access right for that operation.
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.
Enum that represents a LWM2M response/request content type.
Enum that represents a LWM2M resource data type.
Enum data represents if an sol_lwm2m_resource is an array or not.
Enum that represents the UDP Security Mode.
enum sol_lwm2m_tlv_type |
Enum that represents the TLV type.
int sol_lwm2m_client_object_get_id | ( | const struct sol_lwm2m_client_object * | object, |
uint16_t * | id | ||
) |
Gets the object id.
object | The LWM2M object to get the id. |
id | The object id to be filled. |
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.
object | The LWM2M object to get the instances. |
NULL
on error. 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.
content | A binary data that contains the TLV. |
tlv_values | An array of sol_lwm2m_tlv that will be filled. |
Referenced by location_changed_cb().
void sol_lwm2m_resource_clear | ( | struct sol_lwm2m_resource * | resource | ) |
Clears a sol_lwm2m_resource.
resource | The resource to be cleared. |
Referenced by create_location_obj(), delete_all_cb(), write_sec_one_cb(), write_server_one_cb(), and write_servers_cb().
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 |
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 data type. |
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.
resource | The resource to be initialized. |
id | The resource id. |
data_type | The resource data type. |
res_instances | The list of Resource Instances. Each Resource Instance value must respect the table according to the resource data type. |
Referenced by read_access_control_obj().
void sol_lwm2m_tlv_clear | ( | struct sol_lwm2m_tlv * | tlv | ) |
Clear a TLV.
tlv | The TLV the be cleared. |
int sol_lwm2m_tlv_get_bool | ( | struct sol_lwm2m_tlv * | tlv, |
bool * | value | ||
) |
Converts an TLV value to boolean value.
tlv | The tlv data. |
value | The converted value. |
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.
tlv | The tlv data. |
buf | The buffer to store the content. |
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.
tlv | The tlv data. |
value | The converted value. |
int sol_lwm2m_tlv_get_int | ( | struct sol_lwm2m_tlv * | tlv, |
int64_t * | value | ||
) |
Converts an TLV value to int value.
tlv | The tlv data. |
value | The converted value. |
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.
tlv | The tlv data. |
object_id | The object id. |
instance_id | the instance id. |
void sol_lwm2m_tlv_list_clear | ( | struct sol_vector * | tlvs | ) |
Clears an TLV array.
tlvs | The TLVs array to be cleared. |
Referenced by location_changed_cb().