Anjay Lite
Loading...
Searching...
No Matches
device_object.h File Reference

Default implementation of the LwM2M Device Object (/3). More...

#include <anj/init.h>
#include <anj/core.h>
#include <anj/dm/core.h>

Go to the source code of this file.

Data Structures

struct  anj_dm_device_object_init_t
 
struct  anj_dm_device_obj_t
 

Typedefs

typedef void anj_dm_reboot_callback_t(void *arg, anj_t *anj)
 

Functions

int anj_dm_device_obj_install (anj_t *anj, anj_dm_device_obj_t *device_obj, const anj_dm_device_object_init_t *obj_init)
 

Detailed Description

Default implementation of the LwM2M Device Object (/3).

Provides installation and basic metadata resources such as manufacturer, model, serial number, firmware version, and reboot handling.

Typedef Documentation

◆ anj_dm_reboot_callback_t

typedef void anj_dm_reboot_callback_t(void *arg, anj_t *anj)

Callback function type for handling the Reboot Resource (/3/0/4).

This function is invoked when the Reboot Resource is executed by the LwM2M server. The user is expected to perform a system reboot after this callback returns.

Warning
The Execute operation is a Confirmable CoAP request, so the LwM2M server expects an acknowledgement. It's recommended to delay the reboot until the response is successfully sent by the client.
Parameters
argOpaque argument passed to the callback, as provided in anj_dm_device_object_init_t::reboot_cb_arg.
anjAnjay object.

Function Documentation

◆ anj_dm_device_obj_install()

int anj_dm_device_obj_install ( anj_t anj,
anj_dm_device_obj_t device_obj,
const anj_dm_device_object_init_t obj_init 
)

Installs Device Object (/3) in data model.

Example usage:

static int reboot_cb(void *arg, anj_t *anj) {
// perform reboot
}
// ...
static const anj_dm_device_object_init_t dev_obj_init = {
.manufacturer = "manufacturer",
.model_number = "model_number",
.serial_number = "serial_number",
.firmware_version = "firmware_version",
.reboot_handler = reboot_cb
};
anj_dm_device_obj_install(&anj, &dev_obj, &dev_obj_init);
struct anj_struct anj_t
Definition defs.h:136
int anj_dm_device_obj_install(anj_t *anj, anj_dm_device_obj_t *device_obj, const anj_dm_device_object_init_t *obj_init)
Definition device_object.h:94
Definition device_object.h:60
const char * manufacturer
Definition device_object.h:62
Parameters
anjAnjay object.
device_objPointer to a variable that will hold the state of the Object.
obj_initPointer to Object's initialization structure.
Returns
0 on success, a non-zero value in case of an error.