Skip to content

Commit

Permalink
net: lwm2m: add missing application type to IPSO Light Control
Browse files Browse the repository at this point in the history
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 Aug 2, 2019
1 parent a33a6f7 commit 9534bbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions samples/net/lwm2m_client/src/lwm2m-client.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define CLIENT_DEVICE_TYPE "OMA-LWM2M Client" #define CLIENT_DEVICE_TYPE "OMA-LWM2M Client"
#define CLIENT_HW_VER "1.0.1" #define CLIENT_HW_VER "1.0.1"


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


#define ENDPOINT_LEN 32 #define ENDPOINT_LEN 32
Expand Down Expand Up @@ -337,6 +338,9 @@ static int lwm2m_setup(void)
lwm2m_engine_create_obj_inst("3311/0"); lwm2m_engine_create_obj_inst("3311/0");
lwm2m_engine_register_post_write_callback("3311/0/5850", lwm2m_engine_register_post_write_callback("3311/0/5850",
led_on_off_cb); 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 */ /* IPSO: Timer object */
Expand Down
5 changes: 4 additions & 1 deletion subsys/net/lib/lwm2m/ipso_light_control.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define LIGHT_POWER_FACTOR_ID 5820 #define LIGHT_POWER_FACTOR_ID 5820
#define LIGHT_COLOUR_ID 5706 #define LIGHT_COLOUR_ID 5706
#define LIGHT_SENSOR_UNITS_ID 5701 #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 #define MAX_INSTANCE_COUNT CONFIG_LWM2M_IPSO_LIGHT_CONTROL_INSTANCE_COUNT


Expand All @@ -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_POWER_FACTOR_ID, R_OPT, FLOAT32),
OBJ_FIELD_DATA(LIGHT_COLOUR_ID, RW_OPT, STRING), OBJ_FIELD_DATA(LIGHT_COLOUR_ID, RW_OPT, STRING),
OBJ_FIELD_DATA(LIGHT_SENSOR_UNITS_ID, R_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]; static struct lwm2m_engine_obj_inst inst[MAX_INSTANCE_COUNT];
Expand Down Expand Up @@ -166,6 +168,7 @@ static struct lwm2m_engine_obj_inst *light_control_create(u16_t obj_inst_id)
colour[avail], LIGHT_STRING_LONG); colour[avail], LIGHT_STRING_LONG);
INIT_OBJ_RES_DATA(res[avail], i, LIGHT_SENSOR_UNITS_ID, INIT_OBJ_RES_DATA(res[avail], i, LIGHT_SENSOR_UNITS_ID,
units[avail], LIGHT_STRING_SHORT); units[avail], LIGHT_STRING_SHORT);
INIT_OBJ_RES_DUMMY(res[avail], i, LIGHT_APPLICATION_TYPE_ID);


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

0 comments on commit 9534bbd

Please sign in to comment.