Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Optional auth: when an `access_token` is configured in settings, all JSON API ro

When WiFi credentials are not saved yet, control APIs (`/anim`, `/test/*`) return **503** `{"ok":false,"error":"wifi not configured"}`. Setup routes (`/`, `/config`, `/auth`, `/health`, `/settings`, `/setup/servo`, `/setup/led`, `/setup/audio`, `/setup/oled`) stay available on the setup AP.

If boot WiFi credentials are missing, the device opens setup AP mode (`TinyEngineer-XXXX`) and serves a five-step setup wizard at `/config` (servo calibration, OLED orientation, RGB LED, speaker test, then Wi-Fi). If saved credentials fail, it reopens setup AP mode. Hardware tests: [`docs/hardware/testing.md`](hardware/testing.md). How to wire this API into AI tools: [`integration.md`](integration.md).
If boot WiFi credentials are missing, the device opens setup AP mode (`TinyEngineer-XXXX`) and serves a five-step setup wizard at `/config` (servo calibration, OLED orientation, RGB LED, speaker test, then Wi-Fi). If saved credentials fail, it reopens setup AP mode. The setup AP acts as a captive portal: DHCP sends the portal URL (option 114) and DNS answers every name with the AP IP, so a phone that joins the network opens the wizard on its own. Hardware tests: [`docs/hardware/testing.md`](hardware/testing.md). How to wire this API into AI tools: [`integration.md`](integration.md).

Firmware answers mDNS A and AAAA (IPv6 link-local) so macOS does not wait 2–3s on a missing AAAA. If a client still pauses on the hostname, force IPv4 (`curl -4`). The IP on the OLED skips DNS entirely.

Expand Down
28 changes: 15 additions & 13 deletions src/network/wifi_connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,19 @@ void startMdns(const char* hostname) {
}
}

void startCaptiveDns() {
// Phones open the setup page on their own: DHCP option 114 names the portal
// URL, and the catch-all DNS sends connectivity probes to the web server.
void openSetupAp(wifi_mode_t mode) {
buildApSsid();

WiFi.persistent(false);
WiFi.mode(mode);
WiFi.softAP(apSsid);

if (!WiFi.AP.enableDhcpCaptivePortal()) {
serialLogPrintln("ERROR: DHCP captive portal option failed");
}

if (dnsStarted) {
return;
}
Expand Down Expand Up @@ -174,11 +186,7 @@ bool connectSta(
}

void startProvisioningAp() {
buildApSsid();

WiFi.persistent(false);
WiFi.mode(WIFI_AP);
WiFi.softAP(apSsid);
openSetupAp(WIFI_AP);

const IPAddress apIp = WiFi.softAPIP();
storeIp(apIp);
Expand All @@ -196,8 +204,6 @@ void startProvisioningAp() {
staConnected = false;
ipText[0] = '\0';

startCaptiveDns();

serialLogPrint("AP setup SSID: ");
serialLogPrintln(apSsid);
serialLogPrint("AP IP: ");
Expand Down Expand Up @@ -272,11 +278,7 @@ bool wifiTestCredentials(
serialLogPrintln("WIFI TEST (provisioning)");
serialLogPrintln("==========================");

buildApSsid();
WiFi.persistent(false);
WiFi.mode(WIFI_AP_STA);
WiFi.softAP(apSsid);
startCaptiveDns();
openSetupAp(WIFI_AP_STA);

if (!connectSta(ssid, password, hostname)) {
wifiRestoreProvisioningAp();
Expand Down
Loading