Skip to content

Commit bf39a23

Browse files
committed
feat: Add ADR for device functions
Signed-off-by: Iain Anderson <[email protected]>
1 parent 0c10af4 commit bf39a23

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

docs_src/design/TOC.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
| [0016 Container Image Guidelines](./adr/security/0016-docker-image-guidelines.md) | Documents best practices for security of docker images |
1919
| [0017 Securing access to Consul](./adr/security/0017-consul-security.md) | Access control and authorization strategy for Consul |
2020
| [0018 Service Registry](./adr/0018-Service-Registry.md) | Service registry usage for EdgeX services |
21-
| [0019 EdgeX-CLI V2](./adr/core/0019-EdgeX-CLI-V2.md) | EdgeX-CLI V2 Implementation |
21+
| [0019 EdgeX-CLI V2](./adr/core/0019-EdgeX-CLI-V2.md) | EdgeX-CLI V2 Implementation |
22+
| [0020 Invoking Device Functions](./adr/device-service/0020-invoking-functions.md) | RPC-like actions for devices |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Invoking Device Functions
2+
3+
4+
## Status
5+
6+
**Draft**
7+
8+
## Context
9+
This ADR presents a mechanism for invoking functions on a device.
10+
11+
## Existing Behavior
12+
13+
Device access in EdgeX is focussed on 'Readings' and 'Settings'. A device may
14+
present values which are readable, representing some measurement or status,
15+
such as a temperature or vibration reading. Also a setting such as a the
16+
required speed of a fan motor may be written to and read back.
17+
18+
What is not supported directly is 'Functions', where a device may be commanded
19+
to do something. Examples could include perform a self-test, go into standby
20+
mode for an hour, invalidate an access key.
21+
22+
While such operations may modelled using virtual resources in a device profile,
23+
this is unintuitive.
24+
25+
## Decision
26+
27+
1. Add a new section to device profiles describing functions
28+
29+
{
30+
"deviceFunctions":
31+
[
32+
{
33+
"name": "Name by which the function is accessed",
34+
"description": "Readable description of the function",
35+
"attributes": { device-specific parameters which select this function },
36+
"parameters":
37+
{
38+
"in":
39+
[
40+
{
41+
"name": "Parameter name",
42+
"description": "description of what the parameter controls",
43+
"type": "Any of the usual EdgeX data types"
44+
}
45+
],
46+
"out":
47+
[
48+
{
49+
"name": "Parameter name",
50+
"description": "description of what the parameter controls",
51+
"type": "Any of the usual EdgeX data types"
52+
}
53+
]
54+
}
55+
}
56+
]
57+
}
58+
59+
2. Add a REST endpoint to the device service for performing functions
60+
61+
api/v2/device-funtion/<device-name>/<function-name>
62+
63+
This shold accept POST requests with parameters sent in a JSON (or CBOR) payload
64+
65+
A successful invocation should return HTTP 200 with the out parameters in JSON
66+
or CBOR format.
67+
68+
Returnable errors should be
69+
BAD REQUEST: parameters were missing or wrong type
70+
INTERNAL SERVER ERROR: the DS implementation was unable to fulfill the request
71+
NOT FOUND: no such device, or no such function
72+
LOCKED: device or service is locked or down (adminstate, operating state)
73+
74+
3. Add a REST endpoint to core-command for performing functions

0 commit comments

Comments
 (0)