Schema Reference
A data model file has three top-level sections: [meta], [enums], and
[[classes]].
Meta
[meta]
id = "my_device" # Namespace identifier (required)
version = "1.0.0" # Semantic version (required)
doc = "Description" # Optional documentation
The id is used to prefix all generated #define names:
DM_KEY_{ID}_{CLASS}_{KEY}.
Enums
Enums define named integer-to-label mappings reusable across keys.
[enums.mode]
doc = "Operating mode"
[enums.mode.values]
off = 0
idle = 1
active = 2
# Optional: per-variant overrides
[enums.mode.variants.compact]
off = 0
active = 1
Reference an enum on a key with enum = "mode". The enum values appear as
comments in the generated key_definitions.h.
Classes
Classes group related keys within a namespace. A namespace can have up to 31 classes, each with up to 1023 keys.
[[classes]]
id = "status"
doc = "Runtime status"
[[classes.keys]]
id = "temperature"
type = "uint16"
# ... attributes
Key Attributes
Attribute |
Type |
Default |
Description |
|---|---|---|---|
|
string |
(required) |
Key identifier |
|
string |
(required) |
Data type (see below) |
|
value |
type zero |
Default value |
|
table |
|
Per-variant default overrides |
|
string |
none |
Reference to an |
|
integer |
none |
Max bytes (required for string/binary) |
|
bool |
|
Prevent modification at runtime |
|
bool |
|
Protect with target mutex |
|
bool |
|
Include in binary save/load |
|
bool |
|
Fire callback on value change |
|
bool |
|
Generate named getter/setter functions |
|
string |
none |
Physical unit (documentary) |
|
string |
none |
Documentation string |
Data Types
Type |
C Type |
Size |
Notes |
|---|---|---|---|
|
|
1 bit |
Packed into uint32_t bitfields |
|
|
1 byte |
|
|
|
1 byte |
|
|
|
2 bytes |
|
|
|
2 bytes |
|
|
|
4 bytes |
|
|
|
4 bytes |
|
|
|
max_size |
Requires |
|
|
max_size |
Requires |
Per-Variant Defaults
Keys can have different default values for different product variants:
[[classes.keys]]
id = "threshold"
type = "uint8"
default = 10 # Base default
[classes.keys.defaults]
compact = 5 # Override for "compact" variant
pro = 15 # Override for "pro" variant
The base default applies when no variant-specific override exists.
Constraints
stringandbinarytypes must specifymax_sizeread_onlykeys cannot bepersistent(validated at parse time)enumreferences must point to a defined[enums]entryClass IDs must be unique within a namespace
Key IDs must be unique within a class