-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi.yml
184 lines (182 loc) · 5.78 KB
/
openapi.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
openapi: 3.0.3
info:
title: pico-hydroponics
description: |-
When the raspberry pico is turned on for the first time it shouldn't have any configs and it'll start as an AP mode. This OpenAPI specs should demonstrate which requests are available for this service.
termsOfService: http://swagger.io/terms/
contact:
email: [email protected]
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 0.0.1
servers:
- url: http://192.168.4.1/
tags:
- name: calibration
description: Calibrate pH and TDS sensors
- name: general
description: Other operations available
paths:
/calibrate/tds:
post:
tags:
- calibration
summary: Calibrate TDS sensor
description: This request makes the raspberry pico read the value from the TDS probe and based on provided buffer value will calculate the coefficient used for reading the correct value from the nutrient or liquid.
operationId: calibrate-tds
parameters:
- name: buffer
in: query
description: The buffer solution value
schema:
type: number
default: 1413
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/TDSCalibrationResponse'
'500':
description: Calibration failed
content:
application/json:
schema:
$ref: '#/components/schemas/TDSCalibrationError'
/calibrate/ph:
get:
tags:
- calibration
summary: Makes pH sensor read the probe value
description: This request makes the raspberry pico read the value from the pH probe and based on provided buffer value will calculate the linear regression m and b values. The linear regression equation will be applied every time when we're collecting the pH metrics. If you input an wrong buffer value please consider turning on and off the raspberry for resetting those buffer values.
operationId: read-pH
parameters:
- name: buffer
in: query
description: The buffer solution value
schema:
type: number
default: 7.0
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/GetPHSuccess'
post:
tags:
- calibration
summary: Generate linear regression constant values based on previous reads
description: This request makes the raspberry pico retrieve the previous buffers and voltages reads collected by the pH probe and calculate the constant values used on when converting the pH voltage to the pH value
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/PostPHSuccess'
/credentials:
post:
tags:
- general
summary: Store credentials
description: This requests store on raspberry pico memory flash some variables that will be used for sending metrics through the internet. Please don't share your raspberry pico with anyone.
requestBody:
$ref: '#/components/requestBodies/Credentials'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/PostCredentialsSuccess'
/shutdown:
post:
tags:
- general
summary: Shutdown AP mode and reset raspberry pico
description: This request makes the raspberry pico turn off the AP mode/HTTP server and reboot. If you've setup everything and calibrated, you can press the small button on the board for initializing the AP mode again.
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/ShutdownResponse'
components:
schemas:
TDSCalibrationResponse:
type: object
properties:
k:
type: number
format: float32
example: 0.4546772
TDSCalibrationError:
type: object
properties:
status:
type: string
example: "failed to calibrate TDS"
GetPHSuccess:
type: object
properties:
ph_voltage:
type: number
format: float32
example: 2554
buffer:
type: number
format: float32
example: 7.0
status:
type: string
example: 'ok'
PostPHSuccess:
type: object
properties:
m:
type: number
format: float32
example: -4.852947599489467
b:
type: number
format: float32
example: 23.73194905699139
PostCredentialsSuccess:
type: object
properties:
status:
type: string
example: 'success'
Credentials:
type: object
properties:
ssid:
type: string
example: 'your_wifi_name'
password:
type: string
example: 'your_wifi_password'
api_key:
type: string
example: 'service api key'
user_id:
type: string
example: 'your_user_id'
ShutdownResponse:
type: object
properties:
status:
type: string
example: 'service shutting down'
requestBodies:
Credentials:
description: Credentials used for sending collected metrics to the service
content:
application/json:
schema:
$ref: '#/components/schemas/Credentials'