Add LED web UI with AP, Wi-Fi client, mDNS and patterns
Brings the led_strip example into the cpp app, targeting the ESP32-C3: - Access point led-XXXXXX (open) plus a Wi-Fi client configured from the web Settings tab, with credentials stored in NVS and reconnect backoff - mDNS as led.local with an HTTP service on port 80 - HTTP server with an embedded web UI and a JSON API for patterns and Wi-Fi - Pattern runner for solid, rainbow, chase, breathe, blink, pulse, transition and circle on a 119-LED WS2812 strip (GPIO 10) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
df43820acd
commit
89f996096c
20 files changed
+1539
-18
No files matched your search
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "nvs.h"
|
||||
#include "settings.h"
|
||||
|
||||
static const char *NS = "led";
|
||||
|
||||
esp_err_t settings_load_wifi(wifi_creds_t *c)
|
||||
{
|
||||
nvs_handle_t h;
|
||||
esp_err_t err = nvs_open(NS, NVS_READONLY, &h);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
size_t len = sizeof(c->ssid);
|
||||
err = nvs_get_str(h, "sta_ssid", c->ssid, &len);
|
||||
if (err == ESP_OK) {
|
||||
len = sizeof(c->pass);
|
||||
err = nvs_get_str(h, "sta_pass", c->pass, &len);
|
||||
if (err == ESP_ERR_NVS_NOT_FOUND) {
|
||||
c->pass[0] = '\0';
|
||||
err = ESP_OK;
|
||||
}
|
||||
}
|
||||
nvs_close(h);
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t settings_save_wifi(const wifi_creds_t *c)
|
||||
{
|
||||
nvs_handle_t h;
|
||||
esp_err_t err = nvs_open(NS, NVS_READWRITE, &h);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
err = nvs_set_str(h, "sta_ssid", c->ssid);
|
||||
if (err == ESP_OK) err = nvs_set_str(h, "sta_pass", c->pass);
|
||||
if (err == ESP_OK) err = nvs_commit(h);
|
||||
nvs_close(h);
|
||||
return err;
|
||||
}
|
||||
Reference in new issue
Block a user