feat: Wi-Fi access point with a setting, password and boot button
The controller runs an AP (SSID = hostname, 192.168.5.1) next to ESP-NOW, on by default. Network settings gain an on/off switch (ap_enabled) and an optional WPA2 password (ap_password, 8-63 chars; empty is open). A button on D7 (GPIO44) held at boot forces the AP on. Wi-Fi now starts before Ethernet, and a missing W5500 no longer aborts the boot: the web server and mDNS start anyway so the AP stays usable. Network tuning found while testing over the AP: HTTP backlog 10 and 12 open sockets (the default 5 dropped the 6th SYN, a 1 s stall on every page load), larger TCP and Wi-Fi buffers, and IPv6 link-local addresses so mDNS answers AAAA queries (browsers waited about a second for them). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9989dd3062
commit
f85021d40d
11 files changed
+197
-22
No files matched your search
+13
@@ -348,6 +348,10 @@ void api_settings_defaults(void)
|
||||
api_set(st, "global_brightness", cJSON_CreateNumber(255));
|
||||
changed = true;
|
||||
}
|
||||
if (!cJSON_IsBool(cJSON_GetObjectItem(st, "ap_enabled"))) {
|
||||
api_set(st, "ap_enabled", cJSON_CreateBool(true));
|
||||
changed = true;
|
||||
}
|
||||
if (changed) {
|
||||
store_save("settings");
|
||||
}
|
||||
@@ -382,6 +386,15 @@ static esp_err_t put_settings(httpd_req_t *req)
|
||||
bad = INTS[i].err;
|
||||
}
|
||||
}
|
||||
const cJSON *ap = cJSON_GetObjectItem(body, "ap_enabled");
|
||||
if (ap && !cJSON_IsBool(ap)) {
|
||||
bad = "ap_enabled must be true or false";
|
||||
}
|
||||
const cJSON *pw = cJSON_GetObjectItem(body, "ap_password");
|
||||
if (!bad && pw && !cJSON_IsNull(pw) &&
|
||||
!(cJSON_IsString(pw) && (!pw->valuestring[0] || (strlen(pw->valuestring) >= 8 && strlen(pw->valuestring) <= 63)))) {
|
||||
bad = "ap_password must be empty (open) or 8 to 63 characters";
|
||||
}
|
||||
const cJSON *sw = cJSON_GetObjectItem(body, "sequence_switch_wait");
|
||||
if (!bad && sw && !cJSON_IsNull(sw) &&
|
||||
!(cJSON_IsString(sw) && (!strcasecmp(sw->valuestring, "beat") || !strcasecmp(sw->valuestring, "downbeat")))) {
|
||||
|
||||
Reference in new issue
Block a user