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
Data Structures | Typedefs | Enumerations | Functions
LWM2M Client

Routines to create Clients talking the LWM2M protocol. More...

Data Structures

struct  sol_lwm2m_object
 A LWM2M object implementation. More...
 

Typedefs

typedef struct sol_lwm2m_client sol_lwm2m_client
 A handle to a LWM2M client. More...
 
typedef struct sol_lwm2m_object sol_lwm2m_object
 A LWM2M object implementation. More...
 

Enumerations

enum  sol_lwm2m_bootstrap_event { SOL_LWM2M_BOOTSTRAP_EVENT_FINISHED, SOL_LWM2M_BOOTSTRAP_EVENT_ERROR }
 Enum that express the bootstrapping lifecycle. More...
 

Functions

int sol_lwm2m_client_add_bootstrap_finish_monitor (struct sol_lwm2m_client *client, void(*sol_lwm2m_client_bootstrap_event_cb)(void *data, struct sol_lwm2m_client *client, enum sol_lwm2m_bootstrap_event event), const void *data)
 Adds a bootstrap monitor to the client. More...
 
int sol_lwm2m_client_add_object_instance (struct sol_lwm2m_client *client, const struct sol_lwm2m_object *obj, const void *data)
 Creates an object instance. More...
 
void sol_lwm2m_client_del (struct sol_lwm2m_client *client)
 Deletes a LWM2M client. More...
 
int sol_lwm2m_client_del_bootstrap_finish_monitor (struct sol_lwm2m_client *client, void(*sol_lwm2m_client_bootstrap_event_cb)(void *data, struct sol_lwm2m_client *client, enum sol_lwm2m_bootstrap_event event), const void *data)
 Removes a bootstrap monitor from the client. More...
 
struct sol_lwm2m_clientsol_lwm2m_client_new (const char *name, const char *path, const char *sms, const struct sol_lwm2m_object **objects, const void *data)
 Creates a new LWM2M client. More...
 
int sol_lwm2m_client_notify (struct sol_lwm2m_client *client, const char **paths)
 Notifies all the observing LWM2M servers that a resource has changed. More...
 
int sol_lwm2m_client_send_update (struct sol_lwm2m_client *client)
 Sends an update message to the LWM2M servers. More...
 
int sol_lwm2m_client_start (struct sol_lwm2m_client *client)
 Starts the LWM2M client. More...
 
int sol_lwm2m_client_stop (struct sol_lwm2m_client *client)
 Stops the LWM2M client. More...
 

Detailed Description

Routines to create Clients talking the LWM2M protocol.

Typedef Documentation

A handle to a LWM2M client.

See Also
sol_lwm2m_client_new().

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

See Also
sol_lwm2m_client_new()

Enumeration Type Documentation

Enum that express the bootstrapping lifecycle.

See Also
sol_lwm2m_client_add_bootstrap_monitor()
Enumerator
SOL_LWM2M_BOOTSTRAP_EVENT_FINISHED 

Indicates that a server finished bootstrapping the client.

SOL_LWM2M_BOOTSTRAP_EVENT_ERROR 

Indicates that an error occurred during the bootstrap process.

Function Documentation

int sol_lwm2m_client_add_bootstrap_finish_monitor ( struct sol_lwm2m_client client,
void(*)(void *data, struct sol_lwm2m_client *client, enum sol_lwm2m_bootstrap_event event)  sol_lwm2m_client_bootstrap_event_cb,
const void *  data 
)

Adds a bootstrap monitor to the client.

This function register a monitor. This means that every time a LWM2M bootstrap server performs a Bootstrap Finish sol_lwm2m_client_bootstrap_event_cb will be called.

Parameters
clientThe LWM2M client.
sol_lwm2m_client_bootstrap_event_cbA callback that is used to inform a LWM2M bootstrap server event - data User data; client The LWM2M client; event The bootstrap event itself.
dataThe user data to sol_lwm2m_client_bootstrap_event_cb.
Returns
0 on success, -errno on error.
See Also
sol_lwm2m_client_del_bootstrap_finish_monitor()
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by main().

