Soletta™ Framework
|
Routines to create Servers talking the LWM2M protocol. More...
Typedefs | |
typedef struct sol_lwm2m_client_info | sol_lwm2m_client_info |
A handle that contains information about a registered LWM2M client. More... | |
typedef struct sol_lwm2m_server | sol_lwm2m_server |
A handle to a LWM2M server. More... | |
Enumerations | |
enum | sol_lwm2m_registration_event { SOL_LWM2M_REGISTRATION_EVENT_REGISTER, SOL_LWM2M_REGISTRATION_EVENT_UPDATE, SOL_LWM2M_REGISTRATION_EVENT_UNREGISTER, SOL_LWM2M_REGISTRATION_EVENT_TIMEOUT } |
Enum that expresses a LWM2M client lifecycle changes. More... | |
Functions | |
const struct sol_network_link_addr * | sol_lwm2m_client_info_get_address (const struct sol_lwm2m_client_info *client) |
Gets the client address. More... | |
enum sol_lwm2m_binding_mode | sol_lwm2m_client_info_get_binding_mode (const struct sol_lwm2m_client_info *client) |
Gets the client binding mode. More... | |
int | sol_lwm2m_client_info_get_lifetime (const struct sol_lwm2m_client_info *client, uint32_t *lifetime) |
Gets the client lifetime in seconds. More... | |
const char * | sol_lwm2m_client_info_get_location (const struct sol_lwm2m_client_info *client) |
Gets the client location path in the LWM2M server. More... | |
const char * | sol_lwm2m_client_info_get_name (const struct sol_lwm2m_client_info *client) |
Gets the name of client. More... | |
const struct sol_ptr_vector * | sol_lwm2m_client_info_get_objects (const struct sol_lwm2m_client_info *client) |
Get client's objects. More... | |
const char * | sol_lwm2m_client_info_get_objects_path (const struct sol_lwm2m_client_info *client) |
Gets the client objects path. More... | |
const char * | sol_lwm2m_client_info_get_sms_number (const struct sol_lwm2m_client_info *client) |
Gets the client SMS number. More... | |
int | sol_lwm2m_server_add_observer (struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, void(*sol_lwm2m_server_content_cb)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code, enum sol_lwm2m_content_type content_type, struct sol_str_slice content), const void *data) |
Observes a client object, instance or resource. More... | |
int | sol_lwm2m_server_add_registration_monitor (struct sol_lwm2m_server *server, void(*sol_lwm2m_server_registration_event_cb)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *cinfo, enum sol_lwm2m_registration_event event), const void *data) |
Adds a registration monitor. More... | |
int | sol_lwm2m_server_create_object_instance (struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, struct sol_lwm2m_resource *resources, size_t len, void(*sol_lwm2m_server_management_status_response_cb)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code), const void *data) |
Creates an object instance on a client. More... | |
void | sol_lwm2m_server_del (struct sol_lwm2m_server *server) |
Deletes a server instance. More... | |
int | sol_lwm2m_server_del_observer (struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, void(*sol_lwm2m_server_content_cb)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code, enum sol_lwm2m_content_type content_type, struct sol_str_slice content), const void *data) |
Unobserve a client object, instance or resource. More... | |
int | sol_lwm2m_server_del_registration_monitor (struct sol_lwm2m_server *server, void(*sol_lwm2m_server_registration_event_cb)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *cinfo, enum sol_lwm2m_registration_event event), const void *data) |
Removes a registration monitor. More... | |
int | sol_lwm2m_server_delete_object_instance (struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, void(*sol_lwm2m_server_management_status_response_cb)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code), const void *data) |
Deletes an object instance on a client. More... | |
int | sol_lwm2m_server_execute_resource (struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, const char *args, void(*sol_lwm2m_server_management_status_response_cb)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code), const void *data) |
Executes an resource on a client. More... | |
const struct sol_ptr_vector * | sol_lwm2m_server_get_clients (const struct sol_lwm2m_server *server) |
Gets all registerd clients. More... | |
struct sol_lwm2m_server * | sol_lwm2m_server_new (uint16_t coap_port, uint16_t num_sec_modes,...) |
Creates a new LWM2M server. More... | |
int | sol_lwm2m_server_read (struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, void(*sol_lwm2m_server_content_cb)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code, enum sol_lwm2m_content_type content_type, struct sol_str_slice content), const void *data) |
Reads an object, instance or resource from a client. More... | |
int | sol_lwm2m_server_write (struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, struct sol_lwm2m_resource *resources, size_t len, void(*sol_lwm2m_server_management_status_response_cb)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code), const void *data) |
Writes an object instance or resource. More... | |
Routines to create Servers talking the LWM2M protocol.
A handle that contains information about a registered LWM2M client.
A handle to a LWM2M server.
Enum that expresses a LWM2M client lifecycle changes.
const struct sol_network_link_addr* sol_lwm2m_client_info_get_address | ( | const struct sol_lwm2m_client_info * | client | ) |
Gets the client address.
client | The LWM2M client info. |
client
address or NULL
on error. enum sol_lwm2m_binding_mode sol_lwm2m_client_info_get_binding_mode | ( | const struct sol_lwm2m_client_info * | client | ) |
Gets the client binding mode.
client | The LWM2M client info. |
int sol_lwm2m_client_info_get_lifetime | ( | const struct sol_lwm2m_client_info * | client, |
uint32_t * | lifetime | ||
) |
Gets the client lifetime in seconds.
client | The LWM2M client info. |
lifetime | The client lifetime to be set. |
const char* sol_lwm2m_client_info_get_location | ( | const struct sol_lwm2m_client_info * | client | ) |
Gets the client location path in the LWM2M server.
This value is specified by the LWM2M server and it will be used by the client to identify itself.
client | The LWM2M client info. |
client
location path or NULL
on error. const char* sol_lwm2m_client_info_get_name | ( | const struct sol_lwm2m_client_info * | client | ) |
Gets the name of client.
client | The LWM2M client info. |
client
name or NULL
on error. Referenced by create_cb(), location_changed_cb(), and registration_cb().
const struct sol_ptr_vector* sol_lwm2m_client_info_get_objects | ( | const struct sol_lwm2m_client_info * | client | ) |
Get client's objects.
client | The LWM2M client info. |
NULL
on error. Referenced by get_location_object_status().
const char* sol_lwm2m_client_info_get_objects_path | ( | const struct sol_lwm2m_client_info * | client | ) |
Gets the client objects path.
A LWM2M client may specify an alternate objects path.
client | The LWM2M client info. |
NULL
. NULL
. const char* sol_lwm2m_client_info_get_sms_number | ( | const struct sol_lwm2m_client_info * | client | ) |
Gets the client SMS number.
A client may specify an SMS number to be used for communication.
client | The LWM2M client info. |
NULL
. int sol_lwm2m_server_add_observer | ( | struct sol_lwm2m_server * | server, |
struct sol_lwm2m_client_info * | client, | ||
const char * | path, | ||
void(*)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code, enum sol_lwm2m_content_type content_type, struct sol_str_slice content) | sol_lwm2m_server_content_cb, | ||
const void * | data | ||
) |
Observes a client object, instance or resource.
Every time the observed path changes, the client will notify the LWM2M server.
server | The LWM2M server. |
client | The LWM2M client to be observed. |
path | The path to be observed (Example: /3/0/0). |
sol_lwm2m_server_content_cb | A callback to be called when the observed path changes, used to inform a observable/read response. - server The LWM2M server; client The LWM2M client; path The client's path; response_code The response code; content_type The response content type; content The response content; data User data. |
data | User data to sol_lwm2m_server_content_cb |
Referenced by observe_location().
int sol_lwm2m_server_add_registration_monitor | ( | struct sol_lwm2m_server * | server, |
void(*)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *cinfo, enum sol_lwm2m_registration_event event) | sol_lwm2m_server_registration_event_cb, | ||
const void * | data | ||
) |
Adds a registration monitor.
This function registers a monitor, making it easier to observe a LWM2M client's life cycle. This means that every time a LWM2M client is registered, updated, deleted or timed out, sol_lwm2m_server_registration_event_cb will be called.
server | The LWM2M server. |
sol_lwm2m_server_registration_event_cb | A callback that is used to inform a LWM2M client registration event - data User data; server The LWM2M server; cinfo The client that generated the registration event; event The registration event itself. |
data | The user data to sol_lwm2m_server_registration_event_cb . |
Referenced by main().
int sol_lwm2m_server_create_object_instance | ( | struct sol_lwm2m_server * | server, |
struct sol_lwm2m_client_info * | client, | ||
const char * | path, | ||
struct sol_lwm2m_resource * | resources, | ||
size_t | len, | ||
void(*)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code) | sol_lwm2m_server_management_status_response_cb, | ||
const void * | data | ||
) |
Creates an object instance on a client.
server | The LWM2M server. |
client | The LWM2M client info to create an object instance. |
path | The object path to be created (Example /1). |
resources | An array of sol_lwm2m_resource which contains the required resources to create an object. |
len | The length of resources . |
sol_lwm2m_server_management_status_response_cb | A callback to be called when the create operation is completed. - server The LW2M server; client The LWM2M client; path The client's path; response_code The operation's response_code ; data User data. |
data | User data to sol_lwm2m_server_management_status_response_cb |
Referenced by create_location_obj().
void sol_lwm2m_server_del | ( | struct sol_lwm2m_server * | server | ) |
Deletes a server instance.
Use this function to stop the LWM2M server and release its resources.
server | The LWM2M server to be deleted. |
Referenced by main().
int sol_lwm2m_server_del_observer | ( | struct sol_lwm2m_server * | server, |
struct sol_lwm2m_client_info * | client, | ||
const char * | path, | ||
void(*)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code, enum sol_lwm2m_content_type content_type, struct sol_str_slice content) | sol_lwm2m_server_content_cb, | ||
const void * | data | ||
) |
Unobserve a client object, instance or resource.
server | The LWM2M server. |
client | The LWM2M client to be unobserved. |
path | The path to be unobserved (Example: /3/0/0). |
sol_lwm2m_server_content_cb | The previous registered callback. - server The LWM2M server; client The LWM2M client; path The client's path; @ response_code The response code; content_type The response content type; content The response content; data User data. |
data | User data to sol_lwm2m_server_content_cb |
int sol_lwm2m_server_del_registration_monitor | ( | struct sol_lwm2m_server * | server, |
void(*)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *cinfo, enum sol_lwm2m_registration_event event) | sol_lwm2m_server_registration_event_cb, | ||
const void * | data | ||
) |
Removes a registration monitor.
server | The LWM2M server. |
sol_lwm2m_server_registration_event_cb | The previous registered callback. - data User data; server The LWM2M server; cinfo The client that generated the registration event; event The registration event itself. |
data | The user data to sol_lwm2m_server_registration_event_cb . |
int sol_lwm2m_server_delete_object_instance | ( | struct sol_lwm2m_server * | server, |
struct sol_lwm2m_client_info * | client, | ||
const char * | path, | ||
void(*)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code) | sol_lwm2m_server_management_status_response_cb, | ||
const void * | data | ||
) |
Deletes an object instance on a client.
server | The LWM2M server. |
client | The LWM2M client info to delete an object |
path | The object path to be deleted (Example /1/1). |
sol_lwm2m_server_management_status_response_cb | A callback to be called when the delete operation is completed. - server The LW2M server; client The LWM2M client; path The client's path; response_code The operation's response_code ; data User data. |
data | User data to sol_lwm2m_server_management_status_response_cb |
int sol_lwm2m_server_execute_resource | ( | struct sol_lwm2m_server * | server, |
struct sol_lwm2m_client_info * | client, | ||
const char * | path, | ||
const char * | args, | ||
void(*)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code) | sol_lwm2m_server_management_status_response_cb, | ||
const void * | data | ||
) |
Executes an resource on a client.
server | The LWM2M server. |
client | The LWM2M client info to execute the resource. |
path | The object path to be executed (Example /1/1/8). |
args | Arguments to the execute command. |
sol_lwm2m_server_management_status_response_cb | A callback to be called when the execute operation is completed. - server The LW2M server; client The LWM2M client; path The client's path; response_code The operation's response_code ; data User data. |
data | User data to sol_lwm2m_server_management_status_response_cb |
const struct sol_ptr_vector* sol_lwm2m_server_get_clients | ( | const struct sol_lwm2m_server * | server | ) |
Gets all registerd clients.
server | The LWM2M Server. |
NULL
on error. struct sol_lwm2m_server* sol_lwm2m_server_new | ( | uint16_t | coap_port, |
uint16_t | num_sec_modes, | ||
... | |||
) |
Creates a new LWM2M server.
The server will be immediately operational and waiting for connections.
coap_port | The UDP port to be used for the NoSec CoAP Server. |
num_sec_modes | The number of DTLS Security Modes this Bootstrap Server will support. |
... | An uint16_t indicating the UDP port to be used for the Secure DTLS Server; and at least one sol_lwm2m_security_mode followed by its relevant parameters, as per the table below: |
Security Mode | Follow-up arguments | Description |
---|---|---|
SOL_LWM2M_SECURITY_MODE_PRE_SHARED_KEY | struct sol_lwm2m_security_psk **known_psks | known_psks The Clients' Pre-Shared Keys this Server has previous knowledge of. It MUST be a NULL-terminated array. |
SOL_LWM2M_SECURITY_MODE_RAW_PUBLIC_KEY | struct sol_lwm2m_security_rpk *rpk, struct sol_blob **known_pub_keys | rpk This Server's Key Pair - known_pub_keys The Clients' Public Keys this Bootstrap Server has previous knowledge of. It MUST be a NULL-terminated array. |
NULL
on error. Referenced by main().
int sol_lwm2m_server_read | ( | struct sol_lwm2m_server * | server, |
struct sol_lwm2m_client_info * | client, | ||
const char * | path, | ||
void(*)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code, enum sol_lwm2m_content_type content_type, struct sol_str_slice content) | sol_lwm2m_server_content_cb, | ||
const void * | data | ||
) |
Reads an object, instance or resource from a client.
server | The LWM2M server. |
client | The LWM2M client info to be read. |
path | The path to be read (Example /3/0/0). |
sol_lwm2m_server_content_cb | A callback to be called when the read operation is completed. - server The LWM2M server; client The LWM2M client; path The client's path; response_code The response code; content_type The response content type; content The response content; data User data. |
data | User data to sol_lwm2m_server_content_cb |
int sol_lwm2m_server_write | ( | struct sol_lwm2m_server * | server, |
struct sol_lwm2m_client_info * | client, | ||
const char * | path, | ||
struct sol_lwm2m_resource * | resources, | ||
size_t | len, | ||
void(*)(void *data, struct sol_lwm2m_server *server, struct sol_lwm2m_client_info *client, const char *path, enum sol_coap_response_code response_code) | sol_lwm2m_server_management_status_response_cb, | ||
const void * | data | ||
) |
Writes an object instance or resource.
server | The LWM2M server. |
client | The LWM2M client info to write |
path | The object path to be written (Example /1/1). |
resources | An array of sol_lwm2m_resource |
len | The length of resources |
sol_lwm2m_server_management_status_response_cb | A callback to be called when the write operation is completed. - server The LW2M server; client The LWM2M client; path The client's path; response_code The operation's response_code ; data User data. |
data | User data to sol_lwm2m_server_management_status_response_cb |