Returning CoAP content
To illustrate how to return content in CoAP, let's look at the plain text example. The XML and JSON examples are analogous. Content encoding and decoding is based on the same encoding/decoding principles as defined in the Waher.Content library, which maps objects in memory to and from their corresponding Internet Content Types and binary encodings. CoAP works with Content Format codes instead, and a much-reduced set of Internet Content Types that are supported, as described earlier. So, to return plain text, we simply build a string and return it as follows. We've chosen a block size of 64 bytes. Any payload larger than this will be automatically divided into blocks, each one sent separately. The blocks are automatically ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access