idnits 2.17.1 draft-ietf-core-interfaces-00.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (June 03, 2013) is 3972 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- ** Obsolete normative reference: RFC 5988 (Obsoleted by RFC 8288) == Outdated reference: A later version (-18) exists of draft-ietf-core-coap-14 == Outdated reference: A later version (-16) exists of draft-ietf-core-observe-08 Summary: 1 error (**), 0 flaws (~~), 3 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 CoRE Z. Shelby 3 Internet-Draft Sensinode 4 Intended status: Informational M.V. Vial 5 Expires: December 05, 2013 Schneider-Electric 6 June 03, 2013 8 CoRE Interfaces 9 draft-ietf-core-interfaces-00 11 Abstract 13 This document defines well-known REST interface descriptions for 14 Batch, Sensor, Parameter and Actuator types for use in contrained web 15 servers using the CoRE Link Format. A short reference is provided 16 for each type that can be efficiently included in the interface 17 description attribute of the CoRE Link Format. These descriptions 18 are intended to be for general use in resource designs or for 19 inclusion in more specific interface profiles. In addition, this 20 document defines the concepts of Function Set and Binding. The 21 former is the basis element to create RESTful profiles and the latter 22 helps the configuration of links between resources located on one or 23 more endpoints. 25 Status of This Memo 27 This Internet-Draft is submitted in full conformance with the 28 provisions of BCP 78 and BCP 79. 30 Internet-Drafts are working documents of the Internet Engineering 31 Task Force (IETF). Note that other groups may also distribute 32 working documents as Internet-Drafts. The list of current Internet- 33 Drafts is at http://datatracker.ietf.org/drafts/current/. 35 Internet-Drafts are draft documents valid for a maximum of six months 36 and may be updated, replaced, or obsoleted by other documents at any 37 time. It is inappropriate to use Internet-Drafts as reference 38 material or to cite them other than as "work in progress." 40 This Internet-Draft will expire on December 05, 2013. 42 Copyright Notice 44 Copyright (c) 2013 IETF Trust and the persons identified as the 45 document authors. All rights reserved. 47 This document is subject to BCP 78 and the IETF Trust's Legal 48 Provisions Relating to IETF Documents 49 (http://trustee.ietf.org/license-info) in effect on the date of 50 publication of this document. Please review these documents 51 carefully, as they describe your rights and restrictions with respect 52 to this document. Code Components extracted from this document must 53 include Simplified BSD License text as described in Section 4.e of 54 the Trust Legal Provisions and are provided without warranty as 55 described in the Simplified BSD License. 57 Table of Contents 59 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 60 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3 61 3. Function Set . . . . . . . . . . . . . . . . . . . . . . . . 4 62 3.1. Defining a Function Set . . . . . . . . . . . . . . . . . 4 63 3.1.1. Path template . . . . . . . . . . . . . . . . . . . . 4 64 3.1.2. Resource Type . . . . . . . . . . . . . . . . . . . . 5 65 3.1.3. Interface Description . . . . . . . . . . . . . . . . 5 66 3.1.4. Data type . . . . . . . . . . . . . . . . . . . . . . 5 67 3.2. Discovery . . . . . . . . . . . . . . . . . . . . . . . . 6 68 3.3. Versioning . . . . . . . . . . . . . . . . . . . . . . . 6 69 4. Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . 6 70 4.1. Format . . . . . . . . . . . . . . . . . . . . . . . . . 7 71 4.2. Binding methods . . . . . . . . . . . . . . . . . . . . . 8 72 4.3. Binding table . . . . . . . . . . . . . . . . . . . . . . 9 73 5. Interface Descriptions . . . . . . . . . . . . . . . . . . . 9 74 5.1. Link List . . . . . . . . . . . . . . . . . . . . . . . . 10 75 5.2. Batch . . . . . . . . . . . . . . . . . . . . . . . . . . 11 76 5.3. Linked Batch . . . . . . . . . . . . . . . . . . . . . . 11 77 5.4. Sensor . . . . . . . . . . . . . . . . . . . . . . . . . 13 78 5.5. Parameter . . . . . . . . . . . . . . . . . . . . . . . . 13 79 5.6. Read-only Parameter . . . . . . . . . . . . . . . . . . . 14 80 5.7. Actuator . . . . . . . . . . . . . . . . . . . . . . . . 14 81 5.8. Binding . . . . . . . . . . . . . . . . . . . . . . . . . 15 82 5.9. Resource Observation Attributes . . . . . . . . . . . . . 15 83 5.10. Future Interfaces . . . . . . . . . . . . . . . . . . . . 18 84 5.11. WADL Description . . . . . . . . . . . . . . . . . . . . 18 85 6. Security Considerations . . . . . . . . . . . . . . . . . . . 22 86 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 22 87 8. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 22 88 9. Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . 22 89 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 23 90 10.1. Normative References . . . . . . . . . . . . . . . . . . 23 91 10.2. Informative References . . . . . . . . . . . . . . . . . 23 92 Appendix A. Profile example . . . . . . . . . . . . . . . . . . 23 93 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 25 95 1. Introduction 96 The Constrained RESTful Environments (CoRE) working group aims at 97 realizing the REST architecture in a suitable form for the most 98 constrained nodes (e.g. 8-bit microcontrollers with limited RAM and 99 ROM) and networks (e.g. 6LoWPAN). CoRE is aimed at machine-to- 100 machine (M2M) applications such as smart energy and building 101 automation. 103 The discovery of resources offered by a constrained server is very 104 important in machine-to-machine applications where there are no 105 humans in the loop and static interfaces result in fragility. The 106 discovery of resources provided by an HTTP Web Server is typically 107 called Web Linking [RFC5988]. The use of Web Linking for the 108 description and discovery of resources hosted by constrained web 109 servers is specified by the CoRE Link Format 110 [I-D.ietf-core-link-format] and can be used by CoAP 111 [I-D.ietf-core-coap] or HTTP servers. The CoRE Link Format defines 112 an attribute that can be used to describe the REST interface of a 113 resource, and may include a link to a description document. This 114 memo describes how other specifications can combine resources with a 115 well-known interface to create new CoRE RESTful profiles. A CoRE 116 profile is based on the concept of Function Set, which is a group of 117 REST resources providing a service in a distributed system. In 118 addition, the notion of Binding is introduced in order to create a 119 synchronization link between two resources. This document also 120 defines well-known interface descriptions for Batch, Sensor, 121 Parameter and Actuator types to compose new Function Sets or for 122 standalone use in a constrained web server. A short reference is 123 provided for each type that can be efficiently included in the 124 interface description (if=) attribute of the CoRE Link Format. 126 2. Terminology 128 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 129 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 130 document are to be interpreted as described in [RFC2119]. 132 This specification requires readers to be familiar with all the terms 133 and concepts that are discussed in [RFC5988] and 134 [I-D.ietf-core-link-format]. This specification makes use of the 135 following additional terminology: 137 Function Set: A group of well-known REST resources that provides a 138 particular service. 140 Profile: A group of well-known Function Sets defined by a 141 specification. 143 Device: An IP smart object running a web server that hosts a group 144 of Function Set instances from a profile. 146 Service Discovery: The process making it possible for a web client 147 to automatically detect devices and Function Sets offered by these 148 devices on a CoRE network. 150 Resource Discovery: The process allowing a web client to identify 151 resources being hosted on a web server. 153 Gradual Reveal: A REST design where resources are discovered 154 progressively using Web Linking. 156 Binding: A unidirectional logical link between a source resource and 157 a destination resource. 159 3. Function Set 161 This section defines how a specification can organize REST resources 162 to create a new profile. A profile is structured into groups of 163 resource types called Function Sets. A Function Set is similar to a 164 function block in the sense that it consists of input, output and 165 parameter resources and contains internal logic. A Function Set MAY 166 have a subset of mandatory inputs, outputs and parameters to provide 167 minimum interoperability. It MAY also be extended with manufacturer/ 168 user-specific resources. Other specifications defines the list of 169 function sets available within a given profile. A device is composed 170 of one or more Function Set instances. A profile specification MAY 171 specify device profiles with mandatory function sets. 173 3.1. Defining a Function Set 175 In a Function Set, types of resources are defined. Each type 176 includes a human readable name, a path template, a Resource Type for 177 discovery, the Interface Definition and the data type and allowed 178 values. A Function Set definition may also include a field 179 indicating if a sub-resource is mandatory or optional. 181 3.1.1. Path template 183 A Function Set is a container resource under which its sub-resources 184 are organized. The profile defines the path to each resource of a 185 Function Set in a path template. The template can contain either 186 relative paths or absolute paths depending on the profile needs. An 187 absolute Function Set SHOULD be located at its recommended root path 188 on a web server, however it MAY be located under an alternative path 189 if necessary (for example multi-purpose devices, gateways etc.). A 190 relative Function Set can be instantiated as many times as needed on 191 a web server with an arbitrary root path. However some Function Sets 192 (e.g. device description) only make sense as singletons. 194 The path template includes a possible index {#} parameter, and 195 possible fixed path segments. The index {#} allows for multiple 196 instances of this type of resource, and can be any string. The root 197 path and the indexes are the only variable elements in a path 198 template. All other path segments MUST be fixed. 200 3.1.2. Resource Type 202 Each root resource of a Function Set is assigned a Resource Type 203 parameter, therefore making it possible to discover it. Each sub- 204 resource of a Function Set is also assigned a Resource Type 205 parameter. This Resource Type is used for resource discovery and is 206 usually necessary to discover optional resources supported on a 207 specific device. The Resource Type of a Function Set may also be 208 used for service discovery and MAY be exported to DNS-SD 209 [I-D.cheshire-dnsext-dns-sd] for example. 211 The Resource Type parameter defines the value that MUST be included 212 in the rt= field of the CoRE Link Format when describing a link to 213 this resource. The value SHOULD be in the form "namespace.type" for 214 root resources and "namespace.type.subtype" for sub-resources. This 215 naming convention facilitates resource type filtering with the / 216 .well-known/core resource. However a profile MAY allow mixing in 217 foreign namespace references within a Function Set to import external 218 references from other object models (e.g. SenML and UCUM). 220 3.1.3. Interface Description 222 The Interface Description parameter defines the REST interface for 223 that type of resource. Several base interfaces are defined in 224 Section 5 of this document. For a given profile, the Interface 225 Description may be inferred from the Resource Type. In that case the 226 Interface Description MAY be elided from link descriptions of 227 resource types defined in the profile, but SHOULD be included for 228 custom extensions to the profile. 230 The root resource of a Function Set should provide a list of links to 231 its sub-resources in order to offer gradual reveal of resources. The 232 CoRE Link List interface defined in Section 5.1 offers this 233 functionality so a root resource SHOULD support this interface or a 234 derived interface like CoRE Batch (See Section 5.2). 236 3.1.4. Data type 237 The Data Type field defines the type of value (and possible range) 238 that is returned in response to a GET for that resource or accepted 239 with a PUT. The interfaces defined in Section 5 make use of plain 240 text and SenML Media types for the actual format of this data. A 241 profile may restrict the list of supported content types for the CoRE 242 interfaces or define new interfaces with new content types. 244 3.2. Discovery 246 A device conforming to a profile SHOULD make its resources 247 discoverable by providing links to the resources on the path /.well- 248 known/core as defined in [I-D.ietf-core-link-format]. All resources 249 hosted on a device SHOULD be discoverable either with a direct link 250 in /.well-known/core or by following successive links starting from / 251 .well-known/core. 253 The root path of a Function Set instance SHOULD be directly 254 referenced in /.well-known/core in order to offer discovery at the 255 first discovery stage. A device with more than 10 individual 256 resources SHOULD only expose Function Set instances in /.well-known/ 257 core to limit the size of this resource. 259 In addition, a device MAY register its resources to a Resource 260 Directory using the registration interface defined in 261 [I-D.shelby-core-resource-directory] if such a directory is 262 available. 264 3.3. Versioning 266 A profile should track Function Set changes to avoid incompatibility 267 issues. Evolutions in a Function Set SHOULD be backward compatible. 269 4. Bindings 271 In a M2M RESTful environment, endpoints exchange the content of their 272 resources to operate the distributed system. Beforehand, a 273 configuration phase is necessary to determine how the resources of 274 the different endpoints are related to each other. This can be done 275 either automatically using discovery mechanisms or by means of human 276 intervention and a so-called commissioning tool. In this document 277 the abstract relationship between two resources is called a Binding. 278 The configuration phase necessitates the exchange of binding 279 information so a format recognized by all CoRE endpoints is 280 essential. This document defines a format based on the CoRE Link- 281 Format to represent binding information along with the rules to 282 define a binding method which is a specialized relationship between 283 two resources. The purpose of a binding is to synchronize the 284 content between a source resource and a destination resource. The 285 destination resource MAY be a group resource if the authority 286 component of the destination URI contains a group address (either a 287 multicast address or a name that resolves to a multicast address). 288 Since a binding is unidirectional, the binding entry defining a 289 relationship is present only on one endpoint. The binding entry may 290 be located either on the source or the destination endpoint depending 291 on the binding method. The following table gives a summary of the 292 binding methods described in more detail in Section 4.2. 294 +---------+------------+-------------+---------------+ 295 | Name | Identifier | Location | Method | 296 +---------+------------+-------------+---------------+ 297 | Polling | poll | Destination | GET | 298 | Observe | obs | Destination | GET + Observe | 299 | Push | push | Source | PUT | 300 +---------+------------+-------------+---------------+ 302 4.1. Format 304 Since Binding lies in the creation of a link between two resources, 305 Web Linking and the CoRE Link-Format are a natural way to represent 306 binding information. This involves the creation of a new relation 307 type, purposely named "boundto". In a Web link with this relation 308 type, the target URI contains the location of the source resource and 309 the context URI points to the destination resource. The Web link 310 attributes allow a fine-grained control of the type of 311 synchronization exchange along with the conditions that trigger an 312 update. This specification defines the attributes below: 314 +--------------------+-----------+------------------+ 315 | Attribute | Parameter | Value | 316 +--------------------+-----------+------------------+ 317 | Binding method | bind | xsd:string | 318 | Minimum Period (s) | pmin | xsd:integer (>0) | 319 | Maximum Period (s) | pmax | xsd:integer (>0) | 320 | Change Step | st | xsd:decimal (>0) | 321 +--------------------+-----------+------------------+ 323 Bind Method: This is the identifier of a binding method which 324 defines the rules to synchronize the destination resource. This 325 attribute is mandatory. 327 Minimum Period: When present, the minimum period indicates the 328 minimum time to wait (in seconds) before sending a new 329 synchronization message (even if it has changed). In the absence 330 of this parameter, the minimum period is up to the notifier. 332 Maximum Period: When present, the maximum period indicates the 333 maximum time in seconds between two consecutive syncronization 334 messages (regardless if it has changed). In the absence of this 335 parameter, the maximum period is up to the notifier. The maximum 336 period MUST be greater than the minimum period parameter (if 337 present). 339 Change Step: When present, the change step indicates how much the 340 value of a resource SHOULD change before sending a new 341 notification (compared to the value of the last notification). 342 This parameter has lower priority than the period parameters, thus 343 even if the change step has been fulfilled, the time since the 344 last notification SHOULD be between pmin and pmax. 346 4.2. Binding methods 348 A binding method defines the rules to generate the web-transfer 349 exchanges that will effectively send content from the source resource 350 to the destination resource. The description of a binding method 351 must define the following aspects: 353 Identifier: This is value of the "bind" attribute used to identify 354 the method. 356 Location: This information indicates whether the binding entry is 357 stored on the source or on the destination endpoint. 359 REST Method: This is the REST method used in the Request/Response 360 exchanges. 362 Conditions: A binding method definition must state how the condition 363 attributes of the abstract binding definition are actually used in 364 this specialized binding. 366 This specification supports 3 binding methods described below. 368 Polling: The Polling method consists of sending periodic GET 369 requests from the destination endpoint to the source resource and 370 copying the content to the destination resource. The binding 371 entry for this method MUST be stored on the destination endpoint. 372 The destination endpoint MUST ensure that the polling frequency 373 does not exceed the limits defined by the pmin and pmax attributes 374 of the binding entry. The copying process MAY filter out content 375 from the GET requests using value-based conditions (e.g Change 376 Step). 378 Observe: The Observe method relies on the Publish/Subscribe pattern 379 thus an observation relationship is created between the 380 destination endpoint and the source resource. On each 381 notification the content from the source resource is copied to the 382 destination resource. The creation of the observation 383 relationship requires the CoAP Observation mechanism 384 [I-D.ietf-core-observe] hence this method is only permitted when 385 the resources are made available over CoAP. The binding entry for 386 this method MUST be stored on the destination endpoint. The 387 binding conditions are mapped as query string parameters (see 388 Section 5.9). 390 Push: When the Push method is assigned to a binding, the source 391 endpoint sends PUT requests to the destination resource upon 392 change of the source resource. The source endpoint MUST only send 393 a notification request if the binding conditions are met. The 394 binding entry for this method MUST be stored on the source 395 endpoint. 397 4.3. Binding table 399 The binding table is a special resource that gives access to the 400 bindings on a endpoint. A binding table resource MUST support the 401 Binding interface defined in Section 5.8. A profile SHOULD allow 402 only one resource table per endpoint. 404 5. Interface Descriptions 406 This section defines REST interfaces for Link List, Batch, Sensor, 407 Parameter, Actuator and Binding table resources. Variants such as 408 Linked Batch or Read-Only Parameter are also presented. Each type is 409 described along with its Interface Description attribute value and 410 valid methods. These are defined for each interface in the table 411 below. These interfaces can support plain text and/or SenML Media 412 types. 414 The if= column defines the Interface Description (if=) attribute 415 value to be used in the CoRE Link Format for a resource conforming to 416 that interface. When this value appears in the if= attribute of a 417 link, the resource MUST support the corresponding REST interface 418 described in this section. The resource MAY support additional 419 functionality, which is out of scope for this specification. 420 Although these interface descriptions are intended to be used with 421 the CoRE Link Format, they are applicable for use in any REST 422 interface definition. 424 The Methods column defines the methods supported by that interface, 425 which are described in more detail below. 427 +-------------------+---------------+-------------------------------+ 428 | Interface | if= | Methods | 429 +-------------------+---------------+-------------------------------+ 430 | Link List | core.ll | GET | 431 | Batch | core.b | GET, PUT, POST (where | 432 | | | applicable) | 433 | Linked Batch | core.lb | GET, PUT, POST, DELETE (where | 434 | | | applicable) | 435 | Sensor | core.s | GET | 436 | Parameter | core.p | GET, PUT | 437 | Read-only | core.rp | GET | 438 | Parameter | | | 439 | Actuator | core.a | GET, PUT, POST | 440 | Binding | core.bnd | GET, POST, DELETE | 441 +-------------------+---------------+-------------------------------+ 443 The following is an example of links in the CoRE Link Format using 444 these interface descriptions. The resource hierarchy is based on a 445 simple profile defined in Appendix A. These links are used in the 446 subsequent examples below. 448 Req: GET /.well-known/core 449 Res: 2.05 Content (application/link-format) 450 ;rt="simple.sen";if="core.b", 451 ;rt="simple.sen.lt";if="core.s", 452 ;rt="simple.sen.tmp";if="core.s";obs, 453 ;rt="simple.sen.hum";if="core.s", 454 ;rt="simple.act";if="core.b", 455 ;rt="simple.act.led";if="core.a", 456 ;rt="simple.act.led";if="core.a", 457 ;rt="simple.dev";if="core.ll", 458 ;if="core.lb", 460 5.1. Link List 462 The Link List interface is used to retrieve (GET) a list of resources 463 on a web server. The GET request SHOULD contain an Accept option 464 with the application/link-format content type, however if the 465 resource does not support any other form of GET methods the Accept 466 option MAY be elided. The Accept option SHOULD only include the 467 application/link-format content type. The request returns a list of 468 URI references with absolute paths to the resources as defined in 469 CoRE Link Format. This interface is typically used with a parent 470 resource to enumerate sub-resources but may be used to reference any 471 resource on a web server. 473 Link List is the base interface to provide gradual reveal of 474 resources on a CoRE web server, hence the root resource of a Function 475 Set SHOULD implement this interface or an extension of this 476 interface. 478 The following example interacts with a Link List /d containing 479 Parameter sub-resources /d/name, /d/model. 481 Req: GET /d (Accept:application/link-format) 482 Res: 2.05 Content (application/link-format) 483 ;rt="simple.dev.n";if="core.p", 484 ;rt="simple.dev.mdl";if="core.rp" 486 5.2. Batch 488 The Batch interface is used to manipulate a collection of sub- 489 resources at the same time. The Batch interface type supports the 490 same methods as its sub-resources, and can be used to read (GET), set 491 (PUT) or toggle (POST) the values of those sub-resource with a single 492 resource representation. The sub-resources of a Batch MAY be 493 heterogeneous, a method used on the Batch only applies to sub- 494 resources that support it. For example Sensor interfaces do not 495 support PUT, and thus a PUT request to a Sensor member of that Batch 496 would be ignored. A batch requires the use of SenML Media types in 497 order to support multiple sub-resources. 499 In addition, The Batch interface is an extension of the Link List 500 interface and in consequence MUST support the same methods. 502 The following example interacts with a Batch /s with Sensor sub- 503 resources /s/light, /s/temp and /s/humidity. 505 Req: GET /s 506 Res: 2.05 Content (application/senml+json) 507 {"e":[ 508 { "n": "light", "v": 123, "u": "lx" }, 509 { "n": "temp", "v": 27.2, "u": "degC" }, 510 { "n": "humidity", "v": 80, "u": "%RH" }], 511 } 513 5.3. Linked Batch 514 The Linked Batch interface is an extension of the Batch interface. 515 Contrary to the basic Batch which is a collection statically defined 516 by the web server, a Linked Batch is dynamically controlled by a web 517 client. A Linked Batch resource has no sub-resources. Instead the 518 resources forming the batch are referenced using Web Linking 519 [RFC5988] and the CoRE Link Format [I-D.ietf-core-link-format]. A 520 request with a POST method and a content type of application/link- 521 format simply appends new resources to the collection. The links in 522 the payload MUST reference a resource on the web server with an 523 absolute path. A DELETE request empties the current collection of 524 links. All other requests available for a basic Batch are still 525 valid for a Linked Batch. 527 The following example interacts with a Linked Batch /l and creates a 528 collection containing /s/light, /s/temp and /s/humidity in 2 steps. 530 Req: POST /l (Content-type: application/link-format) 531 , 532 Res: 2.04 Changed 534 Req: GET /l 535 Res: 2.05 Content (application/senml+json) 536 {"e":[ 537 { "n": "/s/light", "v": 123, "u": "lx" }, 538 { "n": "/s/temp", "v": 27.2, "u": "degC" }, 539 } 541 Req: POST /l (Content-type: application/link-format) 542 543 Res: 2.04 Changed 545 Req: GET /l (Accept: application/link-format) 546 Res: 2.05 Content (application/link-format) 547 ,, 549 Req: GET /l 550 Res: 2.05 Content (application/senml+json) 551 {"e":[ 552 { "n": "/s/light", "v": 123, "u": "lx" }, 553 { "n": "/s/temp", "v": 27.2, "u": "degC" }, 554 { "n": "/s/humidity", "v": 80, "u": "%RH" }], 555 } 557 Req: DELETE /l 558 Res: 2.04 Changed 560 5.4. Sensor 562 The Sensor interface allows the value of a sensor resource to be read 563 (GET). The Media type of the resource can be either plain text or 564 SenML. Plain text MAY be used for a single measurement that does not 565 require meta-data. For a measurement with meta-data such as a unit 566 or time stamp, SenML SHOULD be used. A resource with this interface 567 MAY use SenML to return multiple measurements in the same 568 representation, for example a list of recent measurements. 570 The following are examples of Sensor interface requests in both text/ 571 plain and application/senml+json. 573 Req: GET /s/humidity (Accept: text/plain) 574 Res: 2.05 Content (text/plain) 575 80 577 Req: GET /s/humidity (Accept: application/senml+json) 578 Res: 2.05 Content (application/senml+json) 579 {"e":[ 580 { "n": "humidity", "v": 80, "u": "%RH" }], 581 } 583 5.5. Parameter 585 The Parameter interface allows configurable parameters and other 586 information to be modeled as a resource. The value of the parameter 587 can be read (GET) or set (PUT). Plain text or SenML Media types MAY 588 be returned from this type of interface. 590 The following example shows request for reading and setting a 591 parameter. 593 Req: GET /d/name 594 Res: 2.05 Content (text/plain) 595 node5 597 Req: PUT /d/name (text/plain) 598 outdoor 599 Res: 2.04 Changed 601 5.6. Read-only Parameter 603 The Read-only Parameter interface allows configuration parameters to 604 be read (GET) but not set. Plain text or SenML Media types MAY be 605 returned from this type of interface. 607 The following example shows request for reading such a parameter. 609 Req: GET /d/model 610 Res: 2.05 Content (text/plain) 611 SuperNode200 613 5.7. Actuator 615 The Actuator interface is used by resources that model different 616 kinds of actuators (changing its value has an effect on its 617 environment). Examples of actuators include for example LEDs, 618 relays, motor controllers and light dimmers. The current value of 619 the actuator can be read (GET) or a new actuator value set (PUT). In 620 addition, this interface defines the use of POST (with no body) to 621 toggle an actuator between its possible values. Plain text or SenML 622 Media types MAY be returned from this type of interface. A resource 623 with this interface MAY use SenML to include multiple measurements in 624 the same representation, for example a list of recent actuator values 625 or a list of values to set. 627 The following example shows requests for reading, setting and 628 toggling an actuator (turning on a led). 630 Req: GET /a/1/led 631 Res: 2.05 Content (text/plain) 632 0 634 Req: PUT /a/1/led (text/plain) 635 1 636 Res: 2.04 Changed 638 Req: POST /a/1/led (text/plain) 639 Res: 2.04 Changed 641 Req: GET /a/1/led 642 Res: 2.05 Content (text/plain) 643 0 645 5.8. Binding 647 The Binding interface is used to manipulate a binding table. A 648 request with a POST method and a content type of application/link- 649 format simply appends new bindings to the table. All links in the 650 payload MUST have a relation type "boundTo". A GET request simply 651 returns the current state of a binding table whereas a DELETE request 652 empties the table. 654 The following example shows requests for adding, retrieving and 655 deleting bindings in a binding table. 657 Req: POST /bnd (Content-type: application/link-format) 658 ; 659 rel="boundto";anchor="/a/light";bind="obs";pmin="10";pmax="60" 660 Res: 2.04 Changed 662 Req: GET /bnd 663 Res: 2.05 Content (application/link-format) 664 ; 665 rel="boundto";anchor="/a/light";bind="obs";pmin="10";pmax="60" 667 Req: DELETE /bnd 668 Res: 2.04 Changed 670 5.9. Resource Observation Attributes 671 When resource interfaces following this specification are made 672 available over CoAP, the CoAP Observation mechanism 673 [I-D.ietf-core-observe] MAY be used to observe any changes in a 674 resource, and receive asynchronous notifications as a result. In 675 addition, a set of query string parameters are defined here to allow 676 a client to control how often a client is interested in receiving 677 notifications and how much a resource value should change for the new 678 representation to be interesting. These query parameters are 679 described in the following table. A resource using an interface 680 description defined in this specification and marked as Observable in 681 its link description SHOULD support these observation parameters. 682 The Change Step parameter can only be supported on resources with an 683 atomic numeric value. 685 These query parameters MUST be treated as resources that are read 686 using GET and set using PUT, and MUST NOT be included in the Observe 687 request. Multiple parameters MAY be set at the same time by 688 including the values in the query string of a PUT. Before being set, 689 these parameters have no default value. 691 +--------------------+------------------+------------------+ 692 | Resource | Parameter | Data Format | 693 +--------------------+------------------+------------------+ 694 | Minimum Period (s) | /{resource}?pmin | xsd:integer (>0) | 695 | Maximum Period (s) | /{resource}?pmax | xsd:integer (>0) | 696 | Change Step | /{resource}?st | xsd:decimal (>0) | 697 | Less Than | /{resource}?lt | xsd:decimal | 698 | Greater Than | /{resource}?gt | xsd:decimal | 699 +--------------------+------------------+------------------+ 701 Minimum Period: When set, the minimum period indicates the minimum 702 time in seconds the server SHOULD wait between sending 703 notifications. In the absence of this parameter, the minimum 704 period is up to the server. 706 Maximum Period: When set, the maximum period indicated the maximum 707 time in seconds the server SHOULD wait between sending 708 notifications (regardless if it has changed). In the absence of 709 this parameter, the maximum period is up to the server. The 710 maximum period MUST be greater than the minimum period parameter 711 (if present). 713 Change Step: When set, the change step indicates how much the value 714 of a resource SHOULD change before sending a new notification 715 (compared to the value of the last notification). This parameter 716 has lower priority than the period parameters, thus even if the 717 change step has been fulfilled, the time since the last 718 notification SHOULD be between pmin and pmax. 720 Less Than: When set, the value of the resource MUST be less than 721 this parameter in order to send a new notification. This 722 parameter has lower priority than the period parameters. 724 Greater Than: When set, the value of the resource MUST be greater 725 than this parameter in order to send a new notification. This 726 parameter has lower priority than the period parameters. 728 The following example shows an Observation request using these query 729 parameters. Here the value of Observe indicates the number of 730 seconds since the observation was made to show the time. 732 Req PUT /s/temp?pmin=10&pmax=60&st=1 733 Res: 2.04 Changed 735 Req: GET Observe /s/temp 736 Res: 2.05 Content Observe:0 (text/plain) 737 23.2 739 Res: 2.05 Content Observe:60 (text/plain) 740 23.0 742 Res: 2.05 Content Observe:80 (text/plain) 743 22.0 745 Res: 2.05 Content Observe:140 (text/plain) 746 21.8 748 The following example shows a request to check the current value of 749 the pmin attribute of the Observable resource from the last example. 751 Req: GET /s/temp?pmin 752 Res: 2.05 Content (text/plain) 753 10 755 5.10. Future Interfaces 757 It is expected that further interface descriptions will be defined in 758 this and other specifications. Potential interfaces to be considered 759 for this specifications include: 761 Collection: This resource would be a container that allows sub- 762 resources to be added or removed. 764 5.11. WADL Description 766 This section defines the formal Web Application Description Langauge 767 (WADL) definition of these CoRE interface descriptions. 769 771 775 776 777 779 781 782 783 784 785 787 788 789 790 791 792 794 795 796 797 798 800 801 802 803 804 805 806 808 809 810 811 813 814 The methods read, 815 observe, update and toggle are applied to each sub- 816 resource of the requested resource that supports it. Mixed 817 sub-resource types can be supported. 818 819 820 821 822 823 825 826 . The methods read, 827 obervableRead, update and toggle are applied to each linked 828 resource of the requested resource that supports it. Mixed 829 linked resource types can be supported. 830 831 832 833 834 835 836 838 839 A modifiable list of 840 links. Each link MUST have the relation type "boundTo". 841 842 843 844 846 847 Retrieve the value of a sensor, an actuator or a parameter. 848 Both HTTP and CoAP support this method. 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 865 866 Observe the value of a sensor, an actuator or a parameter. 867 Only CoAP supports this method since it requires the CoRE 868 Observe mechanism. 869 870 871 872 873 874 875 876 877 878 879 880 882 883 Control the actuator or update a parameter with a new value 884 or command. Both HTTP and CoAP support this method. 885 886 887 888 889 890 891 892 893 895 896 Toggle the values of actuator resources. Both HTTP and CoAP 897 support this method. 898 899 The toggle function is only applicable if the request 900 is empty. 901 902 903 904 906 907 Retrieve the list of Web links associated to a resource. 908 Both HTTP and CoAP support this method. 909 910 This request MUST contain an Accept option with 911 application/link-format when the resource supports 912 other GET methods. 913 914 915 916 917 918 919 920 922 923 Append new Web links to a resource which is a collection 924 of links. Both HTTP and CoAP support this method. 925 926 927 928 929 930 932 933 Clear all Web Links in a resource which is a collection 934 of links. Both HTTP and CoAP support this method. 935 936 937 938 939 941 943 6. Security Considerations 945 An implementation of a client needs to be prepared to deal with 946 responses to a request that differ from what is specified in this 947 document. A server implementing what the client thinks is a resource 948 with one of these interface descriptions could return malformed 949 representations and response codes either by accident or maliciously. 950 A server sending maliciously malformed responses could attempt to 951 take advantage of a poorly implemented client for example to crash 952 the node or perform denial of service. 954 7. IANA Considerations 956 The interface description types defined require registration. 958 The new link relation type "boundto" requires registration. 960 8. Acknowledgments 962 Acknowledgement is given to colleagues from the SENSEI project who 963 were critical in the initial development of the well-known REST 964 interface concept, to members of the IPSO Alliance where further 965 requirements for interface types have been discussed, and to Szymon 966 Sasin, Cedric Chauvenet, Daniel Gavelle and Carsten Bormann who have 967 provided useful discussion and input to the concepts in this 968 document. 970 9. Changelog 972 Changes from -05 to WG Document -00 974 o Updated the date and version. 976 Changes from -04 to -05 978 o Made the Observation control parameters to be treated as resources 979 rather than Observe query parameters. Added Less Than and Greater 980 Than parameters. 982 Changes from -03 to -04 984 o Draft refresh 986 Changes from -02 to -03 988 o Added Bindings 990 o Updated all rt= and if= for the new Link Format IANA rules 991 Changes from -01 to -02 993 o Defined a Function Set and its guidelines. 995 o Added the Link List interface. 997 o Added the Linked Batch interface. 999 o Improved the WADL interface definition. 1001 o Added a simple profile example. 1003 10. References 1005 10.1. Normative References 1007 [I-D.ietf-core-link-format] 1008 Shelby, Z., "CoRE Link Format", draft-ietf-core-link- 1009 format-14 (work in progress), June 2012. 1011 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1012 Requirement Levels", BCP 14, RFC 2119, March 1997. 1014 [RFC5988] Nottingham, M., "Web Linking", RFC 5988, October 2010. 1016 10.2. Informative References 1018 [I-D.cheshire-dnsext-dns-sd] 1019 Cheshire, S. and M. Krochmal, "DNS-Based Service 1020 Discovery", draft-cheshire-dnsext-dns-sd-11 (work in 1021 progress), December 2011. 1023 [I-D.ietf-core-coap] 1024 Shelby, Z., Hartke, K., and C. Bormann, "Constrained 1025 Application Protocol (CoAP)", draft-ietf-core-coap-14 1026 (work in progress), March 2013. 1028 [I-D.ietf-core-observe] 1029 Hartke, K., "Observing Resources in CoAP", draft-ietf- 1030 core-observe-08 (work in progress), February 2013. 1032 [I-D.shelby-core-resource-directory] 1033 Shelby, Z., Krco, S., and C. Bormann, "CoRE Resource 1034 Directory", draft-shelby-core-resource-directory-05 (work 1035 in progress), February 2013. 1037 Appendix A. Profile example 1038 The following is a short definition of simple profile. This 1039 simplistic profile is for use in the examples of this document. 1041 +--------------------+-----------+------------+---------+ 1042 | Function Set | Root Path | RT | IF | 1043 +--------------------+-----------+------------+---------+ 1044 | Device Description | /d | simple.dev | core.ll | 1045 | Sensors | /s | simple.sen | core.b | 1046 | Actuators | /a | simple.act | core.b | 1047 +--------------------+-----------+------------+---------+ 1049 List of Function Sets 1051 +-------+----------+----------------+---------+------------+ 1052 | Type | Path | RT | IF | Data Type | 1053 +-------+----------+----------------+---------+------------+ 1054 | Name | /d/name | simple.dev.n | core.p | xsd:string | 1055 | Model | /d/model | simple.dev.mdl | core.rp | xsd:string | 1056 +-------+----------+----------------+---------+------------+ 1058 Device Description Function Set 1060 +-------------+-------------+----------------+--------+-------------+ 1061 | Type | Path | RT | IF | Data Type | 1062 +-------------+-------------+----------------+--------+-------------+ 1063 | Light | /s/light | simple.sen.lt | core.s | xsd:decimal | 1064 | | | | | (lux) | 1065 | Humidity | /s/humidity | simple.sen.hum | core.s | xsd:decimal | 1066 | | | | | (%RH) | 1067 | Temperature | /s/temp | simple.sen.tmp | core.s | xsd:decimal | 1068 | | | | | (degC) | 1069 +-------------+-------------+----------------+--------+-------------+ 1071 Sensors Function Set 1073 +------+------------+----------------+--------+-------------+ 1074 | Type | Path | RT | IF | Data Type | 1075 +------+------------+----------------+--------+-------------+ 1076 | LED | /a/{#}/led | simple.act.led | core.a | xsd:boolean | 1077 +------+------------+----------------+--------+-------------+ 1079 Actuators Function Set 1081 Authors' Addresses 1083 Zach Shelby 1084 Sensinode 1085 Kidekuja 2 1086 Vuokatti 88600 1087 FINLAND 1089 Phone: +358407796297 1090 Email: zach@sensinode.com 1092 Matthieu Vial 1093 Schneider-Electric 1094 Grenoble 1095 FRANCE 1097 Phone: +33 (0)47657 6522 1098 Email: matthieu.vial@schneider-electric.com