-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20652 from leandrolanzieri/dev/lwm2m/ipso_objects
pkg/wakaama: implement IPSO sensor objects in LwM2M
- Loading branch information
Showing
18 changed files
with
2,092 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
menu "IPSO sensor objects" | ||
depends on USEMODULE_WAKAAMA_OBJECTS_IPSO_SENSOR_BASE | ||
|
||
config LWM2M_IPSO_SENSOR_BASE_UNITS_MAX_SIZE | ||
int "Maximum size of strings representing units" | ||
default 4 | ||
|
||
menu "IPSO barometer object" | ||
depends on USEMODULE_WAKAAMA_OBJECTS_BAROMETER | ||
|
||
config LWM2M_BAROMETER_INSTANCES_MAX | ||
int "Maximum number of barometer object instances" | ||
default 1 | ||
|
||
endmenu | ||
|
||
menu "IPSO current object" | ||
depends on USEMODULE_WAKAAMA_OBJECTS_CURRENT | ||
|
||
config LWM2M_CURRENT_INSTANCES_MAX | ||
int "Maximum number of current object instances" | ||
default 1 | ||
|
||
endmenu | ||
|
||
menu "IPSO humidity object" | ||
depends on USEMODULE_WAKAAMA_OBJECTS_HUMIDITY | ||
|
||
config LWM2M_HUMIDITY_INSTANCES_MAX | ||
int "Maximum number of humidity object instances" | ||
default 1 | ||
|
||
endmenu | ||
|
||
menu "IPSO illuminance object" | ||
depends on USEMODULE_WAKAAMA_OBJECTS_ILLUMINANCE | ||
|
||
config LWM2M_ILLUMINANCE_INSTANCES_MAX | ||
int "Maximum number of illuminance object instances" | ||
default 1 | ||
|
||
endmenu | ||
|
||
menu "IPSO temperature object" | ||
depends on USEMODULE_WAKAAMA_OBJECTS_TEMPERATURE | ||
|
||
config LWM2M_TEMPERATURE_INSTANCES_MAX | ||
int "Maximum number of temperature object instances" | ||
default 1 | ||
|
||
endmenu | ||
|
||
menu "IPSO voltage object" | ||
depends on USEMODULE_WAKAAMA_OBJECTS_VOLTAGE | ||
|
||
config LWM2M_VOLTAGE_INSTANCES_MAX | ||
int "Maximum number of voltage object instances" | ||
default 1 | ||
|
||
endmenu | ||
|
||
endmenu # "IPSO objects" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) 2024 HAW Hamburg | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
/** | ||
* @{ | ||
* @ingroup lwm2m_objects_barometer | ||
* | ||
* @file | ||
* @brief Barometer object implementation for LwM2M client using Wakaama | ||
* | ||
* @author Leandro Lanzieri <[email protected]> | ||
* @} | ||
*/ | ||
|
||
#include "liblwm2m.h" | ||
#include "lwm2m_client.h" | ||
#include "objects/barometer.h" | ||
#include "objects/ipso_sensor_base.h" | ||
|
||
#define ENABLE_DEBUG 0 | ||
#include "debug.h" | ||
|
||
/** | ||
* @brief Barometer object implementation descriptor. | ||
*/ | ||
static lwm2m_obj_ipso_sensor_base_t _barometer_object; | ||
|
||
/** | ||
* @brief Pool of object instances. | ||
*/ | ||
static lwm2m_obj_ipso_sensor_base_inst_t _instances[CONFIG_LWM2M_BAROMETER_INSTANCES_MAX]; | ||
|
||
lwm2m_object_t *lwm2m_object_barometer_init(lwm2m_client_data_t *client_data) | ||
{ | ||
assert(client_data); | ||
int res = lwm2m_object_ipso_sensor_base_init_derived(client_data, &_barometer_object, | ||
LWM2M_BAROMETER_OBJECT_ID, | ||
_instances, | ||
CONFIG_LWM2M_BAROMETER_INSTANCES_MAX); | ||
|
||
if (res) { | ||
DEBUG("[lwm2m:barometer]: failed to create object\n"); | ||
return NULL; | ||
} | ||
|
||
return &_barometer_object.object; | ||
} | ||
|
||
int32_t lwm2m_object_barometer_instance_create(const lwm2m_obj_barometer_args_t *args) | ||
{ | ||
int32_t result = lwm2m_object_ipso_sensor_base_instance_create(&_barometer_object, args); | ||
|
||
if (result) { | ||
DEBUG("[lwm2m:barometer]: failed to create instance\n"); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
void lwm2m_object_barometer_update_value(const lwm2m_client_data_t *client_data, | ||
uint16_t instance_id, int16_t value) | ||
{ | ||
lwm2m_object_ipso_sensor_base_update_value(client_data, &_barometer_object, instance_id, value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (C) 2024 HAW Hamburg | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
/** | ||
* @{ | ||
* @ingroup lwm2m_objects_current | ||
* | ||
* @file | ||
* @brief Current sensor object implementation for LwM2M client using Wakaama | ||
* | ||
* @author Leandro Lanzieri <[email protected]> | ||
* @} | ||
*/ | ||
|
||
#include "liblwm2m.h" | ||
#include "lwm2m_client.h" | ||
#include "objects/current.h" | ||
#include "objects/ipso_sensor_base.h" | ||
|
||
#define ENABLE_DEBUG 0 | ||
#include "debug.h" | ||
|
||
/** | ||
* @brief Current Sensor object implementation descriptor. | ||
*/ | ||
static lwm2m_obj_ipso_sensor_base_t _current_object; | ||
|
||
/** | ||
* @brief Pool of object instances. | ||
*/ | ||
static lwm2m_obj_ipso_sensor_base_inst_t _instances[CONFIG_LWM2M_CURRENT_INSTANCES_MAX]; | ||
|
||
lwm2m_object_t *lwm2m_object_current_init(lwm2m_client_data_t *client_data) | ||
{ | ||
assert(client_data); | ||
int res = lwm2m_object_ipso_sensor_base_init_derived(client_data, &_current_object, | ||
LWM2M_CURRENT_OBJECT_ID, | ||
_instances, | ||
CONFIG_LWM2M_CURRENT_INSTANCES_MAX); | ||
|
||
if (res) { | ||
DEBUG("[lwm2m:current]: failed to create object\n"); | ||
return NULL; | ||
} | ||
|
||
return &_current_object.object; | ||
} | ||
|
||
int32_t lwm2m_object_current_instance_create(const lwm2m_obj_current_args_t *args) | ||
{ | ||
int32_t result = lwm2m_object_ipso_sensor_base_instance_create(&_current_object, args); | ||
|
||
if (result) { | ||
DEBUG("[lwm2m:current]: failed to create instance\n"); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
void lwm2m_object_current_update_value(const lwm2m_client_data_t *client_data, uint16_t instance_id, | ||
int16_t value) | ||
{ | ||
lwm2m_object_ipso_sensor_base_update_value(client_data, &_current_object, instance_id, value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (C) 2024 HAW Hamburg | ||
* | ||
* This file is subject to the terms and conditions of the GNU Lesser | ||
* General Public License v2.1. See the file LICENSE in the top level | ||
* directory for more details. | ||
*/ | ||
/** | ||
* @{ | ||
* @ingroup lwm2m_objects_humidity | ||
* | ||
* @file | ||
* @brief Humidity Sensor object implementation for LwM2M client using Wakaama | ||
* | ||
* @author Leandro Lanzieri <[email protected]> | ||
* @} | ||
*/ | ||
|
||
#include "mutex.h" | ||
#include "liblwm2m.h" | ||
#include "lwm2m_client.h" | ||
#include "objects/humidity.h" | ||
#include "objects/ipso_sensor_base.h" | ||
|
||
#define ENABLE_DEBUG 1 | ||
#include "debug.h" | ||
|
||
/** | ||
* @brief Humidity Sensor object implementation descriptor. | ||
*/ | ||
static lwm2m_obj_ipso_sensor_base_t _humidity_object; | ||
|
||
/** | ||
* @brief Pool of object instances. | ||
*/ | ||
static lwm2m_obj_ipso_sensor_base_inst_t _instances[CONFIG_LWM2M_HUMIDITY_INSTANCES_MAX]; | ||
|
||
lwm2m_object_t *lwm2m_object_humidity_init(lwm2m_client_data_t *client_data) | ||
{ | ||
assert(client_data); | ||
int res = lwm2m_object_ipso_sensor_base_init_derived(client_data, &_humidity_object, | ||
LWM2M_HUMIDITY_OBJECT_ID, | ||
_instances, | ||
CONFIG_LWM2M_HUMIDITY_INSTANCES_MAX); | ||
|
||
if (res) { | ||
DEBUG("[lwm2m:humidity]: failed to create object\n"); | ||
return NULL; | ||
} | ||
|
||
return &_humidity_object.object; | ||
} | ||
|
||
int32_t lwm2m_object_humidity_instance_create(const lwm2m_obj_humidity_args_t *args) | ||
{ | ||
int32_t result = lwm2m_object_ipso_sensor_base_instance_create(&_humidity_object, args); | ||
|
||
if (result) { | ||
DEBUG("[lwm2m:humidity]: failed to create instance\n"); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
void lwm2m_object_humidity_update_value(const lwm2m_client_data_t *client_data, | ||
uint16_t instance_id, int16_t value) | ||
{ | ||
lwm2m_object_ipso_sensor_base_update_value(client_data, &_humidity_object, instance_id, value); | ||
} |
Oops, something went wrong.