CHIRP-PROV v1.8

Provisioning over USB

Let the setup page send network settings and device credentials to your firmware over a USB serial connection.

This is optional. Your firmware can use its own setup method and still send data to Warblet. Implement CHIRP-PROV when you want to use the browser setup page.

The exchange

Use UTF-8 lines ending in \n on the primary UART or USB-CDC console, normally at 115200 baud, 8N1. Accept \r\n too. Ordinary log lines can share the port. Keep answering probes while connecting to the network.

portal → device   CHIRP?
device → portal   CHIRP! v=1 hw=sensor-01 fw=v1.6.0 key_set=0 radios=wifi caps={"v":1,"auth":[1,2],"keyProvisioning":["usb"],"otaKeyRotation":false,"otaFirmwareUpdate":false,"transports":["https"]}
portal → device   CHIRP+ {"ssid":"workshop","pass":"example-password","claim":"CHIRP-EXAMPLE","hwid":"sensor-01"}
device → portal   CHIRP= ok

The page asks CHIRP?, checks the reply, then sends one JSON object after CHIRP+ . Reply within five seconds. Opening a serial port can restart some boards; handle this without losing saved settings.

Describe what your firmware supports

Send tokens in this order: v, hw, fw, key_set, radios, t, caps. The whole line must fit in 512 bytes. Omit hw when no ID is known and t when this is not a published demo. caps is always last.

  • v=1 identifies the Wi-Fi wire format; use v=2 for Thread support. This is separate from the protocol document version.
  • fw is your build identifier: 1–64 letters, digits, dots, underscores or hyphens, starting with a letter or digit. Published demos use their catalog’s firmware.fw.
  • key_set=1 means a valid signing key is stored; otherwise send 0. This does not prove that Warblet accepted a signed message.
  • radios lists the networks the device can join, such as wifi, thread or wifi,thread. t, when present, is the published demo slug.
{"v":1,"auth":[1,2],"keyProvisioning":["usb"],"otaKeyRotation":false,"otaFirmwareUpdate":false,"transports":["https"]}

Keep the capability JSON compact, with these exact keys in this order and no more than 256 bytes. Do not repeat keys or list values.

CapabilityMeaning
v1.
authThe modes your firmware implements: 0 Open, 1 Token, 2 Signed. Include at least one.
keyProvisioningusb if you accept a signing key over USB. https-bootstrap only if you implement first-key delivery over HTTPS. An empty list is valid; any key route requires Signed support.
otaKeyRotation, otaFirmwareUpdateUse false unless the complete corresponding update protocol is implemented. These flags alone do not add remote updates.
transportsThe routes implemented by the firmware: http, https, mqtt, mqtts, tcp, tls-tcp or udp. Include at least one. For a device using a relay, describe its route through that relay.

The page offers security choices from this report and the selected demo’s published capabilities. It does not infer support from a board model or the old sig=1 flag. Missing or invalid capabilities prevent settings delivery.

Send long lines in pieces of at most 64 bytes, at least 30 ms apart, so UART consoles can keep up. Finish the line within 70 seconds of its first byte.

Accept only settings you implement

FieldRequirement
ssid, passWi-Fi name: 1–32 UTF-8 bytes. Password: 0–64 UTF-8 bytes. Neither may contain control characters (below U+0020 or U+007F).
aps1–8 Wi-Fi entries, each containing exactly ssid and pass. If top-level network fields are included, they must match the first entry.
threadA Thread dataset or network parameters, only on firmware that stores and applies them.
claim or token1–63 printable ASCII characters, without spaces. Accept credentials only when auth includes Token or Signed. Sending a claim code and a token together is refused with bad-json.
hwidNew USB setup IDs use at most 31 letters, digits, colons, dots, underscores or hyphens. Firmware must hold at least 31 ID characters and refuse a longer ID it cannot store, never truncate it. Existing platform IDs may be longer.
host0–63 letters, digits, dots or hyphens. A fixed-host firmware accepts only its own host. Demo installation sends the catalog host; changing an existing device’s settings leaves it alone.
keyA 32-byte signing key encoded as 44 characters of standard, padded base64. Accept only when keyProvisioning includes usb. An empty key is invalid.

A demo may also accept a published setting such as a TLS switch. There is no level field: authentication requirements are enforced by Warblet, while firmware must implement the selected mode.

Save before acknowledging

Validate the entire request before changing anything. A successful push merges into saved settings; omitted fields remain unchanged. A claim code, or a different device ID, starts a new identity and clears the old signing key unless the same push supplies a replacement. Compare IDs exactly, including case.

  • CHIRP= ok: settings were saved.
  • CHIRP= err bad-json: malformed JSON, invalid types, values or bounds.
  • CHIRP= err unsupported field: the named field is not supported. If several are unsupported, name the first in byte-by-byte order.
  • CHIRP= err missing-field: required information is absent.
  • CHIRP= err store-failed: saving could not be confirmed; either copy may be stored. Retry the push to settle the settings.
  • CHIRP= err apply-failed: settings were saved, but applying the Thread network failed. This is not a successful network connection.

Reject unknown fields rather than silently accepting them. First reject a line that is not valid JSON with bad-json, including any NUL anywhere in its contents. Then check unsupported fields, malformed values, and missing fields, in that order. Do not print credentials in diagnostics. The page keeps prepared credentials in memory after a refusal and asks for corrected settings rather than repeatedly sending the same rejected request.

Use the shared setup helper

Start from the source linked by your selected demo on the setup page. Keep its setup and credential helpers together; guided installation includes every published file. Put your sensor or control logic in the demo application rather than copying the protocol into each project.

Setup and data are separate

USB provisioning saves configuration. Your firmware then joins its network and sends data using its implemented Warblet transport. Signing authenticates messages; TLS encrypts the network connection. Prefer TLS when the firmware supports it.

Test your responder

With a serial monitor, send CHIRP? and check the complete capability report. Test an accepted settings push, an unsupported field and a storage failure. Then close the monitor before opening browser setup: only one program can use the port at a time.

Use a trusted computer

USB setup carries passwords and keys in clear text over the cable. It does not authenticate the computer or protect credentials stored on the device. Treat physical access and device storage protection separately from network encryption.