int sol_lwm2m_client_add_object_instance ( struct sol_lwm2m_client client,
const struct sol_lwm2m_object obj,
const void *  data 
)

Creates an object instance.

Parameters
clientThe client to create the object instance in.
objThe object that the instance should be created.
dataThe instance data.
Returns
0 on success, -errno on error.
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by main().

void sol_lwm2m_client_del ( struct sol_lwm2m_client client)

Deletes a LWM2M client.

This will automatically stop the LWM2M client as well.

Parameters
clientThe client to be deleted.
See Also
sol_lwm2m_client_start()
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by main().

int sol_lwm2m_client_del_bootstrap_finish_monitor ( struct sol_lwm2m_client client,
void(*)(void *data, struct sol_lwm2m_client *client, enum sol_lwm2m_bootstrap_event event)  sol_lwm2m_client_bootstrap_event_cb,
const void *  data 
)

Removes a bootstrap monitor from the client.

Parameters
clientThe LWM2M client.
sol_lwm2m_client_bootstrap_event_cbThe previous registered callback. - data User data; client The LWM2M client; event The bootstrap event itself.
dataThe user data to sol_lwm2m_client_bootstrap_event_cb.
Returns
0 on success, -errno on error.
See Also
sol_lwm2m_client_add_bootstrap_finish_monitor()
struct sol_lwm2m_client* sol_lwm2m_client_new ( const char *  name,
const char *  path,
const char *  sms,
const struct sol_lwm2m_object **  objects,
const void *  data 
)

Creates a new LWM2M client.

This function will create a new LWM2M client with its objects. In order to start the LWM2M client and connect with the LWM2M servers, one must call sol_lwm2m_client_start.

Parameters
nameThe LWM2M client name, must not be NULL.
pathThe Objects path, may be NULL.
smsThe SMS number, may be NULL.
objectsThe implemented objects, must not be NULL and must be NULL terminated.
dataThe user's data that will be passed to the object callbacks. (create, execute, read, write and del).
Returns
A LWM2M client handle or NULL on error
See Also
sol_lwm2m_client_del()
sol_lwm2m_client_add_object_instance()
sol_lwm2m_client_start()
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by main().

int sol_lwm2m_client_notify ( struct sol_lwm2m_client client,
const char **  paths 
)

Notifies all the observing LWM2M servers that a resource has changed.

Use this function to notify the LWM2M servers that an Object instance resource value has changed.

Parameters
clientThe LWM2M client.
pathsThe resource paths that were changed, must be NULL terminated.
Returns
0 on success, -errno on error.
Note
If a LWM2M server creates an object instance, writes on an object instance or writes in an object resource, the LWM2M client infrastructure will automatically notify all observing servers.
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by change_location().

int sol_lwm2m_client_send_update ( struct sol_lwm2m_client client)

Sends an update message to the LWM2M servers.

This will trigger the update method of the LWM2M registration interface. The client will send an update to all the registered LWM2M servers.

Parameters
clientThe client to send the update request.
Returns
0 on success, -errno on error.
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by execute_server_obj().

int sol_lwm2m_client_start ( struct sol_lwm2m_client client)

Starts the LWM2M client.

The LWM2M client will attempt to connect with all the registered LWM2M servers. The LWM2M client will look for the Security and Server LWM2M objects in order to connect with the LWM2M servers.

Parameters
clientThe client to be started.
Returns
0 on success, -errno on error.
See Also
sol_lwm2m_client_stop()
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by bootstrap_cb(), and main().

int sol_lwm2m_client_stop ( struct sol_lwm2m_client client)

Stops the LWM2M client.

This will make the LWM2M client to stop receiving/sending messages from/to the LWM2M servers. It's important to note that the objects and object instances will not be deleted.

In order to be able to respond to commands from a LWM2M server, one must call sol_lwm2m_client_start

Parameters
clientThe client to be stopped.
Returns
0 on success, -errno on error.
See Also
sol_lwm2m_client_start()
Examples:
/src/samples/coap/lwm2m-client.c.

Referenced by main().