O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required