Skip to content

Commit 8e012a0

Browse files
committed
Added CoAP protocol mapping
1 parent ab17f99 commit 8e012a0

2 files changed

Lines changed: 79 additions & 6 deletions

File tree

cddl/coap-protocol-map.cddl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$$SDF-EXTENSION-DATA //= coap-protocol-map
2+
3+
coap-protocol-map = {
4+
method: "GET" / "POST" / "PUT" / "DELETE"
5+
uri: text
6+
? query: {text => text}
7+
? options: {text => text}
8+
}

draft-mohan-asdf-sdf-protocol-mapping.md

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,13 @@ protocol-specific operation, as implementations of the same affordance will
104104
differ between protocols. For example, BLE will address a property as a service
105105
characteristic, while a property in Zigbee is addressed as an attribute in a
106106
cluster of an endpoint. Again, HTTP is addressed by a method, an endpoint path,
107-
an optional query string, optional headers, and an optional body.
107+
an optional query string, optional headers, and an optional body. Finally, CoAP
108+
is addressed by a method, a URI, an optional query string and options set.
108109

109110
A protocol mapping object is a JSON object identified by the `sdfProtocolMap`
110111
keyword. Protocol-specific properties are embedded within this object, organized
111-
by protocol name, e.g., "ble" or "zigbee" or "http". The protocol name MUST be
112-
specified in the IANA registry requested in {{iana-prot-map}}.
112+
by protocol name, e.g., "ble" or "zigbee" or "http" or "coap". The protocol name
113+
MUST be specified in the IANA registry requested in {{iana-prot-map}}.
113114

114115
~~~ aasvg
115116
sdfProtocolMap
@@ -123,8 +124,11 @@ sdfProtocolMap
123124
| +--> Zigbee-specific mapping
124125
|
125126
+-----> http
126-
|
127-
+--> HTTP-specific mapping
127+
| |
128+
| +--> HTTP-specific mapping
129+
+-----> coap
130+
| |
131+
| +--> CoAP-specific mapping
128132
~~~
129133
{: #protmap title="Property Mapping"}
130134

@@ -344,7 +348,7 @@ parameters that are used to access the corresponding SDF affordances.
344348
~~~ cddl
345349
{::include cddl/http-protocol-map.cddl}
346350
~~~
347-
{: #httpmap1 title="CDDL definition for HTTP OpenAPI Protocol Mapping for properties, actions, and events"}
351+
{: #httpmap1 title="CDDL definition for HTTP Protocol Mapping for properties, actions, and events"}
348352

349353
Where:
350354

@@ -374,6 +378,64 @@ For example, a HTTP protocol mapping for a temperature property might look like:
374378

375379
The above SDF Protocol Mapping will be resolved to the following HTTP request: `GET /device/123/temperature/0?unit=celsius`.
376380

381+
### CoAP
382+
383+
The CoAP protocol mapping allows SDF models to specify how affordances should be
384+
accessed using the CoAP protocol. The mapping includes details such as method,
385+
URI, as well as optional query string and options.
386+
387+
~~~ cddl
388+
{::include cddl/coap-protocol-map.cddl}
389+
~~~
390+
{: #coapmap1 title="CDDL definition for CoAP Protocol Mapping for properties, actions, and events"}
391+
392+
Where:
393+
394+
- `method` is the method of the CoAP request towards the affordance. Allowed methods are `GET`, `POST`, `PUT`, and `DELETE`.
395+
- `uri` is the URI that identifies the resource associated to the affordance.
396+
- `query` is the optional query string expressed as a text map. The key of the map is the name of the query parameter and the value of the map is the value of the query parameter.
397+
- `options` is the optional set of CoAP options expressed as text map. The key of the map is the name of the option and the value of the map is the value of the option.
398+
399+
For example, a CoAP protocol mapping for a temperature property may look like:
400+
401+
~~~ jsonc
402+
{
403+
"sdfProperty": {
404+
"temperature": {
405+
"sdfProtocolMap": {
406+
"coap": {
407+
"method": "GET",
408+
"path": "/device/123/temperature/0",
409+
"query": {"unit": "celsius"},
410+
"options": {"Accept": "application/senml+json"},
411+
}
412+
}
413+
}
414+
}
415+
}
416+
~~~
417+
418+
The next example shows how to register for notifications with OBSERVE when a
419+
resource's value gets above 20, e.g., degree Celsius.
420+
421+
~~~ jsonc
422+
{
423+
"sdfProperty": {
424+
"temperature": {
425+
"sdfProtocolMap": {
426+
"coap": {
427+
"method": "GET",
428+
"path": "/device/123/temperature/0?above=20",
429+
"query": {"above": "20", "unit": "celsius"},
430+
"options": {"Accept": "application/senml+json",
431+
"Observe": 0},
432+
}
433+
}
434+
}
435+
}
436+
}
437+
~~~
438+
377439
### OpenAPI Protocol Mapping Structure
378440

379441
In the case of HTTP, SDF protocol mappings towards an SDF quality MAY be
@@ -480,6 +542,7 @@ Following protocol mappings are described in this document:
480542
| ble | Bluetooth Low Energy (BLE) | Protocol mapping for BLE devices | This document |
481543
| zigbee | Zigbee | Protocol mapping for Zigbee devices | This document |
482544
| http | HTTP | Protocol mapping for HTTP IP-based devices | This document |
545+
| coap | CoAP | Protocol mapping for CoAP IP-based devices | This document |
483546
{: #protmap-reg title="Protocol Mapping Registry"}
484547

485548
--- back
@@ -494,6 +557,8 @@ Following protocol mappings are described in this document:
494557
{::include cddl/zigbee-protocol-map.cddl}
495558

496559
{::include cddl/http-protocol-map.cddl}
560+
561+
{::include cddl/coap-protocol-map.cddl}
497562
~~~
498563

499564
# Acknowledgments

0 commit comments

Comments
 (0)