draft-ietf-core-senml-02.txt   draft-ietf-core-senml-03.txt 
Network Working Group C. Jennings Network Working Group C. Jennings
Internet-Draft Cisco Internet-Draft Cisco
Intended status: Standards Track Z. Shelby Intended status: Standards Track Z. Shelby
Expires: January 9, 2017 ARM Expires: April 10, 2017 ARM
J. Arkko J. Arkko
A. Keranen A. Keranen
Ericsson Ericsson
C. Bormann C. Bormann
Universitaet Bremen TZI Universitaet Bremen TZI
July 8, 2016 October 7, 2016
Media Types for Sensor Markup Language (SenML) Media Types for Sensor Markup Language (SenML)
draft-ietf-core-senml-02 draft-ietf-core-senml-03
Abstract Abstract
This specification defines media types for representing simple sensor This specification defines media types for representing simple sensor
measurements and device parameters in the Sensor Markup Language measurements and device parameters in the Sensor Markup Language
(SenML). Representations are defined in JavaScript Object Notation (SenML). Representations are defined in JavaScript Object Notation
(JSON), Concise Binary Object Representation (CBOR), eXtensible (JSON), Concise Binary Object Representation (CBOR), eXtensible
Markup Language (XML), and Efficient XML Interchange (EXI), which Markup Language (XML), and Efficient XML Interchange (EXI), which
share the common SenML data model. A simple sensor, such as a share the common SenML data model. A simple sensor, such as a
temperature sensor, could use this media type in protocols such as temperature sensor, could use this media type in protocols such as
skipping to change at page 1, line 44 skipping to change at page 1, line 44
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/. Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on January 9, 2017. This Internet-Draft will expire on April 10, 2017.
Copyright Notice Copyright Notice
Copyright (c) 2016 IETF Trust and the persons identified as the Copyright (c) 2016 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
skipping to change at page 2, line 28 skipping to change at page 2, line 28
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Requirements and Design Goals . . . . . . . . . . . . . . . . 4 2. Requirements and Design Goals . . . . . . . . . . . . . . . . 4
3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 5 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 5
4. SenML Structure and Semantics . . . . . . . . . . . . . . . . 5 4. SenML Structure and Semantics . . . . . . . . . . . . . . . . 5
4.1. Base attributes . . . . . . . . . . . . . . . . . . . . . 5 4.1. Base attributes . . . . . . . . . . . . . . . . . . . . . 5
4.2. Regular attributes . . . . . . . . . . . . . . . . . . . 6 4.2. Regular attributes . . . . . . . . . . . . . . . . . . . 6
4.3. Considerations . . . . . . . . . . . . . . . . . . . . . 6 4.3. Considerations . . . . . . . . . . . . . . . . . . . . . 7
4.4. Associating Meta-data . . . . . . . . . . . . . . . . . . 8 4.4. Resolved Records . . . . . . . . . . . . . . . . . . . . 8
5. JSON Representation (application/senml+json) . . . . . . . . 8 4.5. Associating Meta-data . . . . . . . . . . . . . . . . . . 8
5.1. Examples . . . . . . . . . . . . . . . . . . . . . . . . 9 5. JSON Representation (application/senml+json) . . . . . . . . 9
5.1.1. Single Datapoint . . . . . . . . . . . . . . . . . . 9 5.1. Examples . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1.2. Multiple Datapoints . . . . . . . . . . . . . . . . . 9 5.1.1. Single Datapoint . . . . . . . . . . . . . . . . . . 10
5.1.2. Multiple Datapoints . . . . . . . . . . . . . . . . . 10
5.1.3. Multiple Measurements . . . . . . . . . . . . . . . . 11 5.1.3. Multiple Measurements . . . . . . . . . . . . . . . . 11
5.1.4. Collection of Resources . . . . . . . . . . . . . . . 12 5.1.4. Resolved Data . . . . . . . . . . . . . . . . . . . . 12
6. CBOR Representation (application/senml+cbor) . . . . . . . . 12 5.1.5. Multiple Data Types . . . . . . . . . . . . . . . . . 12
7. XML Representation (application/senml+xml) . . . . . . . . . 13 5.1.6. Collection of Resources . . . . . . . . . . . . . . . 13
8. EXI Representation (application/senml-exi) . . . . . . . . . 15 6. CBOR Representation (application/senml+cbor) . . . . . . . . 13
9. Usage Considerations . . . . . . . . . . . . . . . . . . . . 17 7. XML Representation (application/senml+xml) . . . . . . . . . 15
10. CDDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 8. EXI Representation (application/senml+exi) . . . . . . . . . 17
11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 20 9. Usage Considerations . . . . . . . . . . . . . . . . . . . . 20
11.1. Units Registry . . . . . . . . . . . . . . . . . . . . . 20 10. CDDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
11.2. SenML label registry . . . . . . . . . . . . . . . . . . 24 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 22
11.3. Media Type Registration . . . . . . . . . . . . . . . . 24 11.1. Units Registry . . . . . . . . . . . . . . . . . . . . . 23
11.3.1. senml+json Media Type Registration . . . . . . . . . 24 11.2. SenML Label Registry . . . . . . . . . . . . . . . . . . 26
11.3.2. senml+cbor Media Type Registration . . . . . . . . . 25 11.3. Media Type Registration . . . . . . . . . . . . . . . . 27
11.3.3. senml+xml Media Type Registration . . . . . . . . . 26 11.3.1. senml+json Media Type Registration . . . . . . . . . 27
11.3.4. senml-exi Media Type Registration . . . . . . . . . 27 11.3.2. senml+cbor Media Type Registration . . . . . . . . . 29
11.4. XML Namespace Registration . . . . . . . . . . . . . . . 28 11.3.3. senml+xml Media Type Registration . . . . . . . . . 29
11.5. CoAP Content-Format Registration . . . . . . . . . . . . 28 11.3.4. senml+exi Media Type Registration . . . . . . . . . 30
12. Security Considerations . . . . . . . . . . . . . . . . . . . 28 11.4. XML Namespace Registration . . . . . . . . . . . . . . . 31
13. Privacy Considerations . . . . . . . . . . . . . . . . . . . 28 11.5. CoAP Content-Format Registration . . . . . . . . . . . . 31
14. Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . 29 12. Security Considerations . . . . . . . . . . . . . . . . . . . 32
15. References . . . . . . . . . . . . . . . . . . . . . . . . . 29 13. Privacy Considerations . . . . . . . . . . . . . . . . . . . 32
15.1. Normative References . . . . . . . . . . . . . . . . . . 29 14. Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . 32
15.2. Informative References . . . . . . . . . . . . . . . . . 30 15. References . . . . . . . . . . . . . . . . . . . . . . . . . 32
Appendix A. Links extension . . . . . . . . . . . . . . . . . . 31 15.1. Normative References . . . . . . . . . . . . . . . . . . 32
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 31 15.2. Informative References . . . . . . . . . . . . . . . . . 34
Appendix A. Links Extension . . . . . . . . . . . . . . . . . . 35
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 35
1. Overview 1. Overview
Connecting sensors to the Internet is not new, and there have been Connecting sensors to the Internet is not new, and there have been
many protocols designed to facilitate it. This specification defines many protocols designed to facilitate it. This specification defines
new media types for carrying simple sensor information in a protocol new media types for carrying simple sensor information in a protocol
such as HTTP or CoAP. This format was designed so that processors such as HTTP or CoAP. This format was designed so that processors
with very limited capabilities could easily encode a sensor with very limited capabilities could easily encode a sensor
measurement into the media type, while at the same time a server measurement into the media type, while at the same time a server
parsing the data could relatively efficiently collect a large number parsing the data could relatively efficiently collect a large number
skipping to change at page 3, line 47 skipping to change at page 4, line 5
single array that contains a series of SenML Records which can each single array that contains a series of SenML Records which can each
contain attributes such as an unique identifier for the sensor, the contain attributes such as an unique identifier for the sensor, the
time the measurement was made, the unit the measurement is in, and time the measurement was made, the unit the measurement is in, and
the current value of the sensor. Serializations for this data model the current value of the sensor. Serializations for this data model
are defined for JSON [RFC7159], CBOR [RFC7049], XML, and Efficient are defined for JSON [RFC7159], CBOR [RFC7049], XML, and Efficient
XML Interchange (EXI) [W3C.REC-exi-20110310]. XML Interchange (EXI) [W3C.REC-exi-20110310].
For example, the following shows a measurement from a temperature For example, the following shows a measurement from a temperature
gauge encoded in the JSON syntax. gauge encoded in the JSON syntax.
[{ "n": "urn:dev:ow:10e2073a01080063", "v":23.1, "u":"Cel" }] [
{"n":"urn:dev:ow:10e2073a01080063","u":"Cel","v":23.1}
]
In the example above, the array has a single SenML Record with a In the example above, the array has a single SenML Record with a
measurement for a sensor named "urn:dev:ow:10e2073a01080063" with a measurement for a sensor named "urn:dev:ow:10e2073a01080063" with a
current value of 23.1 degrees Celsius. current value of 23.1 degrees Celsius.
2. Requirements and Design Goals 2. Requirements and Design Goals
The design goal is to be able to send simple sensor measurements in The design goal is to be able to send simple sensor measurements in
small packets on mesh networks from large numbers of constrained small packets on mesh networks from large numbers of constrained
devices. Keeping the total size of payload under 80 bytes makes this devices. Keeping the total size of payload under 80 bytes makes this
skipping to change at page 4, line 29 skipping to change at page 4, line 37
where the sensor itself sends just a single data item at a time. The where the sensor itself sends just a single data item at a time. The
multiple measurements could be from multiple related sensors or from multiple measurements could be from multiple related sensors or from
the same sensor but at different times. the same sensor but at different times.
The basic design is an array with a series of measurements. The The basic design is an array with a series of measurements. The
following example shows two measurements made at different times. following example shows two measurements made at different times.
The value of a measurement is in the "v" tag, the time of a The value of a measurement is in the "v" tag, the time of a
measurement is in the "t" tag, the "n" tag has a unique sensor name, measurement is in the "t" tag, the "n" tag has a unique sensor name,
and the unit of the measurement is carried in the "u" tag. and the unit of the measurement is carried in the "u" tag.
[ [
{ "n": "urn:dev:ow:10e2073a01080063", {"n":"urn:dev:ow:10e2073a01080063","u":"Cel","t":1.276020076e+09,"v":23.5},
"t": 1276020076, "v":23.5, "u":"Cel" }, {"n":"urn:dev:ow:10e2073a01080063","u":"Cel","t":1.276020091e+09,"v":23.6}
{ "n": "urn:dev:ow:10e2073a01080063", ]
"t": 1276020091, "v":23.6, "u":"Cel" }
]
To keep the messages small, it does not make sense to repeat the "n" To keep the messages small, it does not make sense to repeat the "n"
tag in each SenML Record so there is a concept of a Base Name which tag in each SenML Record so there is a concept of a Base Name which
is simply a string that is prepended to the Name field of all is simply a string that is prepended to the Name field of all
elements in that record and any records that follow it. So a more elements in that record and any records that follow it. So a more
compact form of the example above is the following. compact form of the example above is the following.
[ [
{ "bn": "urn:dev:ow:10e2073a01080063", {"bn":"urn:dev:ow:10e2073a01080063","u":"Cel","t":1.276020076e+09,"v":23.5},
"t": 1276020076, "v":23.5, "u":"Cel" }, {"u":"Cel","t":1.276020091e+09,"v":23.6}
{ "t": 1276020091, "v":23.6, "u":"Cel" } ]
]
In the above example the Base Name is in the "bn" tag and the "n" In the above example the Base Name is in the "bn" tag and the "n"
tags in each Record are the empty string so they are omitted. tags in each Record are the empty string so they are omitted.
Some devices have accurate time while others do not so SenML supports Some devices have accurate time while others do not so SenML supports
absolute and relative times. Time is represented in floating point absolute and relative times. Time is represented in floating point
as seconds and values greater than zero represent an absolute time as seconds and values greater than zero represent an absolute time
relative to the Unix epoch while values of 0 or less represent a relative to the Unix epoch while values of 0 or less represent a
relative time in the past from the current time. A simple sensor relative time in the past from the current time. A simple sensor
with no absolute wall clock time might take a measurement every with no absolute wall clock time might take a measurement every
second and batch up 60 of them then send it to a server. It would second and batch up 60 of them then send it to a server. It would
skipping to change at page 6, line 8 skipping to change at page 6, line 13
Base Time: A base time that is added to the time found in an entry. Base Time: A base time that is added to the time found in an entry.
Base Unit: A base unit that is assumed for all entries, unless Base Unit: A base unit that is assumed for all entries, unless
otherwise indicated. If a record does not contain a Unit value, otherwise indicated. If a record does not contain a Unit value,
then the Base Unit is used. Otherwise the value found in the Unit then the Base Unit is used. Otherwise the value found in the Unit
(if any) is used. (if any) is used.
Base Value: A base value is added to the value found in an entry, Base Value: A base value is added to the value found in an entry,
similar to Base Time. similar to Base Time.
Base Sum: A base sum is added to the sum found in an entry, similar
to Base Time.
Version: Version number of media type format. This attribute is an Version: Version number of media type format. This attribute is an
optional positive integer and defaults to 5 if not present. [RFC optional positive integer and defaults to 5 if not present. [RFC
Editor: change the default value to 10 when this specification is Editor: change the default value to 10 when this specification is
published as an RFC and remove this note] published as an RFC and remove this note]
4.2. Regular attributes 4.2. Regular attributes
Name: Name of the sensor or parameter. When appended to the Base Name: Name of the sensor or parameter. When appended to the Base
Name attribute, this must result in a globally unique identifier Name attribute, this must result in a globally unique identifier
for the resource. The name is optional, if the Base Name is for the resource. The name is optional, if the Base Name is
present. If the name is missing, Base Name must uniquely identify present. If the name is missing, Base Name must uniquely identify
the resource. This can be used to represent a large array of the resource. This can be used to represent a large array of
measurements from the same sensor without having to repeat its measurements from the same sensor without having to repeat its
identifier on every measurement. identifier on every measurement.
Unit: Units for a measurement value. Optional. If the Record has Unit: Units for a measurement value. Optional. If the Record has
no Unit, the Base Unit is used as the Unit. Having no Unit and no no Unit, the Base Unit is used as the Unit. Having no Unit and no
Base Unit is allowed. Base Unit is allowed.
Value Value of the entry. Optional if a Sum value is present, Value Value of the entry. Optional if a Sum value is present,
otherwise required. Values are represented using three basic data otherwise required. Values are represented using basic data
types, Floating point numbers ("v" field for "Value"), Booleans types. This specification defines floating point numbers ("v"
("vb" for "Boolean Value"), Strings ("vs" for "String Value") and field for "Value"), booleans ("vb" for "Boolean Value"), strings
Binary Data ("vd" for "Data Value") . Exactly one of these four ("vs" for "String Value") and binary data ("vd" for "Data Value").
fields MUST appear unless there is Sum field in which case it is Exactly one value field MUST appear unless there is Sum field in
allowed to have no Value field or to have "v" field. which case it is allowed to have no Value field.
Sum: Integrated sum of the values over time. Optional. This Sum: Integrated sum of the values over time. Optional. This
attribute is in the units specified in the Unit value multiplied attribute is in the units specified in the Unit value multiplied
by seconds. by seconds.
Time: Time when value was recorded. Optional. Time: Time when value was recorded. Optional.
Update Time: An optional time in seconds that represents the maximum Update Time: An optional time in seconds that represents the maximum
time before this sensor will provide an updated reading for a time before this sensor will provide an updated reading for a
measurement. This can be used to detect the failure of sensors or measurement. This can be used to detect the failure of sensors or
skipping to change at page 7, line 50 skipping to change at page 8, line 8
If either the Base Time or Time value is missing, the missing If either the Base Time or Time value is missing, the missing
attribute is considered to have a value of zero. The Base Time and attribute is considered to have a value of zero. The Base Time and
Time values are added together to get the time of measurement. A Time values are added together to get the time of measurement. A
time of zero indicates that the sensor does not know the absolute time of zero indicates that the sensor does not know the absolute
time and the measurement was made roughly "now". A negative value is time and the measurement was made roughly "now". A negative value is
used to indicate seconds in the past from roughly "now". A positive used to indicate seconds in the past from roughly "now". A positive
value is used to indicate the number of seconds, excluding leap value is used to indicate the number of seconds, excluding leap
seconds, since the start of the year 1970 in UTC. seconds, since the start of the year 1970 in UTC.
If only one of the Base Sum or Sum value is present, the missing
attribute is considered to have a value of zero. The Base Sum and
Sum values are added together to get the sum of measurement. If
neither the Base Sum or Sum are present, then the measurement does
not have a sum value.
Representing the statistical characteristics of measurements, such as Representing the statistical characteristics of measurements, such as
accuracy, can be very complex. Future specification may add new accuracy, can be very complex. Future specification may add new
attributes to provide better information about the statistical attributes to provide better information about the statistical
properties of the measurement. properties of the measurement.
A SenML object is referred to as "expanded" if it does not contain 4.4. Resolved Records
any base values and has no relative times.
4.4. Associating Meta-data Sometimes it is useful to be able to refer to a defined normalized
format for SenML records. This normalized format tends to get used
for big data applications and intermediate forms when converting to
other formats.
A SenML Record is referred to as "resolved" if it does not contain
any base values and has no relative times, but the base values of the
SenML Pack (if any) are applied to the Record. That is, name and
base name are concatenated, base time is added to the time of the
Record, if the Record did not contain Unit the Base Unit is applied
to the record, etc. In addition the records need to be in
chronological order. An example of this is show in Section 5.1.4.
Future specification that defines new base attributes need to specify
how the attribute is resolved.
4.5. Associating Meta-data
SenML is designed to carry the minimum dynamic information about SenML is designed to carry the minimum dynamic information about
measurements, and for efficiency reasons does not carry significant measurements, and for efficiency reasons does not carry significant
static meta-data about the device, object or sensors. Instead, it is static meta-data about the device, object or sensors. Instead, it is
assumed that this meta-data is carried out of band. For web assumed that this meta-data is carried out of band. For web
resources using SenML Packs, this meta-data can be made available resources using SenML Packs, this meta-data can be made available
using the CoRE Link Format [RFC6690]. The most obvious use of this using the CoRE Link Format [RFC6690]. The most obvious use of this
link format is to describe that a resource is available in a SenML link format is to describe that a resource is available in a SenML
format in the first place. The relevant media type indicator is format in the first place. The relevant media type indicator is
included in the Content-Type (ct=) attribute. included in the Content-Type (ct=) attribute.
skipping to change at page 8, line 34 skipping to change at page 9, line 17
The SenML labels (JSON object member names) shown in Table 1 are used The SenML labels (JSON object member names) shown in Table 1 are used
in JSON SenML Record attributes. in JSON SenML Record attributes.
+---------------+-------+---------+ +---------------+-------+---------+
| Name | label | Type | | Name | label | Type |
+---------------+-------+---------+ +---------------+-------+---------+
| Base Name | bn | String | | Base Name | bn | String |
| Base Time | bt | Number | | Base Time | bt | Number |
| Base Unit | bu | String | | Base Unit | bu | String |
| Base Value | bv | Number | | Base Value | bv | Number |
| Base Sum | bs | Number |
| Version | bver | Number | | Version | bver | Number |
| Name | n | String | | Name | n | String |
| Unit | u | String | | Unit | u | String |
| Value | v | Number | | Value | v | Number |
| String Value | vs | String | | String Value | vs | String |
| Boolean Value | vb | Boolean | | Boolean Value | vb | Boolean |
| Data Value | vd | String | | Data Value | vd | String |
| Value Sum | s | Number | | Value Sum | s | Number |
| Time | t | Number | | Time | t | Number |
| Update Time | ut | Number | | Update Time | ut | Number |
| Link | l | String |
+---------------+-------+---------+ +---------------+-------+---------+
Table 1: JSON SenML Labels Table 1: JSON SenML Labels
The root content consists of an array with one JSON object for each The root content consists of an array with one JSON object for each
SenML Record. All the fields in the above table MAY occur in the SenML Record. All the fields in the above table MAY occur in the
records with the type specified in the table. records with the type specified in the table.
Only the UTF-8 form of JSON is allowed. Characters in the String Only the UTF-8 form of JSON is allowed. Characters in the String
Value are encoded using the escape sequences defined in [RFC7159]. Value are encoded using the escape sequences defined in [RFC7159].
Characters in the Data Value are base64 encoded with URL safe Octets in the Data Value are base64 encoded with URL safe alphabet as
alphabet as defined in Section 5 of [RFC4648]. defined in Section 5 of [RFC4648].
Systems receiving measurements MUST be able to process the range of Systems receiving measurements MUST be able to process the range of
floating point numbers that are representable as an IEEE double- floating point numbers that are representable as an IEEE double
precision floating-point numbers [IEEE.754.1985]. The number of precision floating point numbers [IEEE.754.1985]. The number of
significant digits in any measurement is not relevant, so a reading significant digits in any measurement is not relevant, so a reading
of 1.1 has exactly the same semantic meaning as 1.10. If the value of 1.1 has exactly the same semantic meaning as 1.10. If the value
has an exponent, the "e" MUST be in lower case. The mantissa SHOULD has an exponent, the "e" MUST be in lower case. The mantissa SHOULD
be less than 19 characters long and the exponent SHOULD be less than be less than 19 characters long and the exponent SHOULD be less than
5 characters long. This allows time values to have better than micro 5 characters long. This allows time values to have better than micro
second precision over the next 100 years. second precision over the next 100 years.
5.1. Examples 5.1. Examples
TODO - Add example with string, data, boolean, and base value
5.1.1. Single Datapoint 5.1.1. Single Datapoint
The following shows a temperature reading taken approximately "now" The following shows a temperature reading taken approximately "now"
by a 1-wire sensor device that was assigned the unique 1-wire address by a 1-wire sensor device that was assigned the unique 1-wire address
of 10e2073a01080063: of 10e2073a01080063:
[{ "n": "urn:dev:ow:10e2073a01080063", "v":23.1, "u":"Cel" }] [
{"n":"urn:dev:ow:10e2073a01080063","u":"Cel","v":23.1}
]
5.1.2. Multiple Datapoints 5.1.2. Multiple Datapoints
The following example shows voltage and current now, i.e., at an The following example shows voltage and current now, i.e., at an
unspecified time. unspecified time.
[ {"bn": "urn:dev:ow:10e2073a01080063", [
"n": "voltage", "t": 0, "u": "V", "v": 120.1 }, {"bn":"urn:dev:ow:10e2073a01080063","n":"voltage","u":"V","v":120.1},
{"n": "current", "t": 0, "u": "A", "v": 1.2 } {"n":"current","u":"A","v":1.2}
] ]
The next example is similar to the above one, but shows current at The next example is similar to the above one, but shows current at
Tue Jun 8 18:01:16.001 UTC 2010 and at each second for the previous 5 Tue Jun 8 18:01:16.001 UTC 2010 and at each second for the previous 5
seconds. seconds.
[{"bn": "urn:dev:ow:10e2073a01080063/", [
"bt": 1276020076.001, {"bn":"urn:dev:ow:10e2073a01080063/","bt":1.276020076001e+09,"bu":"A","bver":5,
"bu": "A", "n":"voltage","u":"V","v":120.1},
"bver": 5, {"n":"current","t":-5,"v":1.2},
"n": "voltage", "u": "V", "v": 120.1 }, {"n":"current","t":-4,"v":1.3},
{ "n": "current", "t": -5, "v": 1.2 }, {"n":"current","t":-3,"v":1.4},
{ "n": "current", "t": -4, "v": 1.30 }, {"n":"current","t":-2,"v":1.5},
{ "n": "current", "t": -3, "v": 0.14e1 }, {"n":"current","t":-1,"v":1.6},
{ "n": "current", "t": -2, "v": 1.5 }, {"n":"current","v":1.7}
{ "n": "current", "t": -1, "v": 1.6 }, ]
{ "n": "current", "t": 0, "v": 1.7 }
]
Note that in some usage scenarios of SenML the implementations MAY Note that in some usage scenarios of SenML the implementations MAY
store or transmit SenML in a stream-like fashion, where data is store or transmit SenML in a stream-like fashion, where data is
collected over time and continuously added to the object. This mode collected over time and continuously added to the object. This mode
of operation is optional, but systems or protocols using SenML in of operation is optional, but systems or protocols using SenML in
this fashion MUST specify that they are doing this. SenML defines a this fashion MUST specify that they are doing this. SenML defines a
separate media type to indicate Sensor Streaming Markup Language separate media type to indicate Sensor Streaming Markup Language
(SensML) for this usage (see Section 11.3.1). In this situation the (SensML) for this usage (see Section 11.3.1). In this situation the
SensML stream can be sent and received in a partial fashion, i.e., a SensML stream can be sent and received in a partial fashion, i.e., a
measurement entry can be read as soon as the SenML Record is received measurement entry can be read as soon as the SenML Record is received
and not have to wait for the full SensML Stream to be complete. and not have to wait for the full SensML Stream to be complete.
For instance, the following stream of measurements may be sent via a For instance, the following stream of measurements may be sent via a
long lived HTTP POST from the producer of a SensML to the consumer of long lived HTTP POST from the producer of a SensML to the consumer of
that, and each measurement object may be reported at the time it was that, and each measurement object may be reported at the time it was
measured: measured:
[ {"bn": "urn:dev:ow:10e2073a01080063", [
"bt": 1320067464, {"bn":"urn:dev:ow:10e2073a01080063","bt":1.320067464e+09,"bu":"%RH","v":21.2},
"bu": "%RH", {"t":10,"v":21.3},
"v": 21.2, "t": 0 }, {"t":20,"v":21.4},
{ "v": 21.3, "t": 10 }, {"t":30,"v":21.4},
{ "v": 21.4, "t": 20 }, {"t":40,"v":21.5},
{ "v": 21.4, "t": 30 }, {"t":50,"v":21.5},
{ "v": 21.5, "t": 40 }, {"t":60,"v":21.5},
{ "v": 21.5, "t": 50 }, {"t":70,"v":21.6},
{ "v": 21.5, "t": 60 }, {"t":80,"v":21.7},
{ "v": 21.6, "t": 70 }, {"t":90,"v":21.5},
{ "v": 21.7, "t": 80 }, ...
{ "v": 21.5, "t": 90 },
...
5.1.3. Multiple Measurements 5.1.3. Multiple Measurements
The following example shows humidity measurements from a mobile The following example shows humidity measurements from a mobile
device with a 1-wire address 10e2073a01080063, starting at Mon Oct 31 device with a 1-wire address 10e2073a01080063, starting at Mon Oct 31
13:24:24 UTC 2011. The device also provides position data, which is 13:24:24 UTC 2011. The device also provides position data, which is
provided in the same measurement or parameter array as separate provided in the same measurement or parameter array as separate
entries. Note time is used to for correlating data that belongs entries. Note time is used to for correlating data that belongs
together, e.g., a measurement and a parameter associated with it. together, e.g., a measurement and a parameter associated with it.
Finally, the device also reports extra data about its battery status Finally, the device also reports extra data about its battery status
at a separate time. at a separate time.
[{"bn": "urn:dev:ow:10e2073a01080063", [
"bt": 1320067464, {"bn":"urn:dev:ow:10e2073a01080063","bt":1.320067464e+09,"bu":"%RH","v":20},
"bu": "%RH", {"u":"lon","v":24.30621},
"v": 20.0, "t": 0 }, {"u":"lat","v":60.07965},
{ "v": 24.30621, "u": "lon", "t": 0 }, {"t":60,"v":20.3},
{ "v": 60.07965, "u": "lat", "t": 0 }, {"u":"lon","t":60,"v":24.30622},
{ "v": 20.3, "t": 60 }, {"u":"lat","t":60,"v":60.07965},
{ "v": 24.30622, "u": "lon", "t": 60 }, {"t":120,"v":20.7},
{ "v": 60.07965, "u": "lat", "t": 60 }, {"u":"lon","t":120,"v":24.30623},
{ "v": 20.7, "t": 120 }, {"u":"lat","t":120,"v":60.07966},
{ "v": 24.30623, "u": "lon", "t": 120 }, {"u":"%EL","t":150,"v":98},
{ "v": 60.07966, "u": "lat", "t": 120 }, {"t":180,"v":21.2},
{ "v": 98.0, "u": "%EL", "t": 150 }, {"u":"lon","t":180,"v":24.30628},
{ "v": 21.2, "t": 180 }, {"u":"lat","t":180,"v":60.07967}
{ "v": 24.30628, "u": "lon", "t": 180 }, ]
{ "v": 60.07967, "u": "lat", "t": 180 }
]
The size of this example represented in various forms, as well as The size of this example represented in various forms, as well as
that form compressed with gzip is given in the following table. that form compressed with gzip is given in the following table.
+----------+------+-----------------+ +----------+------+-----------------+
| Encoding | Size | Compressed Size | | Encoding | Size | Compressed Size |
+----------+------+-----------------+ +----------+------+-----------------+
| JSON | 573 | 206 | | JSON | 573 | 206 |
| XML | 649 | 235 | | XML | 649 | 235 |
| CBOR | 254 | 196 | | CBOR | 254 | 196 |
| EXI | 173 | 196 | | EXI | 173 | 196 |
+----------+------+-----------------+ +----------+------+-----------------+
Table 2: Size Comparisons Table 2: Size Comparisons
Note the EXI sizes are not using the schema guidance so the EXI Note the EXI sizes are not using the schema guidance so the EXI
representation could be a bit smaller. representation could be a bit smaller.
5.1.4. Collection of Resources 5.1.4. Resolved Data
The following shows the example from the previous section show in
resolved format.
[
{"n":"urn:dev:ow:10e2073a01080063","u":"%RH","t":1.320067464e+09,"v":20},
{"n":"urn:dev:ow:10e2073a01080063","u":"lon","t":1.320067464e+09,"v":24.30621},
{"n":"urn:dev:ow:10e2073a01080063","u":"lat","t":1.320067464e+09,"v":60.07965},
{"n":"urn:dev:ow:10e2073a01080063","u":"%RH","t":1.320067524e+09,"v":20.3},
{"n":"urn:dev:ow:10e2073a01080063","u":"lon","t":1.320067524e+09,"v":24.30622},
{"n":"urn:dev:ow:10e2073a01080063","u":"lat","t":1.320067524e+09,"v":60.07965},
{"n":"urn:dev:ow:10e2073a01080063","u":"%RH","t":1.320067584e+09,"v":20.7},
{"n":"urn:dev:ow:10e2073a01080063","u":"lon","t":1.320067584e+09,"v":24.30623},
{"n":"urn:dev:ow:10e2073a01080063","u":"lat","t":1.320067584e+09,"v":60.07966},
{"n":"urn:dev:ow:10e2073a01080063","u":"%EL","t":1.320067614e+09,"v":98},
{"n":"urn:dev:ow:10e2073a01080063","u":"%RH","t":1.320067644e+09,"v":21.2},
{"n":"urn:dev:ow:10e2073a01080063","u":"lon","t":1.320067644e+09,"v":24.30628},
{"n":"urn:dev:ow:10e2073a01080063","u":"lat","t":1.320067644e+09,"v":60.07967}
]
5.1.5. Multiple Data Types
The following example shows a sensor that returns different data
types.
[
{"bn":"urn:dev:ow:10e2073a01080063-","n":"temp","u":"Cel","v":23.1},
{"n":"label","vs":"Machine Room"},
{"n":"open","vb":false},
{"n":"nfv-reader","vd":"aGkgCg=="}
]
5.1.6. Collection of Resources
The following example shows how to query one device that can provide The following example shows how to query one device that can provide
multiple measurements. The example assumes that a client has fetched multiple measurements. The example assumes that a client has fetched
information from a device at 2001:db8::2 by performing a GET information from a device at 2001:db8::2 by performing a GET
operation on http://[2001:db8::2] at Mon Oct 31 16:27:09 UTC 2011, operation on http://[2001:db8::2] at Mon Oct 31 16:27:09 UTC 2011,
and has gotten two separate values as a result, a temperature and and has gotten two separate values as a result, a temperature and
humidity measurement. humidity measurement.
[{"bn": "http://[2001:db8::2]/", [
"bt": 1320078429, {"bn":"http://[2001:db8::2]/","bt":1.320078429e+09,"bver":5,"n":"temperature",
"bver": 5, "u":"Cel","v":27.2},
"n": "temperature", "v": 27.2, "u": "Cel" }, {"n":"humidity",
{ "n": "humidity", "v": 80, "u": "%RH" } "u":"%RH","v":80}
] ]
6. CBOR Representation (application/senml+cbor) 6. CBOR Representation (application/senml+cbor)
The CBOR [RFC7049] representation is equivalent to the JSON The CBOR [RFC7049] representation is equivalent to the JSON
representation, with the following changes: representation, with the following changes:
o For JSON Numbers, the CBOR representation can use integers,
floating point numbers, or decimal fractions (CBOR Tag 4); however
a representation SHOULD be chosen such that when the CBOR value is
converted back to an IEEE double precision floating point value,
it has exactly the same value as the original Number. For the
version number, only an unsigned integer is allowed.
o Characters in the String Value are encoded using a definite length
text string (type 3). Octets in the Data Value are encoded using
a definite length byte string (type 2) .
o For compactness, the CBOR representation uses integers for the map o For compactness, the CBOR representation uses integers for the map
keys defined in Table 3. This table is conclusive, i.e., there is keys defined in Table 3. This table is conclusive, i.e., there is
no intention to define any additional integer map keys; any no intention to define any additional integer map keys; any
extensions will use string map keys. extensions will use string map keys.
o For JSON Numbers, the CBOR representation can use integers, +---------------+-------+------------+
floating point numbers, or decimal fractions (CBOR Tag 4); the | Name | Label | CBOR Label |
common limitations of JSON implementations are not relevant for +---------------+-------+------------+
these. For the version number, however, only an unsigned integer | Version | bver | -1 |
is allowed. | Base Name | bn | -2 |
| Base Time | bt | -3 |
+---------------+------------+------------+ | Base Units | bu | -4 |
| Name | JSON label | CBOR label | | Base Value | bv | -5 |
+---------------+------------+------------+ | Base Sum | bs | -6 |
| Version | bver | -1 | | Name | n | 0 |
| Base Name | bn | -2 | | Units | u | 1 |
| Base Time | bt | -3 | | Value | v | 2 |
| Base Units | bu | -4 | | String Value | vs | 3 |
| Base Value | bv | -5 | | Boolean Value | vb | 4 |
| Name | n | 0 | | Value Sum | s | 5 |
| Units | u | 1 | | Time | t | 6 |
| Value | v | 2 | | Update Time | ut | 7 |
| String Value | vs | 3 | | Data Value | vd | 8 |
| Boolean Value | vb | 4 | | Link | l | 9 |
| Value Sum | s | 5 | +---------------+-------+------------+
| Time | t | 6 |
| Update Time | ut | 7 |
| Data Value | vd | 8 |
+---------------+------------+------------+
Table 3: CBOR representation: integers for map keys Table 3: CBOR representation: integers for map keys
o For streaming SensML in CBOR representation, the array containing
the records SHOULD be an CBOR indefinite length array while for
non streaming SenML, a definite length array MUST be used.
The following example shows a dump of the CBOR example for the same The following example shows a dump of the CBOR example for the same
sensor measurement as in Section 5.1.2. sensor measurement as in Section 5.1.2.
0000 87 a7 21 78 1c 75 72 6e 3a 64 65 76 3a 6f 77 3a |..!x.urn:dev:ow:| 0000 87 a7 21 78 1c 75 72 6e 3a 64 65 76 3a 6f 77 3a |..!x.urn:dev:ow:|
0010 31 30 65 32 30 37 33 61 30 31 30 38 30 30 36 33 |10e2073a01080063| 0010 31 30 65 32 30 37 33 61 30 31 30 38 30 30 36 33 |10e2073a01080063|
0020 2f 22 fb 41 d3 03 a1 5b 00 10 62 23 61 41 20 05 |/".A...[..b#aA .| 0020 2f 22 fb 41 d3 03 a1 5b 00 10 62 23 61 41 20 05 |/".A...[..b#aA .|
0030 00 67 76 6f 6c 74 61 67 65 01 61 56 02 fb 40 5e |.gvoltage.aV..@^| 0030 00 67 76 6f 6c 74 61 67 65 01 61 56 02 fb 40 5e |.gvoltage.aV..@^|
0040 06 66 66 66 66 66 a3 00 67 63 75 72 72 65 6e 74 |.fffff..gcurrent| 0040 06 66 66 66 66 66 a3 00 67 63 75 72 72 65 6e 74 |.fffff..gcurrent|
0050 06 24 02 fb 3f f3 33 33 33 33 33 33 a3 00 67 63 |.$..?.333333..gc| 0050 06 24 02 fb 3f f3 33 33 33 33 33 33 a3 00 67 63 |.$..?.333333..gc|
0060 75 72 72 65 6e 74 06 23 02 fb 3f f4 cc cc cc cc |urrent.#..?.....| 0060 75 72 72 65 6e 74 06 23 02 fb 3f f4 cc cc cc cc |urrent.#..?.....|
skipping to change at page 13, line 47 skipping to change at page 15, line 8
0080 3f f6 66 66 66 66 66 66 a3 00 67 63 75 72 72 65 |?.ffffff..gcurre| 0080 3f f6 66 66 66 66 66 66 a3 00 67 63 75 72 72 65 |?.ffffff..gcurre|
0090 6e 74 06 21 02 f9 3e 00 a3 00 67 63 75 72 72 65 |nt.!..>...gcurre| 0090 6e 74 06 21 02 f9 3e 00 a3 00 67 63 75 72 72 65 |nt.!..>...gcurre|
00a0 6e 74 06 20 02 fb 3f f9 99 99 99 99 99 9a a3 00 |nt. ..?.........| 00a0 6e 74 06 20 02 fb 3f f9 99 99 99 99 99 9a a3 00 |nt. ..?.........|
00b0 67 63 75 72 72 65 6e 74 06 00 02 fb 3f fb 33 33 |gcurrent....?.33| 00b0 67 63 75 72 72 65 6e 74 06 00 02 fb 3f fb 33 33 |gcurrent....?.33|
00c0 33 33 33 33 |3333| 00c0 33 33 33 33 |3333|
00c4 00c4
7. XML Representation (application/senml+xml) 7. XML Representation (application/senml+xml)
A SenML Pack or Stream can also be represented in XML format as A SenML Pack or Stream can also be represented in XML format as
defined in this section. The following example shows an XML example defined in this section.
for the same sensor measurement as in Section 5.1.2.
Only the UTF-8 form of XML is allowed. Characters in the String
Value are encoded using the escape sequences defined in [RFC7159].
Octets in the Data Value are base64 encoded with URL safe alphabet as
defined in Section 5 of [RFC4648].
The following example shows an XML example for the same sensor
measurement as in Section 5.1.2.
<sensml xmlns="urn:ietf:params:xml:ns:senml"> <sensml xmlns="urn:ietf:params:xml:ns:senml">
<senml bn="urn:dev:ow:10e2073a01080063/" bt="1.276020076001e+09" <senml bn="urn:dev:ow:10e2073a01080063/" bt="1.276020076001e+09"
bu="A" bver="5" n="voltage" u="V" v="120.1"></senml> bu="A" bver="5" n="voltage" u="V" v="120.1"></senml>
<senml n="current" t="-5" v="1.2"></senml> <senml n="current" t="-5" v="1.2"></senml>
<senml n="current" t="-4" v="1.3"></senml> <senml n="current" t="-4" v="1.3"></senml>
<senml n="current" t="-3" v="1.4"></senml> <senml n="current" t="-3" v="1.4"></senml>
<senml n="current" t="-2" v="1.5"></senml> <senml n="current" t="-2" v="1.5"></senml>
<senml n="current" t="-1" v="1.6"></senml> <senml n="current" t="-1" v="1.6"></senml>
<senml n="current" v="1.7"></senml> <senml n="current" v="1.7"></senml>
</sensml> </sensml>
The SenML Stream is represented as a sensml tag that contains a The SenML Stream is represented as a sensml tag that contains a
series of senml tags for each SenML Record. The SenML Fields are series of senml tags for each SenML Record. The SenML Fields are
represents as XML attributes. The following table shows the mapping represents as XML attributes. The following table shows the mapping
of the SenML labels to the attribute names and types used in the XML of the SenML labels, which are used for the attribute name, to the
senml tags. attribute types used in the XML senml tags.
+---------------+------+---------+ +---------------+-------+---------+
| Name | XML | Type | | Name | Label | Type |
+---------------+------+---------+ +---------------+-------+---------+
| Base Name | bn | string | | Base Name | bn | string |
| Base Time | bt | double | | Base Time | bt | double |
| Base Unit | bu | string | | Base Unit | bu | string |
| Base Value | bv | double | | Base Value | bv | double |
| Base Version | bver | int | | Base Sum | bs | double |
| Name | n | string | | Base Version | bver | int |
| Unit | u | string | | Name | n | string |
| Value | v | double | | Unit | u | string |
| String Value | vs | string | | Value | v | double |
| Data Value | vd | string | | String Value | vs | string |
| Boolean Value | vb | boolean | | Data Value | vd | string |
| Value Sum | s | double | | Boolean Value | vb | boolean |
| Time | t | double | | Value Sum | s | double |
| Update Time | ut | double | | Time | t | double |
+---------------+------+---------+ | Update Time | ut | double |
| Link | l | string |
+---------------+-------+---------+
Table 4: XML SenML Labels Table 4: XML SenML Labels
The RelaxNG schema for the XML is: The RelaxNG schema for the XML is:
default namespace = "urn:ietf:params:xml:ns:senml" default namespace = "urn:ietf:params:xml:ns:senml"
namespace rng = "http://relaxng.org/ns/structure/1.0" namespace rng = "http://relaxng.org/ns/structure/1.0"
senml = element senml { senml = element senml {
attribute bn { xsd:string }?, attribute bn { xsd:string }?,
attribute bt { xsd:double }?, attribute bt { xsd:double }?,
attribute bv { xsd:double }?, attribute bv { xsd:double }?,
attribute bs { xsd:double }?,
attribute bu { xsd:string }?, attribute bu { xsd:string }?,
attribute bver { xsd:int }?, attribute bver { xsd:int }?,
attribute l { xsd:string }?,
attribute n { xsd:string }?, attribute n { xsd:string }?,
attribute s { xsd:double }?, attribute s { xsd:double }?,
attribute t { xsd:double }?, attribute t { xsd:double }?,
attribute u { xsd:string }?, attribute u { xsd:string }?,
attribute ut { xsd:double }?, attribute ut { xsd:double }?,
attribute v { xsd:double }?, attribute v { xsd:double }?,
attribute vb { xsd:boolean }?, attribute vb { xsd:boolean }?,
attribute vs { xsd:string }?, attribute vs { xsd:string }?,
attribute vd { xsd:string }? attribute vd { xsd:string }?
} }
sensml = sensml =
element sensml { element sensml {
senml+ senml+
} }
start = sensml start = sensml
8. EXI Representation (application/senml-exi) 8. EXI Representation (application/senml+exi)
For efficient transmission of SenML over e.g. a constrained network, For efficient transmission of SenML over e.g. a constrained network,
Efficient XML Interchange (EXI) can be used. This encodes the XML Efficient XML Interchange (EXI) can be used. This encodes the XML
Schema structure of SenML into binary tags and values rather than Schema structure of SenML into binary tags and values rather than
ASCII text. An EXI representation of SenML SHOULD be made using the ASCII text. An EXI representation of SenML SHOULD be made using the
strict schema-mode of EXI. This mode however does not allow tag strict schema-mode of EXI. This mode however does not allow tag
extensions to the schema, and therefore any extensions will be lost extensions to the schema, and therefore any extensions will be lost
in the encoding. For uses where extensions need to be preserved in in the encoding. For uses where extensions need to be preserved in
EXI, the non-strict schema mode of EXI MAY be used. EXI, the non-strict schema mode of EXI MAY be used.
The EXI header option MUST be included. An EXI schemaID options MUST The EXI header option MUST be included. An EXI schemaID options MUST
be set to the value of "a" indicating the scheme provided in this be set to the value of "a" indicating the scheme provided in this
specification. Future revisions to the schema can change this specification. Future revisions to the schema can change this
schemaID to allow for backwards compatibility. When the data will be schemaID to allow for backwards compatibility. When the data will be
transported over CoAP or HTTP, an EXI Cookie SHOULD NOT be used as it transported over CoAP or HTTP, an EXI Cookie SHOULD NOT be used as it
simply makes things larger and is redundant to information provided simply makes things larger and is redundant to information provided
in the Content-Type header. in the Content-Type header.
TODO - examples probably have the wrong setting for the schemaID
The following is the XSD Schema to be used for strict schema guided The following is the XSD Schema to be used for strict schema guided
EXI processing. It is generated from the RelaxNG. EXI processing. It is generated from the RelaxNG.
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="urn:ietf:params:xml:ns:senml" targetNamespace="urn:ietf:params:xml:ns:senml"
xmlns:ns1="urn:ietf:params:xml:ns:senml"> xmlns:ns1="urn:ietf:params:xml:ns:senml">
<xs:element name="senml"> <xs:element name="senml">
<xs:complexType> <xs:complexType>
<xs:attribute name="bn" type="xs:string" /> <xs:attribute name="bn" type="xs:string" />
<xs:attribute name="bt" type="xs:double" /> <xs:attribute name="bt" type="xs:double" />
<xs:attribute name="bv" type="xs:double" /> <xs:attribute name="bv" type="xs:double" />
<xs:attribute name="bu" type="xs:string" /> <xs:attribute name="bu" type="xs:string" />
<xs:attribute name="bver" type="xs:int" /> <xs:attribute name="bver" type="xs:int" />
<xs:attribute name="l" type="xs:string" />
<xs:attribute name="n" type="xs:string" /> <xs:attribute name="n" type="xs:string" />
<xs:attribute name="s" type="xs:double" /> <xs:attribute name="s" type="xs:double" />
<xs:attribute name="t" type="xs:double" /> <xs:attribute name="t" type="xs:double" />
<xs:attribute name="u" type="xs:string" /> <xs:attribute name="u" type="xs:string" />
<xs:attribute name="ut" type="xs:double" /> <xs:attribute name="ut" type="xs:double" />
<xs:attribute name="v" type="xs:double" /> <xs:attribute name="v" type="xs:double" />
<xs:attribute name="vb" type="xs:boolean" /> <xs:attribute name="vb" type="xs:boolean" />
<xs:attribute name="vs" type="xs:string" /> <xs:attribute name="vs" type="xs:string" />
<xs:attribute name="vd" type="xs:string" /> <xs:attribute name="vd" type="xs:string" />
</xs:complexType> </xs:complexType>
skipping to change at page 17, line 7 skipping to change at page 19, line 15
<sensml xmlns="urn:ietf:params:xml:ns:senml"> <sensml xmlns="urn:ietf:params:xml:ns:senml">
<senml bn="urn:dev:ow:10e2073a01080063" n="voltage" u="V" <senml bn="urn:dev:ow:10e2073a01080063" n="voltage" u="V"
v="120.1"></senml> v="120.1"></senml>
<senml n="current" u="A" v="1.2"></senml> <senml n="current" u="A" v="1.2"></senml>
</sensml> </sensml>
Which compresses with EXI to the following displayed in hexdump: Which compresses with EXI to the following displayed in hexdump:
0000 a0 30 3d cd 95 b9 b5 b0 b9 9d 95 b8 b9 e1 cd 90 |.0=.............| 0000 a0 30 3d cd 95 b9 b5 b0 b9 9d 95 b8 b9 e1 cd 90 |.0=.............|
0010 80 eb ab 93 71 d3 23 2b b1 d3 7b b9 d1 89 83 29 |....q.#+..{....)| 0010 80 eb ab 93 71 d3 23 2b b1 d3 7b b9 d1 89 83 29 |....q.#+..{....)|
0020 91 81 b9 9b 09 81 89 81 c1 81 81 b1 9a 84 bb 37 |...............7| 0020 91 81 b9 9b 09 81 89 81 c1 81 81 b1 9a 04 bb 37 |...............7|
0030 b6 3a 30 b3 b2 90 1a b1 58 84 c0 33 04 b1 ba b9 |.:0.....X..3....| 0030 b6 3a 30 b3 b2 90 1a b1 58 84 c0 32 84 b1 ba b9 |.:0.....X..2....|
0040 39 32 b7 3a 10 1a 09 06 40 38 |92.:....@8| 0040 39 32 b7 3a 10 1a 09 06 40 38 |92.:....@8|
004a 004a
The above example used the bit packed form of EXI but it is also The above example used the bit packed form of EXI but it is also
possible to use a byte packed form of EXI which can makes it easier possible to use a byte packed form of EXI which can makes it easier
for a simple sensor to produce valid EXI without really implementing for a simple sensor to produce valid EXI without really implementing
EXI. Consider the example of a temperature sensor that produces a EXI. Consider the example of a temperature sensor that produces a
value in tenths of degrees Celsius over a range of 0.0 to 55.0. It value in tenths of degrees Celsius over a range of 0.0 to 55.0. It
would produce an XML SenML file such as: would produce an XML SenML file such as:
<sensml xmlns="urn:ietf:params:xml:ns:senml"> <sensml xmlns="urn:ietf:params:xml:ns:senml">
<senml n="urn:dev:ow:10e2073a01080063" u="Cel" v="23.1"></senml> <senml n="urn:dev:ow:10e2073a01080063" u="Cel" v="23.1"></senml>
</sensml> </sensml>
The compressed form, using the byte alignment option of EXI, for the The compressed form, using the byte alignment option of EXI, for the
above XML is the following: above XML is the following:
0000 a0 00 48 81 ee 6c ad cd ad 85 cc ec ad c5 cf 0e |..H..l..........| 0000 a0 00 48 81 ee 6c ad cd ad 85 cc ec ad c5 cf 0e |..H..l..........|
0010 6c 80 01 06 1d 75 72 6e 3a 64 65 76 3a 6f 77 3a |l....urn:dev:ow:| 0010 6c 80 01 05 1d 75 72 6e 3a 64 65 76 3a 6f 77 3a |l....urn:dev:ow:|
0020 31 30 65 32 30 37 33 61 30 31 30 38 30 30 36 33 |10e2073a01080063| 0020 31 30 65 32 30 37 33 61 30 31 30 38 30 30 36 33 |10e2073a01080063|
0030 02 05 43 65 6c 01 00 e7 01 01 00 03 01 |..Cel........| 0030 02 05 43 65 6c 01 00 e7 01 01 00 03 01 |..Cel........|
003d 003d
A small temperature sensor devices that only generates this one EXI A small temperature sensor devices that only generates this one EXI
file does not really need an full EXI implementation. It can simply file does not really need an full EXI implementation. It can simply
hard code the output replacing the 1-wire device ID starting at byte hard code the output replacing the 1-wire device ID starting at byte
0x20 and going to byte 0x2F with it's device ID, and replacing the 0x20 and going to byte 0x2F with it's device ID, and replacing the
value "0xe7 0x01" at location 0x37 and 0x38 with the current value "0xe7 0x01" at location 0x37 and 0x38 with the current
temperature. The EXI Specification [W3C.REC-exi-20110310] contains temperature. The EXI Specification [W3C.REC-exi-20110310] contains
skipping to change at page 20, line 18 skipping to change at page 22, line 27
Figure 1: Common CDDL specification for CBOR and JSON SenML Figure 1: Common CDDL specification for CBOR and JSON SenML
For JSON, we use text labels and base64url-encoded binary data For JSON, we use text labels and base64url-encoded binary data
(Figure 2). (Figure 2).
bver = "bver" n = "n" s = "s" bver = "bver" n = "n" s = "s"
bn = "bn" u = "u" t = "t" bn = "bn" u = "u" t = "t"
bt = "bt" v = "v" ut = "ut" bt = "bt" v = "v" ut = "ut"
bu = "bu" vs = "vs" vd = "vd" bu = "bu" vs = "vs" vd = "vd"
bv = "bv" vb = "vb" bv = "bv" vb = "vb" l = "l"
binary-value = tstr ; base64url encoded binary-value = tstr ; base64url encoded
Figure 2: JSON-specific CDDL specification for SenML Figure 2: JSON-specific CDDL specification for SenML
For CBOR, we use integer labels and native binary data (Figure 3). For CBOR, we use integer labels and native binary data (Figure 3).
bver = -1 n = 0 s = 5 bver = -1 n = 0 s = 5
bn = -2 u = 1 t = 6 bn = -2 u = 1 t = 6
bt = -3 v = 2 ut = 7 bt = -3 v = 2 ut = 7
bu = -4 vs = 3 vd = 8 bu = -4 vs = 3 vd = 8
bv = -5 vb = 4 bv = -5 vb = 4 l = 9
binary-value = bstr binary-value = bstr
Figure 3: CBOR-specific CDDL specification for SenML Figure 3: CBOR-specific CDDL specification for SenML
11. IANA Considerations 11. IANA Considerations
Note to RFC Editor: Please replace all occurrences of "RFC-AAAA" with Note to RFC Editor: Please replace all occurrences of "RFC-AAAA" with
the RFC number of this specification. the RFC number of this specification.
skipping to change at page 24, line 5 skipping to change at page 26, line 13
allocated. allocated.
10. A number after a unit typically indicates the previous unit 10. A number after a unit typically indicates the previous unit
raised to that power, and the / indicates that the units that raised to that power, and the / indicates that the units that
follow are the reciprocal. A unit should have only one / in the follow are the reciprocal. A unit should have only one / in the
name. name.
11. A good list of common units can be found in the Unified Code for 11. A good list of common units can be found in the Unified Code for
Units of Measure [UCUM]. Units of Measure [UCUM].
11.2. SenML label registry 11.2. SenML Label Registry
IANA will create a new registry for SenML labels. The initial IANA will create a new registry for SenML labels. The initial
content of the registry are shown in Table 1 and Table 4. content of the registry is:
+---------------+-------+------+----------+----+---------+
| Name | Label | CBOR | XML Type | ID | Note |
+---------------+-------+------+----------+----+---------+
| Base Name | bn | -2 | string | a | RFCXXXX |
| Base Sum | bs | -6 | double | a | RFCXXXX |
| Base Time | bt | -3 | double | a | RFCXXXX |
| Base Unit | bu | -4 | string | a | RFCXXXX |
| Base Value | bv | -5 | double | a | RFCXXXX |
| Base Version | bver | -1 | int | a | RFCXXXX |
| Boolean Value | vb | 4 | boolean | a | RFCXXXX |
| Data Value | vd | 8 | string | a | RFCXXXX |
| Name | n | 0 | string | a | RFCXXXX |
| String Value | vs | 3 | string | a | RFCXXXX |
| Time | t | 6 | double | a | RFCXXXX |
| Unit | u | 1 | string | a | RFCXXXX |
| Update Time | ut | 7 | double | a | RFCXXXX |
| Value | v | 2 | double | a | RFCXXXX |
| Value Sum | s | 5 | double | a | RFCXXXX |
| Link | l | 9 | string | a | RFCXXXX |
+---------------+-------+------+----------+----+---------+
Table 6: SenML Labels
Note to RFC Editor. Please replace RFCXXXX with the number for this
RFC.
All new entries must define the Label Name, Label, and XML Type but
the CBOR labels SHOULD be left empty as CBOR will use the string
encoding for any new labels. The ID fields contains the EXI schemaID
of the first Schema which includes this label or is empty if this
label was not intended for use with EXI. The Note field SHOULD
contain information about where to find out more information about
this label.
The JSON, CBOR, and EXI types are derived from the XML type. All XML
numeric types such as double, float, integer and int become a JSON
Number. XML boolean and string become a JSON Boolean and String
respectively. CBOR represents numeric values with a CBOR type that
does not loose any information from the JSON value. EXI uses the XML
types.
New entries can be added to the registration by either Expert Review New entries can be added to the registration by either Expert Review
or IESG Approval as defined in [RFC5226]. Experts should exercise or IESG Approval as defined in [RFC5226]. Experts should exercise
their own good judgment but need to consider that shorter labels their own good judgment but need to consider that shorter labels
should have more strict review. should have more strict review.
All new SenML labels that have "base" semantics (see Section 4.1) All new SenML labels that have "base" semantics (see Section 4.1)
must start with character 'b'. Regular labels must not start with MUST start with character 'b'. Regular labels MUST NOT start with
that character. that character.
All new entries must define the Label Name, Label, JSON Type, and XML Extensions that add a label that is intended for use with XML need to
Type. create a new RelaxNG scheme that includes all the labels in the IANA
registry.
Extensions that add a label that is intended for use with EXI need to
create a new XSD Schema that includes all the labels in the IANA
registry then allocate a new EXI schemaID. Moving to the next letter
in the alphabet is the suggested way to create the new EXI schemaID.
Any labels with previously blank ID values SHOULD be updated in the
IANA table to have their ID set to this new schemaID value.
11.3. Media Type Registration 11.3. Media Type Registration
The following registrations are done following the procedure The following registrations are done following the procedure
specified in [RFC6838] and [RFC7303]. specified in [RFC6838] and [RFC7303].
Note to RFC Editor - please remove this paragraph. Note that a
request for media type review for senml+json was sent to the media-
types@iana.org on Sept 21, 2010. A second request for all the types
was sent on TODO.
11.3.1. senml+json Media Type Registration 11.3.1. senml+json Media Type Registration
Type name: application Type name: application
Subtype name: senml+json and sensml+json Subtype name: senml+json and sensml+json
Required parameters: none Required parameters: none
Optional parameters: none Optional parameters: none
Encoding considerations: Must be encoded as using a subset of the Encoding considerations: Must be encoded as using a subset of the
encoding allowed in [RFC7159]. See RFC-AAAA for details. This encoding allowed in [RFC7159]. See RFC-AAAA for details. This
simplifies implementation of very simple system and does not impose simplifies implementation of very simple system and does not impose
any significant limitations as all this data is meant for machine to any significant limitations as all this data is meant for machine to
machine communications and is not meant to be human readable. machine communications and is not meant to be human readable.
Security considerations: Sensor data can contain a wide range of Security considerations: Sensor data can contain a wide range of
information ranging from information that is very public, such the information ranging from information that is very public, such the
outside temperature in a given city, to very private information that outside temperature in a given city, to very private information that
requires integrity and confidentiality protection, such as patient requires integrity and confidentiality protection, such as patient
skipping to change at page 27, line 17 skipping to change at page 30, line 33
Jennings <fluffy@iii.ca> Jennings <fluffy@iii.ca>
Intended usage: COMMON Intended usage: COMMON
Restrictions on usage: None Restrictions on usage: None
Author: Cullen Jennings <fluffy@iii.ca> Author: Cullen Jennings <fluffy@iii.ca>
Change controller: IESG Change controller: IESG
11.3.4. senml-exi Media Type Registration 11.3.4. senml+exi Media Type Registration
Type name: application Type name: application
Subtype name: senml-exi and sensml-exi Subtype name: senml+exi and sensml+exi
Required parameters: none Required parameters: none
Optional parameters: none Optional parameters: none
Encoding considerations: TBD Encoding considerations: TBD
Security considerations: TBD Security considerations: TBD
Interoperability considerations: TBD Interoperability considerations: TBD
skipping to change at page 28, line 24 skipping to change at page 31, line 39
Registrant Contact: The IESG. Registrant Contact: The IESG.
XML: N/A, the requested URIs are XML namespaces XML: N/A, the requested URIs are XML namespaces
11.5. CoAP Content-Format Registration 11.5. CoAP Content-Format Registration
IANA is requested to assign CoAP Content-Format IDs for the SenML IANA is requested to assign CoAP Content-Format IDs for the SenML
media types in the "CoAP Content-Formats" sub-registry, within the media types in the "CoAP Content-Formats" sub-registry, within the
"CoRE Parameters" registry [RFC7252]. All IDs are assigned from the "CoRE Parameters" registry [RFC7252]. All IDs are assigned from the
"Expert Review" (0-255) range. The assigned IDs are show in Table 6. "Expert Review" (0-255) range. The assigned IDs are show in Table 7.
+-------------------------+-----+ +-------------------------+-----+
| Media type | ID | | Media type | ID |
+-------------------------+-----+ +-------------------------+-----+
| application/senml+json | TBD | | application/senml+json | TBD |
| application/sensml+json | TBD | | application/sensml+json | TBD |
| application/senml+cbor | TBD | | application/senml+cbor | TBD |
| application/sensml+cbor | TBD |
| application/senml+xml | TBD | | application/senml+xml | TBD |
| application/sensml+xml | TBD | | application/sensml+xml | TBD |
| application/senml-exi | TBD | | application/senml+exi | TBD |
| application/sensml+exi | TBD |
+-------------------------+-----+ +-------------------------+-----+
Table 6: CoAP Content-Format IDs Table 7: CoAP Content-Format IDs
12. Security Considerations 12. Security Considerations
See Section 13. Further discussion of security properties can be See Section 13. Further discussion of security properties can be
found in Section 11.3. found in Section 11.3.
13. Privacy Considerations 13. Privacy Considerations
Sensor data can range from information with almost no security Sensor data can range from information with almost no security
considerations, such as the current temperature in a given city, to considerations, such as the current temperature in a given city, to
highly sensitive medical or location data. This specification highly sensitive medical or location data. This specification
provides no security protection for the data but is meant to be used provides no security protection for the data but is meant to be used
inside another container or transport protocol such as S/MIME or HTTP inside another container or transport protocol such as S/MIME or HTTP
with TLS that can provide integrity, confidentiality, and with TLS that can provide integrity, confidentiality, and
authentication information about the source of the data. authentication information about the source of the data.
14. Acknowledgement 14. Acknowledgement
We would like to thank Lisa Dusseault, Joe Hildebrand, Lyndsay We would like to thank Lisa Dusseault, Joe Hildebrand, Lyndsay
Campbell, Martin Thomson, John Klensin, Bjoern Hoehrmann, and Campbell, Martin Thomson, John Klensin, Bjoern Hoehrmann, Christian
Christian Amsuess for their review comments. Groves, and Christian Amsuess, for their review comments.
15. References 15. References
15.1. Normative References 15.1. Normative References
[BIPM] Bureau International des Poids et Mesures, "The [BIPM] Bureau International des Poids et Mesures, "The
International System of Units (SI)", 8th edition, 2006. International System of Units (SI)", 8th edition, 2006.
[IEEE.754.1985] [IEEE.754.1985]
Institute of Electrical and Electronics Engineers, Institute of Electrical and Electronics Engineers,
skipping to change at page 30, line 42 skipping to change at page 34, line 25
Names for Device Identifiers", draft-arkko-core-dev-urn-03 Names for Device Identifiers", draft-arkko-core-dev-urn-03
(work in progress), July 2012. (work in progress), July 2012.
[I-D.greevenbosch-appsawg-cbor-cddl] [I-D.greevenbosch-appsawg-cbor-cddl]
Vigano, C. and H. Birkholz, "CBOR data definition language Vigano, C. and H. Birkholz, "CBOR data definition language
(CDDL): a notational convention to express CBOR data (CDDL): a notational convention to express CBOR data
structures", draft-greevenbosch-appsawg-cbor-cddl-08 (work structures", draft-greevenbosch-appsawg-cbor-cddl-08 (work
in progress), March 2016. in progress), March 2016.
[I-D.ietf-core-links-json] [I-D.ietf-core-links-json]
Li, K., Rahman, A., and D. Bormann, "Representing CoRE Li, K., Rahman, A., and C. Bormann, "Representing CoRE
Formats in JSON and CBOR", draft-ietf-core-links-json-05 Formats in JSON and CBOR", draft-ietf-core-links-json-06
(work in progress), April 2016. (work in progress), July 2016.
[RFC2141] Moats, R., "URN Syntax", RFC 2141, DOI 10.17487/RFC2141, [RFC2141] Moats, R., "URN Syntax", RFC 2141, DOI 10.17487/RFC2141,
May 1997, <http://www.rfc-editor.org/info/rfc2141>. May 1997, <http://www.rfc-editor.org/info/rfc2141>.
[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
Resource Identifier (URI): Generic Syntax", STD 66, RFC Resource Identifier (URI): Generic Syntax", STD 66, RFC
3986, DOI 10.17487/RFC3986, January 2005, 3986, DOI 10.17487/RFC3986, January 2005,
<http://www.rfc-editor.org/info/rfc3986>. <http://www.rfc-editor.org/info/rfc3986>.
[RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally
skipping to change at page 31, line 29 skipping to change at page 35, line 15
[RFC7721] Cooper, A., Gont, F., and D. Thaler, "Security and Privacy [RFC7721] Cooper, A., Gont, F., and D. Thaler, "Security and Privacy
Considerations for IPv6 Address Generation Mechanisms", Considerations for IPv6 Address Generation Mechanisms",
RFC 7721, DOI 10.17487/RFC7721, March 2016, RFC 7721, DOI 10.17487/RFC7721, March 2016,
<http://www.rfc-editor.org/info/rfc7721>. <http://www.rfc-editor.org/info/rfc7721>.
[UCUM] Schadow, G. and C. McDonald, "The Unified Code for Units [UCUM] Schadow, G. and C. McDonald, "The Unified Code for Units
of Measure (UCUM)", Regenstrief Institute and Indiana of Measure (UCUM)", Regenstrief Institute and Indiana
University School of Informatics, 2013, University School of Informatics, 2013,
<http://unitsofmeasure.org/ucum.html>. <http://unitsofmeasure.org/ucum.html>.
Appendix A. Links extension Appendix A. Links Extension
An extension to SenML to support links is expected to be registered An attribute to support a link extension for SenML is defined as a
and defined by [I-D.ietf-core-links-json]. string attribute by this specification. The link extension can be
used for additional information about a SenML Record. The definition
and usage of the contents of this value are specified in
[I-D.ietf-core-links-json].
The link extension can be an array of objects that can be used for For JSON and XML the attribute has a label of "l" and a value that is
additional information. Each object in the Link array is constrained a string.
to being a map of strings to strings with unique keys.
The following shows an example of the links extension. The following shows an example of the links extension.
[{"bn": "urn:dev:ow:10e2073a01080063/", [
"bt": 1320078429, {"bn":"urn:dev:ow:10e2073a01080063/","bt":1.320078429e+09,
"l": "[{\"href\":\"humidity\",\"foo\":\"bar1\"}", "l":"[{\"href\":\"humidity\",\"foo\":\"bar1\"}",
"n": "temperature", "v": 27.2, "u": "Cel" }, "n":"temperature","u":"Cel","v":27.2},
{ "n": "humidity", "v": 80, "u": "%RH" } {"n":"humidity","u":"%RH","v":80}
] ]
Authors' Addresses Authors' Addresses
Cullen Jennings Cullen Jennings
Cisco Cisco
400 3rd Avenue SW 400 3rd Avenue SW
Calgary, AB T2P 4H2 Calgary, AB T2P 4H2
Canada Canada
Phone: +1 408 421-9990 Phone: +1 408 421-9990
Email: fluffy@iii.ca Email: fluffy@iii.ca
Zach Shelby Zach Shelby
ARM ARM
150 Rose Orchard 150 Rose Orchard
San Jose 95134 San Jose 95134
USA USA
Phone: +1-408-203-9434 Phone: +1-408-203-9434
Email: zach.shelby@arm.com Email: zach.shelby@arm.com
Jari Arkko Jari Arkko
 End of changes. 61 change blocks. 
199 lines changed or deleted 332 lines changed or added

This html diff was produced by rfcdiff 1.45. The latest version is available from http://tools.ietf.org/tools/rfcdiff/