|
| 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