The Sensor Measurement Lists (SenML) media types [
RFC 8428] can be used to send various kinds of data. In the example given in
Figure 1, a temperature value, an indication whether a lock is open, and a Data Value (with SenML field "vd") read from a Near Field Communication (NFC) reader is sent in a single SenML Pack. The example is given in SenML JSON representation, so the "vd" (Data Value) field is encoded as a base64url string (without padding), as per
Section 5 of
RFC 8428.
[
{"bn":"urn:dev:ow:10e2073a01080063:","n":"temp","u":"Cel","v":7.1},
{"n":"open","vb":false},
{"n":"nfc-reader","vd":"aGkgCg"}
]
The receiver is expected to know how to interpret the data in the "vd" field based on the context, e.g., the name of the data source and out-of-band knowledge of the application. However, this context may not always be easily available to entities processing the SenML Pack, especially if the Pack is propagated over time and via multiple entities. To facilitate automatic interpretation, it is useful to be able to indicate an Internet media type and, optionally, content codings right in the SenML Record.
The Constrained Application Protocol (CoAP) Content-Format (
Section 12.3 of
RFC 7252) provides this information in the form of a single unsigned integer. For instance, [
RFC 8949] defines the Content-Format number 60 for Content-Type application/cbor. Enclosing this Content-Format number in the Record is illustrated in
Figure 2. All registered CoAP Content-Format numbers are listed in the "[
IANA.core-parameters]" registry [
IANA.core-parameters], as specified by
Section 12.3 of
RFC 7252. Note that, at the time of writing, the structure of this registry only provides for zero or one content coding; nothing in the present document needs to change if the registry is extended to allow sequences of content codings.
{"n":"nfc-reader", "vd":"gmNmb28YKg", "ct":"60"}
In this example SenML Record, the Data Value contains a string "foo" and a number 42 encoded in a Concise Binary Object Representation (CBOR) [
RFC 8949] array. Since the example above uses the JSON format of SenML, the Data Value containing the binary CBOR value is base64 encoded (
Section 5 of
RFC 4648). The Data Value after base64 decoding is shown with CBOR diagnostic notation in
Figure 3.
82 # array(2)
63 # text(3)
666F6F # "foo"
18 2A # unsigned(42)
As with SenML in general, there is no expectation that the creator of a SenML Pack knows (or has negotiated with) each consumer of that Pack, which may be very remote in space and particularly in time. This means that the SenML creator in general has no way to know whether the consumer knows:
-
each specific Media-Type-Name used,
-
each parameter and each parameter value used,
-
each content coding in use, and
-
each Content-Format number in use for a combination of these.
What SenML, as well as the new fields defined here, guarantees is that a recipient implementation
knows when it needs to be updated to understand these field values and the values controlled by them; registries are used to evolve these name spaces in a controlled way. SenML Packs can be processed by a consumer while not understanding all the information in them, and information can generally be preserved in this processing such that it is useful for further consumers.