-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-api-radio.yml
360 lines (318 loc) · 10.6 KB
/
example-api-radio.yml
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
%YAML 1.2
---
afbidl: "0.1"
info:
apiname: radio
title: Service for radio reception
description:
"Radio service manages and reports radio configuration changes
(eg. frequency, band, ....) and allows requesting infos (RDS,...)"
version: "0.1"
author: AGL
maintainer: Matt Ranostay (Konsulko)
homepage: https://gerrit.automotivelinux.org/gerrit/apps/agl-service-radio
tools:
afb-genskel:
scope: static
prefix: req_
postfix: _cb
init: init
doc:
id: radio-api
keywords: radio
author:
version:
src_prefix: api-radio
chapters:
- name: Abstract
url: abstract.md
- name: User Guide
url: userguide.md
verbs:
frequency:
description: "Set/Get frequency (NB: we can't just get the value on request)"
request: $/schemas/frequency/get
reply:
success:
schema: $/schemas/frequency/get
_: Fails if frequency value is NaN (but no check on the value, nor on set_frequency() return value...)
band:
description: "Set/Get band (NB : same as frequency, no standalone get)"
request: $/schemas/band/set
reply:
success:
schema: $/schemas/band/get
_: Fails if the band/modulation is invalid
rds:
description: "Get Radio Data System information"
request: $/schemas/none
reply:
success:
schema: $/schemas/rds/reply
_: Fails if not supported by the radio backend
band_supported:
description: "Check band support (NB : no way to get list all supported bands)"
request: $/schemas/band/get
reply:
success:
schema: $/schemas/band/supported_bands
_: Fails if the band/modulation is invalid
frequency_range:
description: "Get frequency range (for a given band/modulation)"
request: $/schemas/band/get
reply:
success:
schema: $/schemas/frequency/range
_: Fails if band/modulation is unknown.
frequency_step:
description: "Get frequency step"
request: $/schemas/band/get
reply:
success:
schema: $/schemas/frequency/step
start:
description: "Start radio playback"
request: $/schemas/none
reply:
success:
schema: $/schemas/playing/status
description: "playing status must be \"playing\""
stop:
description: "Stop radio playback"
request: $/schemas/none
reply:
success:
schema: $/schemas/playing/status
description: "playing status must be \"stopped\""
scan_start:
description: "Start station scan (in a given direction)"
request: $/schemas/start_scan
reply:
success:
when-state:
scanning: idle
triggers: scan-start
schema: $/schemas/none
_: Fails if direction is invalid
stop_scan:
description: "Stop station scan"
request: $/schemas/none
reply:
success:
triggers: scan-stop
schema: $/schemas/none
stereo_mode:
description: "Set/Get stereo_mode (NB: we can't just get the value on request)"
request: $/schemas/stereo_mode
reply:
success:
schema: $/schemas/stereo_mode
_: Fails if passed an invalid stereo mode
subscribe:
description: "Request subscription to an event"
request: $/schemas/subscription
reply:
success:
schema: $/schemas/none
triggers: start-signaling
unsubscribe:
description: "Cancel subscription to an event"
request: $/schemas/subscription
reply:
success:
schema: $/schemas/none
triggers: stop-signaling
state-machines:
scanning:
description: "Indicates if the backend is currently scanning frequency"
scope: global
states: [ idle, progress ]
initial: idle
transitions:
scan-start-transition:
from: idle
to: progress
trigged-by: start-scan
scan-stop-transition:
from: idle
to: progress
trigged-by: stop-scan
# Just for the record: the following compact syntax is
# equivalent to the developped syntax above
#- [ idle, progress, scan-start ]
#- [ progress, idle, scan-complete ]
signaling:
description: "Emits events to listeners"
scope: session
states:
- "on"
- "off"
initial: "off"
transitions:
- ["on", "off", start-signaling ]
- ["off", "on", stop-signaling ]
events:
frequency:
description: "event emitted when a new frequency is tuned (TBC)"
schema: $/schemas/frequency/event
when-state:
signaling: "on"
station_found:
description: "event emitted when a valid station is tuned (frequency with a good S/N ration ? TBC)"
schema: $/schemas/frequency/event
when-state:
signaling: "on"
scanning: progress
status:
description: "event emitted when playing status changes."
schema: $/schemas/playing/status
when-state:
signaling: "on"
# Follow JsonSchema specification (https://json-schema.org/)
schemas:
types:
band:
title: Frequency band (modulation)
description: "Enumeration of valid frquency bands/modulations values as string"
type: string
enum: ["AM", "FM"]
stereo_mode:
title: Stereo mode
description: "Enumeration of valid stereo modes"
type: string
enum: ["mono", "stereo"]
frequency:
# we could unify get, set and event if they all had the same property (for instance : value)
# also description would be much simpler : "object used to pass a frequency value"
set:
title:
description: "object used to set the tuned frequency"
type: object
properties:
value:
title: frequency value
description: "desired frequency to be tuned"
type: number
required: [ value ]
get:
title:
description: "object used to retrieve tuned frequency"
type: object
properties:
frequency:
title: frequency value
description: "frequency currently tuned"
type: number
required: [ frequency ]
range:
title:
description: "object used to retreive minimum and maximum frequency for a given modulation"
type: object
properties:
min:
title: Minimal frequency for the range
type: number
max:
title: Maximal frequency for the range
type: number
required: [ min, max ]
step:
title:
description: "object used to retrieve the increment between 2 tunable frequencies"
type: object
properties:
step:
title: frequency step
type: number
required: [ step ]
event:
title:
description:
type: object
properties:
value:
title: frequency value
type: number
required: [ value ]
band:
# same here, we could unify set and get.
# not done yet to stay coherent with frequency schemas
set:
title:
description:
type: object
properties:
value: $/schemas/types/band
required: [ value ]
get:
title:
type: object
properties:
value: $/schemas/types/band
required: [ value ]
supported_bands:
title:
description: "list of bands/modulations supported by the radio backend"
type: array
contains: $/schemas/types/band
rds:
reply:
success:
title:
description: "object used to retrieve Radio Data System information"
type: object
properties:
rds:
title: '"playing now" information'
type: string
required: [ rds ]
playing:
status:
title:
description: "Object used to return the playing status"
type: object
properties:
value: { enum: ["playing", "stopped" ] }
required: [ value ]
start_scan:
request:
title:
description: "object used to pass the direction of the frequency scan"
type: object
properties:
direction: { enum: ["forward, backward" ] }
required: [ direction ]
stereo_mode:
title:
description: "Object used to pass a stereo mode (NB : stereo is either true or false. Polyphony is more general, does it make sense here ?)"
type: object
properties:
value: $/schemas/types/stereo_mode
required: [ value ]
subscription:
title:
description: "describes a subscription to an event"
type: object
properties:
value: { enum: ["frequency", "station_found", "status" ] }
required: [ value ]
none:
title: no value, just null
description:
const: null
scenarios:
- from:
scanning: idle
signaling: "off"
sequence:
- { request: stop_scan, value: null }
- { reply: success, value: null }
- { request: subscribe, value: { value: station_found } }
- { reply: success, value: null }
- { request: start_scan, value: null }
- { reply: success, value: null }
- { event: station_found, value: { value: 89.4 } }
- { request: unsubscribe, value: { value: station_found } }
- { reply: success, value: null }
- { request: stop_scan, value: null }
- { reply: success, value: null }