Expand description
Telegrams as JSON, without allocating: Display adapters that write one object.
use mbus_kit::{json::Json, Application};
let app = Application::parse(0x78, &[0x0C, 0x13, 0x27, 0x04, 0x85, 0x02])?;
assert_eq!(
Json::new(&app).to_string(),
r#"{"meter":null,"ci":"78","authenticity":"none","body":"records","records":[{"name":"volume","function":"instantaneous","storage":0,"tariff":0,"subunit":0,"modifiers":[],"value":2850.427,"unit":"m3","text":"volume — 2850.427 m³"}]}"#
);Schema (one object per telegram; fields in this order, absent ones left out):
| Field | Type | Meaning |
|---|---|---|
meter | object or null | manufacturer (3 letters), id (8 digits, or 8 hex digits when not BCD), version, medium (name), medium_code |
ci | string | the CI field, two hex digits |
access, status | number | from the transport header, if it has one |
rssi_dbm | number | when given with Json::rssi |
authenticity | string | none, encrypted (decrypted, not integrity-protected) or authenticated |
counter | number | the message counter the MAC or tag covers (authenticated only) |
body | string | records, encrypted, compact, format, fragment, application_error, alarm, empty |
security | string | for encrypted: mode5, mode7, mode10, ell, mode<n> |
signature | string | for compact and format: the format signature, four hex digits |
bytes | string | for application_error and alarm: the payload in hex |
records | array | for records: see below |
manufacturer_data | string | bytes after a 0F/1F DIF, in hex |
A record is name, function, storage, tariff, subunit, modifiers (strings),
then value and unit: an exact decimal number literal with an ASCII unit code
(m3, Wh, degC, m3/h, …) when the record is a quantity; otherwise a string (dates
and times in ISO 8601, text, hex bytes) or null (no value, NaN, invalid BCD). Then
encrypted (true when the record came out of decryption) and text, the record’s
one-line description. A compact profile has "value":null and a profile object:
direction (forward, backward, registers), elements_are (readings,
increments, decrements, differences), spacing ({"every":15,"unit":"s"},
months as "mo", or "columns") and elements, exact numbers in the record’s unit
(null for the “illegal” preset). A record that does not parse is
{"error": "…"}, and the list ends there. Strings are escaped per RFC 8259.
Structs§
- Json
- One telegram as a JSON object.
- Json
Address - A meter address as the JSON object used for
meter. - Json
Record - One record as a JSON object (the elements of
recordsinJson). - Json
String - A string as a JSON string literal, quotes included.