Light Control object implementation for LwM2M client using Wakaama. More...
Light Control object implementation for LwM2M client using Wakaama.
This implements the LwM2M Light Control object (ID 3311) as specified in the LwM2M registry.
This Object is used to control a light source, such as a LED or other light. It allows a light to be turned on or off and dim it.
To use this object add USEMODULE += wakaama_objects_light_control
to the application Makefile.
For an XML description of the object see https://raw.githubusercontent.com/OpenMobileAlliance/lwm2m-registry/prod/3311.xml
Name | ID | Mandatory | Type | Range | Units | Implemented |
---|---|---|---|---|---|---|
On/Off | 5850 | Yes | Boolean | - | - | Yes[1] |
Dimmer | 5851 | No | Integer | 0 - 100 | /100 | Yes[1] |
On time | 5852 | No | Integer | - | s | Yes |
Cumulative active power | 5805 | No | Float | - | Wh | No |
Power factor | 5820 | No | Float | - | - | No |
Colour | 5706 | No | String | - | - | Yes |
Sensor Units | 5701 | No | String | - | - | No |
Application Type | 5750 | No | String | - | - | Yes |
[1]: The handling of these resources are implemented, but its actual impact on the light state depends on the application.
Modules | |
LwM2M Light Control object compile configurations | |
Files | |
file | light_control.h |
Data Structures | |
struct | lwm2m_obj_light_control_args |
Arguments for the creation of a Light Control object instance. More... | |
Macros | |
#define | LWM2M_LIGHT_CONTROL_OBJECT_ID 3311 |
Light Control object ID. | |
Typedefs | |
typedef void(* | lwm2m_obj_light_control_cb_t) (lwm2m_object_t *object, uint16_t instance_id, bool status, uint8_t dimmer, const char *color, const char *app_type, void *arg) |
Signature of the callback called when the light resources are updated. | |
typedef struct lwm2m_obj_light_control_args | lwm2m_obj_light_control_args_t |
Arguments for the creation of a Light Control object instance. | |
Functions | |
lwm2m_object_t * | lwm2m_object_light_control_init (lwm2m_client_data_t *client_data) |
Initialize the Light Control object. | |
int | lwm2m_object_light_control_instance_create (const lwm2m_obj_light_control_args_t *args, int32_t instance_id) |
Create a new Light Control instance and add it to the object list. | |
int | lwm2m_object_light_control_update_status (uint16_t instance_id, bool status, bool call_cb) |
Update the status of a light control instance. | |
int | lwm2m_object_light_control_update_dimmer (uint16_t instance_id, uint8_t dimmer, bool call_cb) |
Update the dimmer value of a light control instance. | |
int | lwm2m_object_light_control_update_color (uint16_t instance_id, const char *color, size_t len, bool call_cb) |
Update the color of a light control instance. | |
int | lwm2m_object_light_control_update_app_type (uint16_t instance_id, const char *app_type, size_t len, bool call_cb) |
Update the application type of a light control instance. | |
Light Control object resource's IDs. | |
#define | LWM2M_LIGHT_CONTROL_ON_OFF_ID 5850 |
Light status resource ID. | |
#define | LWM2M_LIGHT_CONTROL_DIMMER_ID 5851 |
Dimmer value resource ID. | |
#define | LWM2M_LIGHT_CONTROL_ON_TIME_ID 5852 |
On Time resource ID. | |
#define | LWM2M_LIGHT_CONTROL_ACT_PWR_ID 5805 |
Light active power resource ID. | |
#define | LWM2M_LIGHT_CONTROL_PWR_FACTOR_ID 5820 |
Light power factor resource ID. | |
#define | LWM2M_LIGHT_CONTROL_COLOUR_ID 5706 |
Light color resource ID. | |
#define | LWM2M_LIGHT_CONTROL_UNITS_ID 5701 |
Units of the power sensing resource ID. | |
#define | LWM2M_LIGHT_CONTROL_APP_TYPE_ID 5750 |
Light application type resource ID. | |
#define LWM2M_LIGHT_CONTROL_ACT_PWR_ID 5805 |
Light active power resource ID.
Definition at line 168 of file light_control.h.
#define LWM2M_LIGHT_CONTROL_APP_TYPE_ID 5750 |
Light application type resource ID.
Definition at line 184 of file light_control.h.
#define LWM2M_LIGHT_CONTROL_COLOUR_ID 5706 |
Light color resource ID.
Definition at line 176 of file light_control.h.
#define LWM2M_LIGHT_CONTROL_DIMMER_ID 5851 |
Dimmer value resource ID.
Definition at line 160 of file light_control.h.
#define LWM2M_LIGHT_CONTROL_OBJECT_ID 3311 |
Light Control object ID.
Definition at line 147 of file light_control.h.
#define LWM2M_LIGHT_CONTROL_ON_OFF_ID 5850 |
Light status resource ID.
Definition at line 156 of file light_control.h.
#define LWM2M_LIGHT_CONTROL_ON_TIME_ID 5852 |
On Time resource ID.
Definition at line 164 of file light_control.h.
#define LWM2M_LIGHT_CONTROL_PWR_FACTOR_ID 5820 |
Light power factor resource ID.
Definition at line 172 of file light_control.h.
#define LWM2M_LIGHT_CONTROL_UNITS_ID 5701 |
Units of the power sensing resource ID.
Definition at line 180 of file light_control.h.
typedef void(* lwm2m_obj_light_control_cb_t) (lwm2m_object_t *object, uint16_t instance_id, bool status, uint8_t dimmer, const char *color, const char *app_type, void *arg) |
Signature of the callback called when the light resources are updated.
[in] | object | Light Control object handle. |
[in] | instance_id | ID of the instance where the resource changed. |
[in] | status | Light status. |
[in] | dimmer | Dimmer value. |
[in] | color | Light color NULL-terminated string. |
[in] | app_type | Light application type NULL-terminated string. |
[in] | arg | Argument registered in lwm2m_object_light_control_instance_create. |
Definition at line 199 of file light_control.h.
lwm2m_object_t * lwm2m_object_light_control_init | ( | lwm2m_client_data_t * | client_data | ) |
Initialize the Light Control object.
[in] | client_data | LwM2M client data. |
int lwm2m_object_light_control_instance_create | ( | const lwm2m_obj_light_control_args_t * | args, |
int32_t | instance_id | ||
) |
Create a new Light Control instance and add it to the object
list.
[in] | args | Initialize structure with the parameter for the instance. May not be NULL. |
[in] | instance_id | ID for the new instance. It must be between 0 and (UINT16_MAX - 1), if -1 the next available ID will be used. |
instance_id
is given int lwm2m_object_light_control_update_app_type | ( | uint16_t | instance_id, |
const char * | app_type, | ||
size_t | len, | ||
bool | call_cb | ||
) |
Update the application type of a light control instance.
[in] | instance_id | ID of the instance to update. |
[in] | app_type | New application type of the light. |
[in] | len | Length of the app_type string. |
[in] | call_cb | If true, the callback lwm2m_obj_light_control_args_t::cb will be called. |
int lwm2m_object_light_control_update_color | ( | uint16_t | instance_id, |
const char * | color, | ||
size_t | len, | ||
bool | call_cb | ||
) |
Update the color of a light control instance.
[in] | instance_id | ID of the instance to update. |
[in] | color | New color of the light. |
[in] | len | Length of the color string. |
[in] | call_cb | If true, the callback lwm2m_obj_light_control_args_t::cb will be called. |
int lwm2m_object_light_control_update_dimmer | ( | uint16_t | instance_id, |
uint8_t | dimmer, | ||
bool | call_cb | ||
) |
Update the dimmer value of a light control instance.
[in] | instance_id | ID of the instance to update. |
[in] | dimmer | New dimmer value. |
[in] | call_cb | If true, the callback lwm2m_obj_light_control_args_t::cb will be called. |
int lwm2m_object_light_control_update_status | ( | uint16_t | instance_id, |
bool | status, | ||
bool | call_cb | ||
) |
Update the status of a light control instance.
[in] | instance_id | ID of the instance to update. |
[in] | status | New status of the light. |
[in] | call_cb | If true, the callback lwm2m_obj_light_control_args_t::cb will be called. |