Skip to content

Commit

Permalink
app: Make app_object schema future proof
Browse files Browse the repository at this point in the history
Extended the schema by adding 'any' type members so that the
schema is future proof and the app can respond to any new
additional fields that may be populated by the cloud side

Signed-off-by: Balaji Srinivasan <[email protected]>
  • Loading branch information
Balaji Srinivasan authored and simensrostad committed Jun 5, 2024
1 parent 0d21a0e commit 0665ea4
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions app/src/modules/app/app_object.cddl
Original file line number Diff line number Diff line change
@@ -1,41 +1,53 @@
; Define the basic structure of the JSON object

; The 'any' type is used in this schema to allow forward compatibility.
; They are inserted into maps that may contain additional fields in the future.
; This prevents cbor decoding from failing in the field when the cloud side has new fields.
app-object = {
? "nrfcloud_mqtt_topic_prefix": tstr,
? "pairing": pairing-type,
"lwm2m": lwm2m-map
"lwm2m": lwm2m-map,
* tstr => any
}

; Define the pairing object with nested topics
pairing-type = {
"state": tstr,
"topics": {
"d2c": tstr,
"c2d": tstr
}
"c2d": tstr,
* tstr => any
},
* any => any
}

lwm2m-map = {
? "14240:1.0": led,
? "14301:1.0": config
? "14301:1.0": config,
* tstr => any
}

led = {
"0": led_inner_object
"0": led_inner_object,
* tstr => any
}

led_inner_object = {
"0": int .size 4,
"1": int .size 4,
"2": int .size 4,
"99": int .size 8
"99": int .size 8,
* tstr => any
}

config = {
"0": config_inner_object
"0": config_inner_object,
* tstr => any
}

config_inner_object = {
"0": int .size 8,
"1": bool,
"99": int .size 8
"99": int .size 8,
* tstr => any
}

0 comments on commit 0665ea4

Please sign in to comment.