Reputation: 369
I am very new to this mqtt-sn stuff. So my question is - how does a mqtt-sn message look like. So I mean the raw data format. I do not clearly understand what octet means. So as I understand an octet is a byte.
So is the data transferred binary?
Or what means octet exact?
Please can someone give me a sample message. It is really bad that there is not example message in the specification.
Thanks, Mathias
Upvotes: 0
Views: 1179
Reputation: 59751
An octet is just a collection of 8 bit so just another name for a byte
So a message consists of a header made up of 2 or 4 bytes and the the message body.
The header is sub divided into 1 OR 3 bytes for the length and 1 byte for the type. If the first byte is 0x01 then the next 2 bytes are the length, else the value of the first byte is the length.
The next byte is a type, a table of valid message types can be found in sections 5.2.2 in the spec
The Message body varies depending on the type.
But to publish a message with payload HelloWorld
on Topic ID of AB (0x41, 0x42) would look something like this:
0x0F - length (15 bytes total, including length)
0x0C - msg type (publish)
0x02 - flags (QOS 0, topic name)
0x41 - topic ID 1
0x42 - topic ID 2
0x00 - MsgID (00 for QOS 0)
0x48 - H
0x65 - e
0x6C - l
0x6C - l
0x6F - o
0x57 - W
0x6F - o
0x72 - r
0x6C - l
0x64 - d
Where the topic id is the output from a topic register message (Section 6.5 in the spec)
Upvotes: 1
Reputation: 11618
An octet is a byte.
There isn't an example payload because the spec doesn't dictate a payload format. You can use whatever you want.
Upvotes: 0