net: lwm2m: Add IPSO Buzzer object in version 1.1

Update IPSO Buzzer object implementation to support object model
version 1.1.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2021-02-12 16:16:03 +01:00 committed by Anas Nashif
commit 1efc8e7353
2 changed files with 33 additions and 2 deletions

View file

@ -207,6 +207,21 @@ config LWM2M_IPSO_BUZZER_INSTANCE_COUNT
This setting establishes the total count of IPSO Buzzer This setting establishes the total count of IPSO Buzzer
instances available to the LWM2M client. instances available to the LWM2M client.
choice
prompt "IPSO Buzzer object version"
depends on LWM2M_IPSO_BUZZER
default LWM2M_IPSO_BUZZER_VERSION_1_0
help
Select which version of the IPSO Buzzer object should be used.
config LWM2M_IPSO_BUZZER_VERSION_1_0
bool "IPSO Buzzer object version 1.0"
config LWM2M_IPSO_BUZZER_VERSION_1_1
bool "IPSO Buzzer object version 1.1"
endchoice
config LWM2M_IPSO_TIMER config LWM2M_IPSO_TIMER
bool "IPSO Light Control Support" bool "IPSO Light Control Support"
help help

View file

@ -23,9 +23,15 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include "lwm2m_resource_ids.h" #include "lwm2m_resource_ids.h"
#define BUZZER_VERSION_MAJOR 1 #define BUZZER_VERSION_MAJOR 1
#define BUZZER_VERSION_MINOR 0
#define BUZZER_MAX_ID 6
#if defined(CONFIG_LWM2M_IPSO_BUZZER_VERSION_1_1)
#define BUZZER_VERSION_MINOR 1
#define BUZZER_MAX_ID 8
#else
#define BUZZER_VERSION_MINOR 0
#define BUZZER_MAX_ID 6
#endif /* defined(CONFIG_LWM2M_IPSO_BUZZER_VERSION_1_1) */
#define MAX_INSTANCE_COUNT CONFIG_LWM2M_IPSO_BUZZER_INSTANCE_COUNT #define MAX_INSTANCE_COUNT CONFIG_LWM2M_IPSO_BUZZER_INSTANCE_COUNT
@ -64,6 +70,10 @@ static struct lwm2m_engine_obj_field fields[] = {
* events * events
*/ */
OBJ_FIELD_DATA(DIGITAL_INPUT_STATE_RID, R, BOOL), OBJ_FIELD_DATA(DIGITAL_INPUT_STATE_RID, R, BOOL),
#if defined(CONFIG_LWM2M_IPSO_BUZZER_VERSION_1_1)
OBJ_FIELD_DATA(TIMESTAMP_RID, R_OPT, TIME),
OBJ_FIELD_DATA(FRACTIONAL_TIMESTAMP_RID, R_OPT, FLOAT32),
#endif
}; };
static struct lwm2m_engine_obj_inst inst[MAX_INSTANCE_COUNT]; static struct lwm2m_engine_obj_inst inst[MAX_INSTANCE_COUNT];
@ -227,6 +237,12 @@ static struct lwm2m_engine_obj_inst *buzzer_create(uint16_t obj_inst_id)
INIT_OBJ_RES_DATA(DIGITAL_INPUT_STATE_RID, res[avail], i, INIT_OBJ_RES_DATA(DIGITAL_INPUT_STATE_RID, res[avail], i,
res_inst[avail], j, &buzzer_data[avail].active, res_inst[avail], j, &buzzer_data[avail].active,
sizeof(buzzer_data[avail].active)); sizeof(buzzer_data[avail].active));
#if defined(CONFIG_LWM2M_IPSO_BUZZER_VERSION_1_1)
INIT_OBJ_RES_OPTDATA(TIMESTAMP_RID, res[avail], i, res_inst[avail], j);
INIT_OBJ_RES_OPTDATA(FRACTIONAL_TIMESTAMP_RID, res[avail], i,
res_inst[avail], j);
#endif
inst[avail].resources = res[avail]; inst[avail].resources = res[avail];
inst[avail].resource_count = i; inst[avail].resource_count = i;