/
openapi.yaml
317 lines (316 loc) · 8.88 KB
/
openapi.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
openapi: 3.0.3
info:
title: M-Bus HTTPD API
version: 0.3.5
servers:
- url: /
paths:
/mbus/api:
get:
description: Returns this API specification
operationId: mbus_api
responses:
"200":
content:
text/x-yaml:
schema:
$ref: '#/components/schemas/yaml'
description: OK
"404":
content:
text/plain:
example: File not found
schema:
$ref: '#/components/schemas/textError'
description: Not found
/mbus/hat:
get:
description: Gets Raspberry Pi Hat information
operationId: hat
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/hat'
description: OK
"404":
content:
text/plain:
example: Hat information not found
schema:
$ref: '#/components/schemas/textError'
description: Not found
/mbus/hat/on:
post:
description: Turns on power to the M-Bus
operationId: hatOn
responses:
"200":
description: OK
"404":
content:
text/plain:
example: M-Bus Master Hat not installed
schema:
$ref: '#/components/schemas/textError'
description: Not found
/mbus/hat/off:
post:
description: Turns off power to the M-Bus
operationId: hatOff
responses:
"200":
description: OK
"404":
content:
text/plain:
example: M-Bus Master Hat not installed
schema:
$ref: '#/components/schemas/textError'
description: Not found
/mbus/scan/{device}/{baudrate}:
post:
description: Scan the specified device for slaves
operationId: scan
parameters:
- description: The serial device to scan - /dev/ is pre-pended to {device} by
M-Bus HTTPD before scanning
example: ttyAMA0
explode: false
in: path
name: device
required: true
schema:
$ref: '#/components/schemas/device'
style: simple
- description: Baudrate to communicate with M-Bus devices
example: 2400
explode: false
in: path
name: baudrate
required: true
schema:
$ref: '#/components/schemas/baudrate'
style: simple
responses:
"200":
content:
text/plain:
example: Found a M-Bus device at address 1
schema:
$ref: '#/components/schemas/slaves'
description: OK
"400":
content:
text/plain:
example: Baudrate {baudrate} is invalid
schema:
$ref: '#/components/schemas/textError'
description: Bad request
"404":
content:
text/plain:
example: Device /dev/{device} does not exist
schema:
$ref: '#/components/schemas/textError'
description: Not found (e.g. device not found, or M-Bus HTTPD is unauthorized
to access it, or to change baud rate to that specified, device not responding
etc)
/mbus/get/{device}/{baudrate}/{address}:
post:
description: Gets data from the slave identified by {address}
operationId: get
parameters:
- description: The serial device to scan - /dev/ is pre-pended to {device} by
M-Bus HTTPD before scanning
example: ttyAMA0
explode: false
in: path
name: device
required: true
schema:
$ref: '#/components/schemas/device'
style: simple
- description: Baudrate to communicate with M-Bus devices
example: 2400
explode: false
in: path
name: baudrate
required: true
schema:
$ref: '#/components/schemas/baudrate'
style: simple
- description: The slave device to get data from
example: 48
explode: false
in: path
name: address
required: true
schema:
$ref: '#/components/schemas/address'
style: simple
responses:
"200":
content:
application/xml:
schema:
$ref: '#/components/schemas/mbusData'
description: OK
"400":
content:
text/plain:
example: Baudrate {baudrate} is invalid
schema:
$ref: '#/components/schemas/textError'
description: Bad request
"404":
content:
text/plain:
example: Slave {address} not responding
schema:
$ref: '#/components/schemas/textError'
description: Not found (or M-Bus HTTPD is unauthorized to access it, or
to change baud rate to that specified, etc)
/mbus/getMulti/{device}/{baudrate}/{address}/{maxframes}:
post:
description: Gets data from the slave identified by {address}, and supports
multiple responses from the slave
operationId: getMulti
parameters:
- description: The serial device to scan - /dev/ is pre-pended to {device} by
M-Bus HTTPD before scanning
example: ttyAMA0
explode: false
in: path
name: device
required: true
schema:
$ref: '#/components/schemas/device'
style: simple
- description: Baudrate to communicate with M-Bus devices
example: 2400
explode: false
in: path
name: baudrate
required: true
schema:
$ref: '#/components/schemas/baudrate'
style: simple
- description: The slave device to get data from
example: 48
explode: false
in: path
name: address
required: true
schema:
$ref: '#/components/schemas/address'
style: simple
- description: The slave device to get data from
example: 16
explode: false
in: path
name: maxframes
required: true
schema:
$ref: '#/components/schemas/maxframes'
style: simple
responses:
"200":
content:
application/xml:
schema:
$ref: '#/components/schemas/mbusData'
description: OK
"400":
content:
text/plain:
example: Baudrate {baudrate} is invalid
schema:
$ref: '#/components/schemas/textError'
description: Bad request
"404":
content:
text/plain:
example: Slave {address} not responding
schema:
$ref: '#/components/schemas/textError'
description: Not found (or M-Bus HTTPD is unauthorized to access it, or
to change baud rate to that specified, etc)
components:
schemas:
yaml:
description: A YAML file
example: A YAML file
type: string
textError:
description: Some error text
example: Device /dev/{device} does not exist
type: string
device:
description: The device the M-Bus is connected to - /dev/ is prepended to {device}
by M-Bus HTTPD
example: ttyAMA0
type: string
baudrate:
description: Baudrate to use for the communication - valid values 300, 600,
1200, 2400, 4800, 9600
enum:
- 300
- 600
- 1200
- 2400
- 4800
- 9600
example: 2400
format: int32
type: integer
slaves:
description: Output of libmbus scan command
example: Found a M-Bus device at address 1
type: string
mbusData:
description: M-Bus device data as an XML document
example: <?xml version="1.0" encoding="UTF-8"?>...
type: string
address:
description: Slave address (primary or secondary)
example: "48"
format: string
maxLength: 16
minLength: 1
type: string
maxframes:
description: Max frames to listen for
example: 16
format: int32
maximum: 250
minimum: 1
type: integer
hat:
description: Raspberry Pi Hat Information
example:
index: 1
addr: 30
enabled: true
properties:
product:
description: Product
example: M-Bus Master
type: string
productId:
description: Product ID
example: 0x0001
type: string
productVer:
description: Product Version
example: 0x0002
type: string
uuid:
description: Hat UUID
example: 148fa981-a33b-a07a-a13f-a2405d08e0fe
type: string
vendor:
description: Hat Vendor
example: packom.net
type: string