DocsReferenceAPI reference
Wi-Fi
Saved networks (up to 3), switching and forgetting; during Wi-Fi setup, the open /prov/* endpoints used by the setup page on the hotspot. When a phone joins the setup hotspot, the captive portal redirects (302) GETs with no route to the setup page (not an endpoint). Only a person enters Wi-Fi passwords, on the setup page or in Settings of the device web app; host tools and agents never handle them
GET /v1/wifi#
Saved networks (up to 3, most recent first, no passwords) and the current one
Lists names, last connection time and channel only; never returns passwords
Reply#
Saved networks
Saved networks and the current one
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
current | string | null | Yes | Network in use; null when offline | ||
max | integer | Yes | ≥ 1 | Maximum number of saved networks | |
networks | object[] | Yes | Saved networks, most recent first | ||
ssid | string | Yes | length 1–32; ≤ 32 bytes | Network name (SSID), 1–32 bytes, case-sensitive | |
last_ok | integer | null | Yes | ≥ 0 | Unix time (s) it last connected; null if the clock was not set then | |
channel | integer | null | Yes | 1–14 | Channel it last connected on; null if unknown |
Error codes#
For errors any endpoint can return, see Common errors.
POST /v1/wifi#
Set as candidate and switch to it in about 1.5 s; saved only once joined, otherwise returns to a saved network
Called by Settings in the device web app after a person enters the network; host tools and agents never handle Wi-Fi passwords and do not call it. The network is kept in memory as a candidate; about 1.5 s after replying the device leaves the current network to join it and is offline meanwhile. Only once it joins and gets an IP is it saved, first in the list (with 3 saved, the least recently used is dropped). A wrong password drops it; if it cannot connect, the device returns to a saved network
Request body#
application/json
Network to join
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ssid | string | Yes | length 1–32; ≤ 32 bytes | Network name (SSID), 1–32 bytes, case-sensitive | |
pass | string | pattern ^(.{8,})?$ | ≤ 64 bytes | Password: empty or omitted for open networks, otherwise 8–64 bytes |
Examples#
Add a network with a password#
The password is a placeholder; a person types it in the web app
{"ssid": "MyHome", "pass": "<wifi-password>"}Open network (no password)#
{"ssid": "Cafe-Guest"}Reply#
Candidate set; switching
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_wifi | ssid is not 1–32 bytes, the password is neither empty nor 8–64 bytes, or the body is not a JSON object. See the example “Add a network with a password” for the correct form |
For errors any endpoint can return, see Common errors.
POST /v1/wifi/forget#
Forget a network; without ssid, clear all and enter Wi-Fi setup (device goes offline until set up from a phone)
With ssid: forget that one (and a candidate of the same name); if in use it stays connected but will not come back after a disconnect. Without: clear all, disconnect and enter Wi-Fi setup; the device is offline until a person sets it up from a phone via the hotspot
Request body#
application/json · optional
The body is optional: with ssid, forget that one; without (empty body or {}), clear all and enter Wi-Fi setup
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ssid | string | length 1–32; ≤ 32 bytes | Network name (SSID), 1–32 bytes, case-sensitive |
Examples#
Forget one#
{"ssid": "OldHome"}Forget all and enter Wi-Fi setup#
The device goes offline at once
{}Reply#
Forgotten
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_args | ssid is not a 1–32 byte string, or the body is not a JSON object. See the example “Forget one” for the correct form |
404 | not_found | No saved network by that name (case-sensitive). Check names with GET /v1/wifi |
500 | nvs | Saving failed. Retry; if it persists, check stick logs |
For errors any endpoint can return, see Common errors.
GET /prov/status#
Setup page polling: candidate network result (Wi-Fi setup only)
The setup page polls about once a second after submitting, to see whether the candidate joined; also returns saved networks and the screen language
Reply#
Setup progress
The candidate's result comes first; without a candidate, state is up when connected
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
id | string | Yes | pattern ^stick-[0-9a-f]{6}$ | Device ID, also the hotspot name | |
state | string | Yes | idle connecting got_ap up failed | idle = not connecting, connecting, got_ap = joined the router and waiting for an IP, up = online, failed = the candidate did not connect (see reason) | |
ssid | string | null | Yes | Network being joined or in use; null if none | ||
reason | string | null | Yes | auth not_found timeout no_ip null | Why it failed: auth = wrong password (the candidate is dropped), not_found = network not found, timeout, no_ip = got no IP address; null in other states | |
ip | string | Device address on that network; only when up | |||
rssi | integer | ≤ 0 | Signal strength (dBm); only when up | ||
known | object[] | Yes | Saved networks, most recent first | ||
ssid | string | Yes | length 1–32; ≤ 32 bytes | Network name (SSID), 1–32 bytes, case-sensitive | |
last_ok | integer | null | Yes | ≥ 0 | Unix time (s) it last connected; null if the clock was not set then | |
channel | integer | null | Yes | 1–14 | Channel it last connected on; null if unknown | |
max | integer | Yes | ≥ 1 | Maximum number of saved networks | |
lang | string | zh en | Screen language of the device | ||
lang_chosen | boolean | Someone has chosen a language; if not, the setup page sets one from the phone's language |
Error codes#
| Status | Code | Description |
|---|---|---|
404 | not_found | Not in Wi-Fi setup (the hotspot is off) |
For errors any endpoint can return, see Common errors.
GET /prov/scan#
Nearby networks (Wi-Fi setup only)
Scans once on the spot and replies when done
Reply#
Nearby networks
Strongest first; each name listed once, hidden networks excluded, at most 20
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true | |
networks | object[] | Yes | ≤ 20 items | Nearby networks | |
ssid | string | Yes | length 1–32; ≤ 32 bytes | Network name (SSID), 1–32 bytes, case-sensitive | |
rssi | integer | Yes | ≤ 0 | Signal strength (dBm) | |
secure | boolean | Yes | Needs a password |
Error codes#
| Status | Code | Description |
|---|---|---|
503 | scan_busy | The device is joining a network and cannot scan. Retry later |
404 | not_found | Not in Wi-Fi setup (the hotspot is off) |
For errors any endpoint can return, see Common errors.
POST /prov/wifi#
Setup page submit (form ssid, pass; Wi-Fi setup only)
Same rules as POST /v1/wifi: kept as a candidate and joined about 1.5 s after replying (the hotspot follows the channel, so the phone may drop briefly), saved only once joined; then poll GET /prov/status for the result. A person types the password on the setup page
Request body#
application/x-www-form-urlencoded
Network to join
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ssid | string | Yes | length 1–32; ≤ 32 bytes | Network name (SSID), 1–32 bytes, case-sensitive | |
pass | string | pattern ^(.{8,})?$ | ≤ 64 bytes | Password: empty or omitted for open networks, otherwise 8–64 bytes |
Examples#
Submit a network#
The password is a placeholder
{"ssid": "MyHome", "pass": "<wifi-password>"}Reply#
Candidate set
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_wifi | ssid is missing or not 1–32 bytes, or the password is neither empty nor 8–64 bytes. See the example “Submit a network” for the correct form |
404 | not_found | Not in Wi-Fi setup (the hotspot is off) |
For errors any endpoint can return, see Common errors.
POST /prov/forget#
Setup page forgets a network (form ssid; Wi-Fi setup only)
Forgets a saved network (and a candidate of the same name); if in use it stays connected
Request body#
application/x-www-form-urlencoded
Network to forget
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ssid | string | Yes | length 1–32; ≤ 32 bytes | Network name (SSID), 1–32 bytes, case-sensitive |
Examples#
Forget one#
{"ssid": "OldHome"}Reply#
Forgotten
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_args | ssid is missing or empty. See the example “Forget one” for the correct form |
404 | not_found | Not in Wi-Fi setup, or no saved network by that name |
500 | nvs | Saving failed. Retry; if it persists, check stick logs |
For errors any endpoint can return, see Common errors.
POST /prov/lang#
Setup page sets the screen language (form lang=zh|en; Wi-Fi setup only)
Same as POST /v1/lang: saved on the device and the screen switches at once. When the setup page opens and nobody has chosen a language (lang_chosen is false), it sets one from the phone's language; the switch at the top right calls it too
Request body#
application/x-www-form-urlencoded
Screen language to set
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
lang | string | Yes | zh en | zh = Chinese, en = English |
Examples#
English#
{"lang": "en"}Reply#
Set
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
| Status | Code | Description |
|---|---|---|
400 | bad_lang | lang must be zh or en. See the example “English” for the correct form |
404 | not_found | Not in Wi-Fi setup (the hotspot is off) |
500 | nvs | Saving failed. Retry; if it persists, check stick logs |
For errors any endpoint can return, see Common errors.
POST /prov/leave#
Leave setup: drop the candidate, close the hotspot, return to a saved network (Wi-Fi setup only)
Drops the candidate. If online, closes the hotspot in about 1.5 s; if not, joins a saved network in about 1.5 s and closes the hotspot once connected (the phone drops). The body is ignored (the setup page sends an empty form)
Reply#
Leaving setup
Successful reply; endpoints add their own fields
| Field | Type | Required | Values | Range | Description |
|---|---|---|---|---|---|
ok | boolean | Yes | true | Always true |
Error codes#
| Status | Code | Description |
|---|---|---|
404 | not_found | Not in Wi-Fi setup (the hotspot is off) |
For errors any endpoint can return, see Common errors.