sml-kit

The wire format

SML transport v1, the type-length encoding, messages and list entries, byte by byte.

On this page
  1. Transport v1
  2. Type-length encoding
  3. A message
  4. A list entry
  5. SML_Time
  6. Server ID
  7. A typical telegram
  8. A parameter tree

Transport v1๐Ÿ”—

1b 1b 1b 1b  01 01 01 01      start
76 โ€ฆ                          SML messages
00 00                         padding to a multiple of 4
1b 1b 1b 1b  1a 02 c1 c2      end: 1a, padding count, CRC

After the start sequence the stream is read in 4-byte words. A word of four 0x1b is an escape, and the next word is a command:

CommandMeaning
1b 1b 1b 1bThe payload itself contains four 0x1b here
01 01 01 01A new frame starts (the current one is lost)
1a pp cc ccEnd of frame: pp padding bytes, then the CRC

The CRC is CRC-16/X-25 over every transmitted byte from the start sequence up to and including the padding count, sent low byte first. Every CRC-valid real-meter capture in the corpus agrees. (Some Holley DTZ541 compute CRC-16/KERMIT instead; see Meter quirks.)

Type-length encoding๐Ÿ”—

Every value starts with a TL byte:

bit   7      6 5 4    3 2 1 0
     more    type     length
Type bitsTypeLength means
000octet stringbytes including the TL bytes
100booleanbytes including the TL byte (always 2)
101integerbytes including the TL byte (2โ€“9)
110unsignedbytes including the TL byte (2โ€“9)
111listnumber of elements

When more is set, another TL byte follows. Its low nibble extends the length, most significant first. Two bytes are special:

  • 0x01 is an empty octet string: SML's marker for an absent optional field.
  • 0x00 is the end of a message, not a value.

Examples: 07 01 00 01 08 00 ff is the OBIS code 1-0:1.8.0*255; 62 1e is unsigned 30 (the unit Wh); 52 ff is integer โˆ’1 (the scaler 10โปยน); 76 is a list of six.

A message๐Ÿ”—

76                    List(6) SML_Message
  05 41 42 43 01        transactionId
  62 00                 groupNo
  62 00                 abortOnError
  72                    messageBody: List(2)
    65 00 00 07 01        tag: GetList.Res
    77 โ€ฆ                  body: List(7)
  63 cc cc              crc16 over the message up to here, low byte first
00                    end of message

The CRC field is an Unsigned16, but a sender may drop a leading zero byte: 62 cc is valid too (ISKRA MT691 does it).

A list entry๐Ÿ”—

77                    SML_ListEntry: List(7)
  07 01 00 01 08 00 ff  objName     1-0:1.8.0*255
  01                    status      absent
  01                    valTime     absent
  62 1e                 unit        30 = Wh
  52 ff                 scaler      โˆ’1
  59 00 00 00 00 07 5b cd 15
                        value       123456789
  01                    valueSignature absent

123456789 ร— 10โปยน Wh = 12345678.9 Wh, which Quantity keeps exact.

A value can also be a time (SML_ListType, choice 1): 72 62 01 followed by an SML_Time. sml-kit reads it as SmlValue::Time.

SML_Time๐Ÿ”—

72  62 01  65 00 01 02 03     secIndex: seconds since a device epoch
72  62 02  65 65 5f 1c 00     timestamp: seconds since 1970 (UTC)
72  62 03  73 65 โ€ฆ 53 โ€ฆ 53 โ€ฆ  localTimestamp: timestamp, local and season offset (minutes)

Server ID๐Ÿ”—

A German meter's 10-byte server ID is type ยท medium ยท manufacturer (3 letters) ยท block ยท serial (u32): 0a 01 49 53 4b 00 04 7a 55 44 is printed on the meter as 1 ISK00 75126084, and ServerId displays it that way.

A typical telegram๐Ÿ”—

A basic meter's push telegram is one frame with three messages:

  1. OpenResponse with the server ID,
  2. GetListResponse with the readings,
  3. CloseResponse.

A parameter tree๐Ÿ”—

73                    SML_Tree: List(3)
  07 81 81 c7 82 01 ff  parameterName   device identification
  01                    parameterValue  absent: a node
  73                    child_List: List(3)
    73                    SML_Tree
      07 81 81 c7 82 03 ff  manufacturer
      72 62 01 04 45 4d 48  value: choice 1 (SML_Value), "EMH"
      01                    no children
    โ€ฆ

SML_ProcParValue is List(2) { choice, value }: 1 value, 2 period entry, 3 tupel entry, 4 time, 5 list entry.

Edit this page on GitHub