Skip to content

Web UI and API

Roman Kuraev edited this page Jul 10, 2026 · 2 revisions

Web UI and API

Embedded web UI

The webui directory contains a small Preact application built with Vite. The production build is packed into a deterministic RWFS image and linked into the F411 application, so the UI and firmware are updated together.

After flashing, open the device's IP address. It serves /, /app.js, and /rewair.css from internal flash. There is no separate UI flash step.

Build the production bundle directly with:

cd webui
npm ci
npm run build

The normal scripts/build_local_bridge.zsh workflow runs this automatically.

Local development

To preview UI changes against a live device without flashing:

cd webui
npm ci
npm run dev

Open the printed localhost URL with the device address in the query string:

http://localhost:5173/?device=192.168.1.242

Cross-origin development requires firmware built with REWAIR_API_CORS_DEV enabled in wiced/apps/rewair/local_bridge/web_api.h. That define also enables the debug SPI-flash route and should be disabled for a production build that does not need either feature.

The same Vite bundle can be hosted on an HTTPS origin and connected through Web Bluetooth. The repository's Pages workflow publishes it at https://naorunaoru.github.io/rewair/ when configured to deploy with GitHub Actions. Bluetooth access is currently read-only pending authenticated sessions; see Bluetooth Transport.

HTTP API

POST endpoints accept JSON labeled as either application/json or text/plain, allowing browser requests to remain CORS-simple.

Route Method Purpose
/api/capabilities GET API version and enabled operations
/api/status GET Live score, sensors, Wi-Fi, time, and settings
/api/scan GET Start/read a nearby Wi-Fi scan
/api/networks GET List saved networks
/api/events GET Server-sent status updates
/api/join POST Save and join a Wi-Fi network
/api/forget POST Remove a saved network
/api/priority POST Reorder saved-network priority
/api/settings POST Update device name, units, timezone, or display mode
/api/mqtt GET/POST Read or update MQTT settings; passwords are never returned
/api/time POST Set wall-clock time
/api/disp POST Set the F103 display mode
/api/update POST Perform chunked F411 firmware OTA
/api/reset POST Clear saved networks/settings and reboot into setup mode
/api/debug/sflash GET Development-only raw SPI-flash readback

The status, capabilities, scan, and network operations also use the shared API core over BLE. Detailed OTA behavior is in the Firmware Updates.

Clone this wiki locally