Skip to content

Commit 8f0ee4b

Browse files
committed
feat: Device functions ADR
Align with north-south messaging ADR (#23) Signed-off-by: Iain Anderson <[email protected]>
1 parent 0d6d03b commit 8f0ee4b

File tree

1 file changed

+47
-19
lines changed

1 file changed

+47
-19
lines changed

docs_src/design/adr/device-service/0021-invoking-functions.md

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ this is unintuitive.
3939
{
4040
"name": "Parameter name",
4141
"description": "(optional) description of what the parameter controls",
42-
"type": "Any of the usual EdgeX data types",
42+
"type": "Any of the existing EdgeX data types",
4343
"defaultValue": "(optional) value to use if param is not supplied",
4444
"maximum": "(optional) for numerics, maximum allowed value",
4545
"minimum": "(optional) for numerics, minimum allowed value"
@@ -50,49 +50,65 @@ this is unintuitive.
5050
{
5151
"name": "Name of returned value",
5252
"description": "(optional) description of what the value indicates",
53-
"type": "Any of the usual EdgeX data types"
53+
"type": "Any of the existing EdgeX data types"
5454
}
5555
]
5656
}
5757
]
5858
}
5959
```
6060

61-
Note: the `attributes` structure is analagous to `attributes` in a `deviceResource`. Each device service should document and implement a scheme of required attributes that will allow for selection of the relevant funtion.
61+
Note: the `attributes` structure is analagous to `attributes` in a `deviceResource`. Each device service should document and implement a scheme of required attributes that will allow for selection of the relevant function.
6262

6363
**Define MessageBus topics on which function call requests and replies are to be made**
6464

65-
`edgex/function-calls/device/[profile-name]/[device-name]/[function-name]`
65+
These follow the style of messagebus usage set out in the North-South messaging ADR.
66+
67+
`edgex/request/function/[device-service-name]/[device-name]`
6668

6769
The payload for messages on these topics should be of the form
6870
```
6971
{
70-
requestId: "184b894f-a7b7-4d6c-b400-99961d462419",
71-
parameters: { (a map of parameter values keyed by parameter name) }
72+
"correlation-id": "1dbbd344-c9f6-4714-8c89-91c1d5b11a90",
73+
"deviceName": "device1",
74+
"function": "functionname",
75+
"request":
76+
{
77+
"requestId": "184b894f-a7b7-4d6c-b400-99961d462419",
78+
"parameter1": "37",
79+
"parameter2": "0"
80+
}
7281
}
73-
```
7482
75-
The `requestId` may be any string but UUIDs are recommended.
83+
```
7684

77-
`edgex/function-responses/device/[profile-name]/[device-name]/[function-name]`
85+
`edgex/response/function/[device-service-name]/[device-name]`
7886

7987
The device service will provide responses to function calls on this topic. The payload will be
8088

8189
```
8290
{
83-
requestId: "184b894f-a7b7-4d6c-b400-99961d462419",
84-
status: 0,
85-
returnValues: { (a map of return values keyed by value name) }
91+
"correlation-id": "1dbbd344-c9f6-4714-8c89-91c1d5b11a90",
92+
"response":
93+
{
94+
"requestId": "184b894f-a7b7-4d6c-b400-99961d462419",
95+
"statusCode": 0,
96+
"returnVal1": "true"
97+
}
8698
}
8799
```
88100

89101
or if a call fails
90102

91103
```
92104
{
93-
requestId: "184b894f-a7b7-4d6c-b400-99961d462419",
94-
status: (nonzero),
95-
errorMessage "Message indicating the nature of the failure"
105+
"correlation-id": "1dbbd344-c9f6-4714-8c89-91c1d5b11a90",
106+
"response":
107+
{
108+
"requestId": "184b894f-a7b7-4d6c-b400-99961d462419",
109+
"statusCode": (nonzero),
110+
"message": "Message indicating the nature of the failure"
111+
}
96112
}
97113
```
98114

@@ -101,12 +117,24 @@ or if a call fails
101117
| Status | Meaning
102118
|--------|--------
103119
| 0 | The operation was successful
104-
| 1 | Parameters were missing, out of range or non-parsable
105-
| 2 | The Device is DOWN or DISABLED (OperatingState / AdminState)
106-
| 3 | No such device or function
120+
| 1 | Request message format error
121+
| 2 | Parameters were missing, out of range or non-parsable
122+
| 3 | The Device is DOWN or DISABLED (OperatingState / AdminState)
123+
| 4 | No such device or function
107124
| 100+ | Implementation-specific errors, defined for each Device Service
108125

109-
** Device SDK enhancement **
126+
*Configuration*
127+
128+
The topic prefixes `edgex/request/function` and `edgex/response/function` will be configurable in the device services.
129+
130+
**Device SDK enhancement**
110131

111132
The device SDKs will handle the messagebus communcations and parameter marshalling. The generic errors defined above may be detected in this SDK code. The SDKs will define APIs for the individual device services to implement the function invocations.
112133

134+
**Command service enhancement**
135+
136+
The core-command service to be extended to provide access to device functions as it does for device readings and settings.
137+
138+
## References
139+
140+
* [ADR 0023-North-South-Messaging](https://github.com/edgexfoundry/edgex-docs/blob/master/docs_src/design/adr/0023-North-South-Messaging.md)

0 commit comments

Comments
 (0)