Skip to content

Commit

Permalink
modules: app: Make LwM2M object optional
Browse files Browse the repository at this point in the history
Make LwM2M object optional, new devices will not have the LwM2M object
present in their shadow.

Signed-off-by: Simen S. Røstad <[email protected]>
  • Loading branch information
simensrostad committed Jun 25, 2024
1 parent 4068895 commit b15b618
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
33 changes: 19 additions & 14 deletions app/src/modules/app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,35 @@ static void shadow_get(bool get_desired)
return;
}

if (!app_object.lwm2m_present) {
LOG_DBG("No LwM2M object present in shadow, ignoring");
return;
}

struct configuration configuration = { 0 };

if (app_object.lwm2m._1424010_present) {
if (app_object.lwm2m.lwm2m._1424010_present) {
configuration.led_present = true;
configuration.led_red = app_object.lwm2m._1424010._1424010._0._0;
configuration.led_green = app_object.lwm2m._1424010._1424010._0._1;
configuration.led_blue = app_object.lwm2m._1424010._1424010._0._2;
configuration.led_red = app_object.lwm2m.lwm2m._1424010._1424010._0._0;
configuration.led_green = app_object.lwm2m.lwm2m._1424010._1424010._0._1;
configuration.led_blue = app_object.lwm2m.lwm2m._1424010._1424010._0._2;

LOG_DBG("LED object (1424010) values received from cloud:");
LOG_DBG("R: %d", app_object.lwm2m._1424010._1424010._0._0);
LOG_DBG("G: %d", app_object.lwm2m._1424010._1424010._0._1);
LOG_DBG("B: %d", app_object.lwm2m._1424010._1424010._0._2);
LOG_DBG("Timestamp: %lld", app_object.lwm2m._1424010._1424010._0._99);
LOG_DBG("R: %d", app_object.lwm2m.lwm2m._1424010._1424010._0._0);
LOG_DBG("G: %d", app_object.lwm2m.lwm2m._1424010._1424010._0._1);
LOG_DBG("B: %d", app_object.lwm2m.lwm2m._1424010._1424010._0._2);
LOG_DBG("Timestamp: %lld", app_object.lwm2m.lwm2m._1424010._1424010._0._99);
}

if (app_object.lwm2m._1430110_present) {
if (app_object.lwm2m.lwm2m._1430110_present) {
configuration.config_present = true;
configuration.update_interval = app_object.lwm2m._1430110._1430110._0._0;
configuration.gnss = app_object.lwm2m._1430110._1430110._0._1;
configuration.update_interval = app_object.lwm2m.lwm2m._1430110._1430110._0._0;
configuration.gnss = app_object.lwm2m.lwm2m._1430110._1430110._0._1;

LOG_DBG("Application configuration object (1430110) values received from cloud:");
LOG_DBG("Update interval: %lld", app_object.lwm2m._1430110._1430110._0._0);
LOG_DBG("GNSS: %d", app_object.lwm2m._1430110._1430110._0._1);
LOG_DBG("Timestamp: %lld", app_object.lwm2m._1430110._1430110._0._99);
LOG_DBG("Update interval: %lld", app_object.lwm2m.lwm2m._1430110._1430110._0._0);
LOG_DBG("GNSS: %d", app_object.lwm2m.lwm2m._1430110._1430110._0._1);
LOG_DBG("Timestamp: %lld", app_object.lwm2m.lwm2m._1430110._1430110._0._99);
}

/* Distribute configuration */
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/app/app_object.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
app-object = {
? "nrfcloud_mqtt_topic_prefix": tstr,
? "pairing": pairing-type,
"lwm2m": lwm2m-map,
? "lwm2m": lwm2m-map,
* tstr => any
}

Expand Down

0 comments on commit b15b618

Please sign in to comment.