Skip to content
Permalink
Browse files

net: lwm2m: add missing application type to IPSO Light Control

Per IPSO Light Control definition from the OMA LwM2M registry:
http://www.openmobilealliance.org/tech/profiles/lwm2m/3311.xml

There is an optional "Application Type" string resource (5750) in the
Light Control object.  This was missed in the initial implementation.

NOTE: sample will assign reference if needed.

Signed-off-by: Michael Scott <mike@foundries.io>
  • Loading branch information...
mike-scott authored and jukkar committed Jul 29, 2019
1 parent a33a6f7 commit 9534bbd991cf14a4bf3ad3188a55bbe147db3ee8
Showing with 8 additions and 1 deletion.
  1. +4 −0 samples/net/lwm2m_client/src/lwm2m-client.c
  2. +4 −1 subsys/net/lib/lwm2m/ipso_light_control.c
@@ -46,6 +46,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define CLIENT_DEVICE_TYPE "OMA-LWM2M Client"
#define CLIENT_HW_VER "1.0.1"

#define LIGHT_NAME "Test light"
#define TIMER_NAME "Test timer"

#define ENDPOINT_LEN 32
@@ -337,6 +338,9 @@ static int lwm2m_setup(void)
lwm2m_engine_create_obj_inst("3311/0");
lwm2m_engine_register_post_write_callback("3311/0/5850",
led_on_off_cb);
lwm2m_engine_set_res_data("3311/0/5750",
LIGHT_NAME, sizeof(LIGHT_NAME),
LWM2M_RES_DATA_FLAG_RO);
}

/* IPSO: Timer object */
@@ -31,8 +31,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define LIGHT_POWER_FACTOR_ID 5820
#define LIGHT_COLOUR_ID 5706
#define LIGHT_SENSOR_UNITS_ID 5701
#define LIGHT_APPLICATION_TYPE_ID 5750

#define LIGHT_MAX_ID 7
#define LIGHT_MAX_ID 8

#define MAX_INSTANCE_COUNT CONFIG_LWM2M_IPSO_LIGHT_CONTROL_INSTANCE_COUNT

@@ -58,6 +59,7 @@ static struct lwm2m_engine_obj_field fields[] = {
OBJ_FIELD_DATA(LIGHT_POWER_FACTOR_ID, R_OPT, FLOAT32),
OBJ_FIELD_DATA(LIGHT_COLOUR_ID, RW_OPT, STRING),
OBJ_FIELD_DATA(LIGHT_SENSOR_UNITS_ID, R_OPT, STRING),
OBJ_FIELD_DATA(LIGHT_APPLICATION_TYPE_ID, RW_OPT, STRING),
};

static struct lwm2m_engine_obj_inst inst[MAX_INSTANCE_COUNT];
@@ -166,6 +168,7 @@ static struct lwm2m_engine_obj_inst *light_control_create(u16_t obj_inst_id)
colour[avail], LIGHT_STRING_LONG);
INIT_OBJ_RES_DATA(res[avail], i, LIGHT_SENSOR_UNITS_ID,
units[avail], LIGHT_STRING_SHORT);
INIT_OBJ_RES_DUMMY(res[avail], i, LIGHT_APPLICATION_TYPE_ID);

inst[avail].resources = res[avail];
inst[avail].resource_count = i;

0 comments on commit 9534bbd

Please sign in to comment.
You can’t perform that action at this time.