-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswagger.yml
More file actions
471 lines (458 loc) · 13.9 KB
/
swagger.yml
File metadata and controls
471 lines (458 loc) · 13.9 KB
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
openapi: 3.0.0
info:
title: Xiaomi Light bar for ESP API
version: 1.1.0
description: REST API for interacting with the Xiaomi Light bar for ESP system.
servers:
- url: "http://{host}/"
description: "API Server for version 1"
variables:
host:
default: "localhost"
tags:
- name: V1
description: All endpoints related to Xiaomi Light bar for ESP system interaction.
paths:
/api/v1/status:
get:
tags:
- V1
summary: Get system status
description: Returns system uptime, free heap memory, and IP address.
responses:
"200":
description: System status information
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: "ok"
ip:
type: string
example: "192.168.1.123"
sys_timestamp:
type: integer
example: "1242013890"
free_heap:
type: string
example: "190.23 KB"
uptime:
type: string
example: "0d 02h 25m 10s"
/api/v1/wifi/connect:
post:
tags:
- V1
summary: Connect to Wi-Fi
description: Attempts to connect to the given Wi-Fi SSID using the provided credentials.
security:
- ApiKeyAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- ssid
- password
properties:
ssid:
type: string
example: "MyNetwork"
password:
type: string
example: "mypassword123"
responses:
"200":
description: Successfully connected
"400":
description: Invalid request or missing fields
"401":
description: Unauthorized (missing or invalid X-API-Key)
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Unauthorized"
/api/v1/wifi/scan:
get:
tags:
- V1
summary: Scan Wi-Fi networks
description: Performs a scan of available Wi-Fi networks nearby.
security:
- ApiKeyAuth: []
responses:
"200":
description: List of available networks
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: true
networks:
type: array
items:
type: object
properties:
ssid:
type: string
example: "MyNetwork"
rssi:
type: integer
example: -55
authmode:
type: string
example: "WPA2_PSK"
/api/v1/ntp/set:
post:
tags:
- V1
summary: Set NTP server for time sync
description: Sync time with the given NTP server
security:
- ApiKeyAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- ntp_domain
properties:
ntp_domain:
type: string
example: "pool.ntp.org"
responses:
"200":
description: Time successfully synchronized with the NTP server.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: true
message:
type: string
example: "NTPS sync ok"
"400":
description: Bad request (Invalid JSON or missing `ntp_domain`).
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Missing or invalid NTP domain"
"401":
description: Unauthorized (missing or invalid X-API-Key)
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Unauthorized"
"500":
description: Failed to sync with the NTP server.
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Failed to sync time with NTP"
/api/v1/logs:
get:
tags:
- V1
summary: Get ESP32 logs
description: Returns the captured logs from the ESP32 as an array of log lines (same as idf.py monitor output).
security:
- ApiKeyAuth: []
responses:
"200":
description: Successfully retrieved logs
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: true
log_lines:
type: array
items:
type: string
example:
- "I (12345) MAIN: Starting application..."
- "I (12346) HTTP_SERVER: Webserver starting on port: 80"
- "I (12347) WIFI: Initializing WiFi..."
total_lines:
type: integer
example: 3
"401":
description: Unauthorized (missing or invalid X-API-Key)
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Unauthorized"
/api/v1/logs/clear:
delete:
tags:
- V1
summary: Clear ESP32 logs
description: Clears the log buffer, removing all captured logs.
security:
- ApiKeyAuth: []
responses:
"200":
description: Logs successfully cleared
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: true
message:
type: string
example: "Logs cleared"
"401":
description: Unauthorized (missing or invalid X-API-Key)
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Unauthorized"
/api/v1/nrf24/scan:
get:
tags:
- V1
summary: Scan for Xiaomi remote control
description: Performs a scan to detect and decode the Xiaomi remote control ID from NRF24 radio packets. The scan listens on multiple 2.4 GHz channels and classifies received commands (on/off, cooler, warmer, higher, lower, reset).
security:
- ApiKeyAuth: []
parameters:
- name: duration
in: query
description: Duration of the scan in seconds (1-60). Default is 10 seconds.
schema:
type: integer
minimum: 1
maximum: 60
default: 10
example: 10
responses:
"200":
description: Scan completed successfully
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
description: Whether the scan detected a remote control ID
example: true
xiaomi_remote_id:
type: string
description: The detected remote control ID in hexadecimal format (null if not detected)
example: "0x700000"
xiaomi_id_saved:
type: boolean
description: Indicates if the detected ID was successfully persisted to NVS
example: true
"401":
description: Unauthorized (missing or invalid X-API-Key)
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Unauthorized"
/api/v1/xiaomi/set-id:
post:
tags:
- V1
summary: Manually set the Xiaomi remote ID
description: Persists a provided Xiaomi remote ID into NVS storage.
security:
- ApiKeyAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- xiaomi_remote_id
properties:
xiaomi_remote_id:
type: string
description: Xiaomi remote control ID in hexadecimal format
example: "0x700000"
responses:
"200":
description: Xiaomi ID saved successfully
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: true
message:
type: string
example: "Xiaomi ID saved successfully"
xiaomi_id:
type: string
example: "0x700000"
"401":
description: Unauthorized (missing or invalid X-API-Key)
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Unauthorized"
/api/v1/xiaomi/get-id:
get:
tags:
- V1
summary: Retrieve the stored Xiaomi remote ID
description: Reads the Xiaomi remote ID persisted in NVS storage and returns it if present.
security:
- ApiKeyAuth: []
responses:
"200":
description: Xiaomi ID read result
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
description: Return the NVS stored remote ID
example: true
xiaomi_id:
type: string
nullable: true
description: Stored Xiaomi remote ID, or null if not set
example: "0x700000"
"401":
description: Unauthorized (missing or invalid X-API-Key)
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Unauthorized"
/api/v1/xiaomi/power/toogle:
post:
tags:
- V1
summary: Toggle Xiaomi light bar power
description: Sends a power toggle command to the Xiaomi light bar using the stored remote ID.
security:
- ApiKeyAuth: []
responses:
"200":
description: Command sent
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: true
xiaomi_remote_id:
type: string
example: "0x700000"
command:
type: string
example: "power_toggle"
status:
type: string
example: "ESP_OK"
"401":
description: Unauthorized (missing or invalid X-API-Key)
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
example: false
message:
type: string
example: "Unauthorized"
components:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-Key
description: API key required for protected endpoints.