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

Signature required

Lists names, last connection time and channel only; never returns passwords

Reply#

Saved networks

Saved networks and the current one

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true
currentstring | nullYesNetwork in use; null when offline
maxintegerYes≥ 1Maximum number of saved networks
networksobject[]YesSaved networks, most recent first
ssidstringYeslength 1–32; ≤ 32 bytesNetwork name (SSID), 1–32 bytes, case-sensitive
last_okinteger | nullYes≥ 0Unix time (s) it last connected; null if the clock was not set then
channelinteger | nullYes1–14Channel 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

Signature required May go offline

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

FieldTypeRequiredValuesRangeDescription
ssidstringYeslength 1–32; ≤ 32 bytesNetwork name (SSID), 1–32 bytes, case-sensitive
passstringpattern ^(.{8,})?$≤ 64 bytesPassword: 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

JSON
{"ssid": "MyHome", "pass": "<wifi-password>"}

Open network (no password)#

JSON
{"ssid": "Cafe-Guest"}

Reply#

Candidate set; switching

Successful reply; endpoints add their own fields

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true

Error codes#

StatusCodeDescription
400bad_wifissid 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)

Signature required May go offline

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

FieldTypeRequiredValuesRangeDescription
ssidstringlength 1–32; ≤ 32 bytesNetwork name (SSID), 1–32 bytes, case-sensitive

Examples#

Forget one#

JSON
{"ssid": "OldHome"}

Forget all and enter Wi-Fi setup#

The device goes offline at once

JSON
{}

Reply#

Forgotten

Successful reply; endpoints add their own fields

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true

Error codes#

StatusCodeDescription
400bad_argsssid is not a 1–32 byte string, or the body is not a JSON object. See the example “Forget one” for the correct form
404not_foundNo saved network by that name (case-sensitive). Check names with GET /v1/wifi
500nvsSaving 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)

Open 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

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true
idstringYespattern ^stick-[0-9a-f]{6}$Device ID, also the hotspot name
statestringYesidle connecting got_ap up failedidle = not connecting, connecting, got_ap = joined the router and waiting for an IP, up = online, failed = the candidate did not connect (see reason)
ssidstring | nullYesNetwork being joined or in use; null if none
reasonstring | nullYesauth not_found timeout no_ip nullWhy 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
ipstringDevice address on that network; only when up
rssiinteger≤ 0Signal strength (dBm); only when up
knownobject[]YesSaved networks, most recent first
ssidstringYeslength 1–32; ≤ 32 bytesNetwork name (SSID), 1–32 bytes, case-sensitive
last_okinteger | nullYes≥ 0Unix time (s) it last connected; null if the clock was not set then
channelinteger | nullYes1–14Channel it last connected on; null if unknown
maxintegerYes≥ 1Maximum number of saved networks
langstringzh enScreen language of the device
lang_chosenbooleanSomeone has chosen a language; if not, the setup page sets one from the phone's language

Error codes#

StatusCodeDescription
404not_foundNot 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)

Open 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

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true
networksobject[]Yes≤ 20 itemsNearby networks
ssidstringYeslength 1–32; ≤ 32 bytesNetwork name (SSID), 1–32 bytes, case-sensitive
rssiintegerYes≤ 0Signal strength (dBm)
securebooleanYesNeeds a password

Error codes#

StatusCodeDescription
503scan_busyThe device is joining a network and cannot scan. Retry later
404not_foundNot 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)

Open 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

FieldTypeRequiredValuesRangeDescription
ssidstringYeslength 1–32; ≤ 32 bytesNetwork name (SSID), 1–32 bytes, case-sensitive
passstringpattern ^(.{8,})?$≤ 64 bytesPassword: empty or omitted for open networks, otherwise 8–64 bytes

Examples#

Submit a network#

The password is a placeholder

JSON
{"ssid": "MyHome", "pass": "<wifi-password>"}

Reply#

Candidate set

Successful reply; endpoints add their own fields

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true

Error codes#

StatusCodeDescription
400bad_wifissid 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
404not_foundNot 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)

Open 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

FieldTypeRequiredValuesRangeDescription
ssidstringYeslength 1–32; ≤ 32 bytesNetwork name (SSID), 1–32 bytes, case-sensitive

Examples#

Forget one#

JSON
{"ssid": "OldHome"}

Reply#

Forgotten

Successful reply; endpoints add their own fields

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true

Error codes#

StatusCodeDescription
400bad_argsssid is missing or empty. See the example “Forget one” for the correct form
404not_foundNot in Wi-Fi setup, or no saved network by that name
500nvsSaving 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)

Open 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

FieldTypeRequiredValuesRangeDescription
langstringYeszh enzh = Chinese, en = English

Examples#

English#

JSON
{"lang": "en"}

Reply#

Set

Successful reply; endpoints add their own fields

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true

Error codes#

StatusCodeDescription
400bad_langlang must be zh or en. See the example “English” for the correct form
404not_foundNot in Wi-Fi setup (the hotspot is off)
500nvsSaving 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)

Open 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

FieldTypeRequiredValuesRangeDescription
okbooleanYestrueAlways true

Error codes#

StatusCodeDescription
404not_foundNot in Wi-Fi setup (the hotspot is off)

For errors any endpoint can return, see Common errors.

View the source of this page on GitHub