The Binary format is used when higher performance or shorter network frames are needed.
For MQTT 5: The Payload Format Indicator is always 0 (Binary), except if the PLC data type is "String", for which it is 1 (String). The Content Type is a textual representation of the PLC data type, optionally followed by a comma separated list of PLC data type flags.
For MQTT 3.1/3.1.1: The data type can not be transferred using this protocol. Either configure the type on all systems equal or use one of the other protocol options.
Note: all examples are given as hexdump.
Numeric value (42)
2A 00
Bit-Array (1, 0, 1, 0)
0A
Structure (First: int = 1, Second: String = "String Value")
01 00 00 00 04 00 00 00 53 74 72 69 6E 67 20 56 61 6C 75 65
The JSON data format is used to transfer data to/from systems that have difficulties with binary data. It consists of a JSON objects with the following properties.
For MQTT 5: The Payload Format Indicator is always 1 (String), the Content Type is "application/json"
Numeric value 42
{
"Type": "Uint16",
"Value": (42)
}
Bit-Array (1, 0, 1, 0)
{
"Type": "Boolean",
"Value": [
true,
false,
true,
false
]
}
Structure (First: int = 1, Second: String = "String Value")
{
"Type": "Structure",
"StructureName": "MyValues",
"Value": {
"First": 1,
"Second": "String Value",
}
}
The XML data format is used to transfer data to/from systems that can't handle binary or JSON data. It recreates the JSON data described above as XML.
For MQTT 5: The Payload Format Indicator is always 1 (String), the Content Type is "text/xml"
See the JSON data described above.
Numeric value (42)
<o>
<s n="Type">Uint16</s>
<i n="Value">42</i>
</o>
Bit-Array (1, 0, 1, 0)
<o>
<s n="Type">Boolean</s>
<a n="Value">
<t/>
<f/>
<t/>
<f/>
</a>
</o>
Structure (First: int = 1, Second: String = "String Value")
<o>
<s n="Type">Structure</s>
<s n="StructureName">MyValues</s>
<o n=Value>
<i n="First">1</i>
<s n="Second">String Value</s>
</o>
</o>
Name | Meaning |
---|---|
Boolean | Binary value (true or false) |
SByte, Int16, Int32, Int64 | Signed integers of 1, 2, 4 or 8 bytes length |
Byte, UInt16, UInt32, UInt64 | Unsigned integers of 1, 2, 4 or 8 bytes length |
Float, Double | Floating point values of 4 or 8 bytes length |
String | Character String |
DateTime | Timestamp with date and time |
Structure | Structured data |
Enumeration | Enumerated data |
LocalizedText | String with multiple possible translations |
Flag | Meaning |
---|---|
BigEndian | Data is in big endian (most-significant byte first) order |
LittleEndian | Data is in little endian (least-significant byte first) order. Note: only one of LittleEndian and BigEndian should be specified. |
BitArrayLen1, BitArrayLen2, ... BitArrayLen7 | Indicate the number of valid bits in the last byte of a bit array. Not specifying one of these makes all 8 bits valid. |