System Configuration - qtoggle/espqtoggle GitHub Wiki
About
There is a set of system parameters that is specific to each device type and that should be configured once, when the device is intially provisioned. This configuration includes parameters such as those related to setup button, status LED and battery.
Available Parameters
Setup Button
pin
: the pin where the setup button is connected (0..16, -1: setup button not available)level
: logic level of the pin when button is pressedhold
: number of seconds the button has to be held pressed to switch to (and from) setup modereset_hold
: number of seconds the button has to be held pressed for a factory reset
Status LED
pin
: the pin where the status LED is connected (0..16, -1: status LED not available)level
: logic level of the pin when LED is lit
Battery
div
: voltage divider factor x 1000 (0: battery not available)voltages
: a list of 6 voltage points (in mV) representing 0%, 20%, 40%, 60%, 80% and 100% battery state-of-charge
API Endpoint
The /system
endpoint is exposed by devices running espQToggle; keep in mind though that it is not a standard qToggle API endpoint.
GET /system
Returns the system configuration.
Response has the following body:
{
"setup_button": {
"pin": number,
"level": boolean,
"hold": number,
"reset_hold": number
},
"status_led": {
"pin": number,
"level": boolean
},
"battery": {
"div": number,
"voltages": number[]
}
}
Example:
Consumer's request:
GET /system HTTP/1.1
Host: device.example.com
Connection: close
Cache-Control: no-cache
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c3IiOiJhZG1pbiIsImlhdCI6MTUxNjIzOTAyMn0.l2uO5g3viMWLQu2s7KJ0zZI5Cn-Cpk5i7am9vv2JcJ0
Device's response:
HTTP/1.1 200 OK
Connection: close
Cache-Control: no-cache
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c3IiOiJhZG1pbiIsImlhdCI6MTUxNjIzOTAyM30.If1_Cu-WRZ3qzICahiA5flU7o4lR1RGMhF9HYeBHpKM
Content-Type: application/json; charset=utf-8
Content-Length: n
{
"setup_button": {
"pin": 13,
"level": false,
"hold": 5,
"reset_hold": 20
},
"status_led": {
"pin": 2,
"level": true
},
"battery": {
"div": 166,
"voltages": number[3300, 3600, 3700, 3750, 3950, 4200]
}
}
PUT /system
Updates the system configuration of a device.
This API function requires admin
access level.
Request has the same body format and meaning as GET /system
.
Response has no body.