feat: default IP, reset reason in /status, seeded default group
With no DHCP answer in 15 seconds the controller takes 192.168.4.1/24, for a cable straight to a PC with a static IP. /status reports why the board last restarted. First boot also seeds a default group that the default zone plays to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4372ba4105
commit
2f0c26e9b8
12 files changed
+99
-35
No files matched your search
@@ -24,7 +24,7 @@ make test-browser HOST=<ip> # Selenium UI tests (needs selenium and chromedriv
|
|||||||
- `led-driver/` (submodule): MicroPython firmware for the ESP32 LED drivers.
|
- `led-driver/` (submodule): MicroPython firmware for the ESP32 LED drivers.
|
||||||
- `led-tool/` (submodule): `led-cli`, configures drivers over serial and updates the controller over Ethernet (`led-cli --ota HOST`).
|
- `led-tool/` (submodule): `led-cli`, configures drivers over serial and updates the controller over Ethernet (`led-cli --ota HOST`).
|
||||||
- `led-simulator/` (submodule), `espnow-sender/`: test helpers.
|
- `led-simulator/` (submodule), `espnow-sender/`: test helpers.
|
||||||
- `db/`: the records a controller starts with (the `default` profile the firmware seeds at first boot, plus pattern metadata), importable with `PUT /db/<name>`.
|
- `db/`: the records a controller starts with (the `default` profile and group the firmware seeds at first boot, plus pattern metadata), importable with `PUT /db/<name>`.
|
||||||
- `test/api/`: the API tests (`test/api/README.md`); `test/browser/`: the UI tests.
|
- `test/api/`: the API tests (`test/api/README.md`); `test/browser/`: the UI tests.
|
||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
@@ -39,6 +39,8 @@ The controller advertises `<hostname>.local` over mDNS (default `led-controller`
|
|||||||
|
|
||||||
`static_ips` is a list of networks to try, in order, each time the Ethernet link comes up. The first entry whose gateway answers ARP is used; if none does (or the list is empty) the controller uses DHCP. `netmask` defaults to `255.255.255.0`, `dns` to the gateway.
|
`static_ips` is a list of networks to try, in order, each time the Ethernet link comes up. The first entry whose gateway answers ARP is used; if none does (or the list is empty) the controller uses DHCP. `netmask` defaults to `255.255.255.0`, `dns` to the gateway.
|
||||||
|
|
||||||
|
If DHCP gets no answer within 15 seconds, the controller takes `192.168.4.1/24`. For a cable straight from a PC, give the PC a static IP on that subnet, such as `192.168.4.2/24`, and open `http://192.168.4.1/`. The controller tries DHCP again only when the link next comes up.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X PUT http://led-controller.local/settings/settings -H 'Content-Type: application/json' -d '{
|
curl -X PUT http://led-controller.local/settings/settings -H 'Content-Type: application/json' -d '{
|
||||||
"hostname": "stage",
|
"hostname": "stage",
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{}
|
{"1": {"name": "default", "devices": [], "wifi_driver_display_name": null, "wifi_driver_num_leds": null, "wifi_color_order": null, "wifi_startup_mode": null, "output_brightness": 255, "bridge_id": null, "pattern": "on", "colors": ["000000", "FF0000"], "brightness": 100, "delay": 100, "step_offset": 0, "step_increment": 1, "n1": 0, "n2": 0, "n3": 0, "n4": 0, "n5": 0, "n6": 0, "n7": 0, "n8": 0, "id": "1"}}
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"1": {"name": "default", "names": ["1"], "presets": [["1", "2", "3", "4", "5", "6", "7", "8"]], "presets_flat": ["1", "2", "3", "4", "5", "6", "7", "8"], "default_preset": "1", "id": "1", "group_ids": [], "preset_group_ids": {}, "sequence_ids": [], "content_kind": "presets"}}
|
{"1": {"name": "default", "names": ["1"], "presets": [["1", "2", "3", "4", "5", "6", "7", "8"]], "presets_flat": ["1", "2", "3", "4", "5", "6", "7", "8"], "default_preset": "1", "id": "1", "group_ids": ["1"], "preset_group_ids": {}, "sequence_ids": [], "content_kind": "presets"}}
|
||||||
+2
-2
@@ -61,7 +61,7 @@ Keys with meaning on the controller (others are stored as they are):
|
|||||||
| Key | Checked | Meaning |
|
| Key | Checked | Meaning |
|
||||||
|-----|---------|---------|
|
|-----|---------|---------|
|
||||||
| `hostname` | | mDNS name (`<hostname>.local`, default `led-controller`); applies after a restart |
|
| `hostname` | | mDNS name (`<hostname>.local`, default `led-controller`); applies after a restart |
|
||||||
| `static_ips` | | List of `{ip, netmask?, gw, dns?}` tried in order when the Ethernet link comes up; the first whose gateway answers ARP is used, else DHCP. Applies after a restart |
|
| `static_ips` | | List of `{ip, netmask?, gw, dns?}` tried in order when the Ethernet link comes up; the first whose gateway answers ARP is used, else DHCP, else `192.168.4.1/24` for a direct PC cable. Applies after a restart |
|
||||||
| `global_brightness` | integer 0–255 | Global factor of each driver's brightness (see Groups). Stored only: the UI pushes each driver its combined value |
|
| `global_brightness` | integer 0–255 | Global factor of each driver's brightness (see Groups). Stored only: the UI pushes each driver its combined value |
|
||||||
| `wifi_channel` | integer 1–11 | Stored for reference. The controller's ESP-NOW channel is set at build time (`make menuconfig`) |
|
| `wifi_channel` | integer 1–11 | Stored for reference. The controller's ESP-NOW channel is set at build time (`make menuconfig`) |
|
||||||
| `audio_simulated_bpm` | clamped to 60–200 | Tempo of the beat clock (default 120) |
|
| `audio_simulated_bpm` | clamped to 60–200 | Tempo of the beat clock (default 120) |
|
||||||
@@ -90,7 +90,7 @@ A profile is `{name, type: "zones", zones: [zone ids], scenes, palette_id}`.
|
|||||||
| GET | `/profiles/<id>/export` | Profile bundle (see Import and export) |
|
| GET | `/profiles/<id>/export` | Profile bundle (see Import and export) |
|
||||||
| POST | `/profiles/import` | Body: `{"bundle": {...}, "name"?, "apply"? (default true)}` or the bundle itself. Reply `{"<id>": profile, "id": "<id>"}`, 201 |
|
| POST | `/profiles/import` | Body: `{"bundle": {...}, "name"?, "apply"? (default true)}` or the bundle itself. Reply `{"<id>": profile, "id": "<id>"}`, 201 |
|
||||||
|
|
||||||
A store with no profile gets one at boot, `default`, with the same seed and a starter palette. A new profile gets an empty palette, eight presets (`on`, `off`, `rainbow` (`colour_cycle`), `Colour Cycle`, `transition`, `flicker`, `flame`, `twinkle`) and a zone `default` that lists them and names driver `1`. With `seed_dj_zone` it also gets three `DJ …` presets in a zone `dj` naming driver `dj`.
|
A store with no profile gets one at boot, `default`, with the same seed, a starter palette and an empty `default` group that its zone plays to. A new profile gets an empty palette, eight presets (`on`, `off`, `rainbow` (`colour_cycle`), `Colour Cycle`, `transition`, `flicker`, `flame`, `twinkle`) and a zone `default` that lists them and names driver `1`. With `seed_dj_zone` it also gets three `DJ …` presets in a zone `dj` naming driver `dj`.
|
||||||
|
|
||||||
## Presets — `/presets`
|
## Presets — `/presets`
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@ export S3=192.168.1.50
|
|||||||
curl -s http://$S3/status
|
curl -s http://$S3/status
|
||||||
```
|
```
|
||||||
|
|
||||||
Expect JSON with `uptime_s`, `bpm`, an `espnow` block and a `link` block (`ver` nonzero, `digests` increasing by one about every 1.5 s). If the mic hears music, `bpm` and `beats_sent` move too, which means beats are already being broadcast. Open `http://$S3/` in a browser: the UI should load, and the dev tools network tab should show `Content-Encoding: gzip` on `/static/*.js`.
|
Expect JSON with `uptime_s`, `reset_reason` (why the board last restarted, such as `panic`, `task_watchdog` or `brownout`; opening the USB serial port resets the board and replaces it with `usb`, so read it first), `bpm`, an `espnow` block and a `link` block (`ver` nonzero, `digests` increasing by one about every 1.5 s). If the mic hears music, `bpm` and `beats_sent` move too, which means beats are already being broadcast. Open `http://$S3/` in a browser: the UI should load, and the dev tools network tab should show `Content-Encoding: gzip` on `/static/*.js`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -s -D - -o /dev/null -H 'Accept-Encoding: gzip' http://$S3/static/presets.js | grep -i -E 'content-encoding|content-type'
|
curl -s -D - -o /dev/null -H 'Accept-Encoding: gzip' http://$S3/static/presets.js | grep -i -E 'content-encoding|content-type'
|
||||||
|
|||||||
+1
-1
@@ -106,7 +106,7 @@ The preset editor:
|
|||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
|
|
||||||
**Settings** (Edit mode) holds the controller's name, the ESP-NOW channel (for reference: the controller's channel is set at build time), its mDNS **hostname** and the **static IPs** it tries on the Ethernet link (DHCP when none answers). Network changes apply after a restart. Drivers are configured over USB with `led-cli` on a computer.
|
**Settings** (Edit mode) holds the controller's name, the ESP-NOW channel (for reference: the controller's channel is set at build time), its mDNS **hostname** and the **static IPs** it tries on the Ethernet link (DHCP when none answers). With no DHCP server, as on a cable straight to a PC, the controller is at `192.168.4.1`; give the PC a static IP such as `192.168.4.2`. Network changes apply after a restart. Drivers are configured over USB with `led-cli` on a computer.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ bool api_preset_in_profile(const cJSON *rec);
|
|||||||
// Bring records written by older versions into the current shape (at boot)
|
// Bring records written by older versions into the current shape (at boot)
|
||||||
void api_migrate_sequences(void);
|
void api_migrate_sequences(void);
|
||||||
void api_seed_defaults(void);
|
void api_seed_defaults(void);
|
||||||
|
// A new group with the defaults, saved; its id in id
|
||||||
|
void api_add_group(const char *name, char *id, size_t len);
|
||||||
void api_migrate_zones(void);
|
void api_migrate_zones(void);
|
||||||
void api_migrate_groups(void);
|
void api_migrate_groups(void);
|
||||||
|
|
||||||
|
|||||||
+67
-25
@@ -45,6 +45,23 @@ static const char *TAG = "eth";
|
|||||||
static httpd_handle_t s_server = NULL;
|
static httpd_handle_t s_server = NULL;
|
||||||
static esp_netif_t *s_eth_netif = NULL;
|
static esp_netif_t *s_eth_netif = NULL;
|
||||||
|
|
||||||
|
static const char *reset_reason(void)
|
||||||
|
{
|
||||||
|
switch (esp_reset_reason()) {
|
||||||
|
case ESP_RST_POWERON: return "power_on";
|
||||||
|
case ESP_RST_EXT: return "external";
|
||||||
|
case ESP_RST_SW: return "software";
|
||||||
|
case ESP_RST_PANIC: return "panic";
|
||||||
|
case ESP_RST_INT_WDT: return "interrupt_watchdog";
|
||||||
|
case ESP_RST_TASK_WDT: return "task_watchdog";
|
||||||
|
case ESP_RST_WDT: return "watchdog";
|
||||||
|
case ESP_RST_BROWNOUT: return "brownout";
|
||||||
|
case ESP_RST_USB: return "usb";
|
||||||
|
case ESP_RST_PWR_GLITCH: return "power_glitch";
|
||||||
|
default: return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static esp_err_t status_get_handler(httpd_req_t *req)
|
static esp_err_t status_get_handler(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
beat_info_t bi;
|
beat_info_t bi;
|
||||||
@@ -63,14 +80,14 @@ static esp_err_t status_get_handler(httpd_req_t *req)
|
|||||||
snprintf(ip, sizeof(ip), IPSTR, IP2STR(&ip_info.ip));
|
snprintf(ip, sizeof(ip), IPSTR, IP2STR(&ip_info.ip));
|
||||||
snprintf(macs, sizeof(macs), MACSTR, MAC2STR(mac));
|
snprintf(macs, sizeof(macs), MACSTR, MAC2STR(mac));
|
||||||
snprintf(buf, sizeof(buf),
|
snprintf(buf, sizeof(buf),
|
||||||
"{\"ip\":\"%s\",\"mac\":\"%s\",\"uptime_s\":%lld,\"free_heap\":%lu,\"free_internal\":%lu,"
|
"{\"ip\":\"%s\",\"mac\":\"%s\",\"uptime_s\":%lld,\"reset_reason\":\"%s\",\"free_heap\":%lu,\"free_internal\":%lu,"
|
||||||
"\"mic_rms_dbfs\":%.1f,\"mic_peak_dbfs\":%.1f,\"mic_spl_db\":%.1f,"
|
"\"mic_rms_dbfs\":%.1f,\"mic_peak_dbfs\":%.1f,\"mic_spl_db\":%.1f,"
|
||||||
"\"bpm\":%.1f,\"beat_confidence\":%.2f,\"beat_locked\":%s,\"beats\":%lu,\"onsets\":%lu,"
|
"\"bpm\":%.1f,\"beat_confidence\":%.2f,\"beat_locked\":%s,\"beats\":%lu,\"onsets\":%lu,"
|
||||||
"\"meter\":%d,\"bar_beat\":%d,\"bar_sure\":%s,\"downbeats\":%lu,"
|
"\"meter\":%d,\"bar_beat\":%d,\"bar_sure\":%s,\"downbeats\":%lu,"
|
||||||
"\"espnow\":{\"beats_sent\":%lu,\"beat_send_fail\":%lu,\"bulk_sent\":%lu,"
|
"\"espnow\":{\"beats_sent\":%lu,\"beat_send_fail\":%lu,\"bulk_sent\":%lu,"
|
||||||
"\"bulk_retries\":%lu,\"bulk_failed\":%lu,\"sim_dropped\":%lu},"
|
"\"bulk_retries\":%lu,\"bulk_failed\":%lu,\"sim_dropped\":%lu},"
|
||||||
"\"link\":{\"ver\":%u,\"acked\":%lu,\"ack_timeouts\":%lu,\"retransmits\":%lu,\"resyncs\":%lu,\"digests\":%lu}}",
|
"\"link\":{\"ver\":%u,\"acked\":%lu,\"ack_timeouts\":%lu,\"retransmits\":%lu,\"resyncs\":%lu,\"digests\":%lu}}",
|
||||||
ip, macs, (long long)(esp_timer_get_time() / 1000000), (unsigned long)esp_get_free_heap_size(),
|
ip, macs, (long long)(esp_timer_get_time() / 1000000), reset_reason(), (unsigned long)esp_get_free_heap_size(),
|
||||||
(unsigned long)heap_caps_get_free_size(MALLOC_CAP_INTERNAL), level.rms_dbfs, level.peak_dbfs, level.spl_db,
|
(unsigned long)heap_caps_get_free_size(MALLOC_CAP_INTERNAL), level.rms_dbfs, level.peak_dbfs, level.spl_db,
|
||||||
bi.bpm, bi.confidence, bi.locked ? "true" : "false", (unsigned long)bi.beat_count,
|
bi.bpm, bi.confidence, bi.locked ? "true" : "false", (unsigned long)bi.beat_count,
|
||||||
(unsigned long)bi.onset_count, bi.meter, bi.bar_beat, bi.bar_sure ? "true" : "false",
|
(unsigned long)bi.onset_count, bi.meter, bi.bar_beat, bi.bar_sure ? "true" : "false",
|
||||||
@@ -85,6 +102,11 @@ static esp_err_t status_get_handler(httpd_req_t *req)
|
|||||||
|
|
||||||
#define DEFAULT_HOSTNAME "led-controller"
|
#define DEFAULT_HOSTNAME "led-controller"
|
||||||
|
|
||||||
|
// Address when no DHCP server answers, as on a cable straight to a PC. The PC needs a static IP on this subnet.
|
||||||
|
#define DEFAULT_IP ESP_IP4TOADDR(192, 168, 4, 1)
|
||||||
|
#define DEFAULT_NETMASK ESP_IP4TOADDR(255, 255, 255, 0)
|
||||||
|
#define DHCP_WAIT_S 15
|
||||||
|
|
||||||
static const char *settings_str(const char *key)
|
static const char *settings_str(const char *key)
|
||||||
{
|
{
|
||||||
cJSON *v = cJSON_GetObjectItem(store_settings(), key);
|
cJSON *v = cJSON_GetObjectItem(store_settings(), key);
|
||||||
@@ -92,7 +114,7 @@ static const char *settings_str(const char *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "static_ips" setting: a list of {ip, netmask, gw, dns} tried in order on every link-up. The first whose
|
// "static_ips" setting: a list of {ip, netmask, gw, dns} tried in order on every link-up. The first whose
|
||||||
// gateway answers ARP is kept; if none does, the controller falls back to DHCP.
|
// gateway answers ARP is kept; if none does, the controller falls back to DHCP, then to DEFAULT_IP.
|
||||||
static bool parse_static(cJSON *e, esp_netif_ip_info_t *info, esp_netif_dns_info_t *dns)
|
static bool parse_static(cJSON *e, esp_netif_ip_info_t *info, esp_netif_dns_info_t *dns)
|
||||||
{
|
{
|
||||||
const char *ip = NULL, *mask = "255.255.255.0", *gw = NULL, *d = NULL;
|
const char *ip = NULL, *mask = "255.255.255.0", *gw = NULL, *d = NULL;
|
||||||
@@ -140,16 +162,19 @@ static bool gateway_answers(esp_netif_t *netif, const esp_ip4_addr_t *gw)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void static_ip_task(void *arg)
|
static bool have_static_ips(void)
|
||||||
{
|
{
|
||||||
static bool running;
|
cJSON *l = cJSON_GetObjectItem(store_settings(), "static_ips");
|
||||||
if (running) {
|
return cJSON_IsArray(l) && cJSON_GetArraySize(l) > 0;
|
||||||
vTaskDelete(NULL);
|
}
|
||||||
|
|
||||||
|
static bool try_static_ips(void)
|
||||||
|
{
|
||||||
|
if (!have_static_ips()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
running = true;
|
|
||||||
cJSON *list = cJSON_GetObjectItem(store_settings(), "static_ips");
|
cJSON *list = cJSON_GetObjectItem(store_settings(), "static_ips");
|
||||||
esp_netif_dhcpc_stop(s_eth_netif);
|
esp_netif_dhcpc_stop(s_eth_netif);
|
||||||
bool done = false;
|
|
||||||
cJSON *e;
|
cJSON *e;
|
||||||
cJSON_ArrayForEach(e, list) {
|
cJSON_ArrayForEach(e, list) {
|
||||||
esp_netif_ip_info_t info;
|
esp_netif_ip_info_t info;
|
||||||
@@ -166,27 +191,46 @@ static void static_ip_task(void *arg)
|
|||||||
}
|
}
|
||||||
if (info.gw.addr == 0 || gateway_answers(s_eth_netif, &info.gw)) {
|
if (info.gw.addr == 0 || gateway_answers(s_eth_netif, &info.gw)) {
|
||||||
ESP_LOGI(TAG, "Static IP " IPSTR " (gw " IPSTR ")", IP2STR(&info.ip), IP2STR(&info.gw));
|
ESP_LOGI(TAG, "Static IP " IPSTR " (gw " IPSTR ")", IP2STR(&info.ip), IP2STR(&info.gw));
|
||||||
done = true;
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Static IP " IPSTR ": gateway " IPSTR " did not answer", IP2STR(&info.ip), IP2STR(&info.gw));
|
ESP_LOGI(TAG, "Static IP " IPSTR ": gateway " IPSTR " did not answer", IP2STR(&info.ip), IP2STR(&info.gw));
|
||||||
}
|
}
|
||||||
if (!done) {
|
ESP_LOGW(TAG, "No static IP matched this network, using DHCP");
|
||||||
ESP_LOGW(TAG, "No static IP matched this network, using DHCP");
|
return false;
|
||||||
esp_netif_ip_info_t none = { 0 };
|
}
|
||||||
esp_netif_set_ip_info(s_eth_netif, &none);
|
|
||||||
esp_netif_dhcpc_start(s_eth_netif);
|
// Start DHCP and wait for a lease. A lost link also ends the wait: the next link-up starts over.
|
||||||
|
static bool dhcp_settled(void)
|
||||||
|
{
|
||||||
|
esp_netif_dhcpc_start(s_eth_netif);
|
||||||
|
for (int i = 0; i < DHCP_WAIT_S * 10; i++) {
|
||||||
|
esp_netif_ip_info_t ip;
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
|
esp_netif_get_ip_info(s_eth_netif, &ip);
|
||||||
|
if (ip.ip.addr != 0 || !esp_netif_is_netif_up(s_eth_netif)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void link_up_task(void *arg)
|
||||||
|
{
|
||||||
|
static bool running;
|
||||||
|
if (running) {
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
running = true;
|
||||||
|
if (!try_static_ips() && !dhcp_settled()) {
|
||||||
|
ESP_LOGW(TAG, "No DHCP server, using the default IP");
|
||||||
|
esp_netif_ip_info_t info = { .ip.addr = DEFAULT_IP, .netmask.addr = DEFAULT_NETMASK };
|
||||||
|
esp_netif_dhcpc_stop(s_eth_netif);
|
||||||
|
esp_netif_set_ip_info(s_eth_netif, &info);
|
||||||
}
|
}
|
||||||
running = false;
|
running = false;
|
||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool have_static_ips(void)
|
|
||||||
{
|
|
||||||
cJSON *l = cJSON_GetObjectItem(store_settings(), "static_ips");
|
|
||||||
return cJSON_IsArray(l) && cJSON_GetArraySize(l) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void start_mdns(void)
|
static void start_mdns(void)
|
||||||
{
|
{
|
||||||
const char *host = settings_str("hostname");
|
const char *host = settings_str("hostname");
|
||||||
@@ -243,9 +287,7 @@ static void eth_event_handler(void *arg, esp_event_base_t event_base,
|
|||||||
esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &speed);
|
esp_eth_ioctl(eth_handle, ETH_CMD_G_SPEED, &speed);
|
||||||
esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &duplex);
|
esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &duplex);
|
||||||
ESP_LOGI(TAG, "Ethernet Link Up, MAC " MACSTR, MAC2STR(mac));
|
ESP_LOGI(TAG, "Ethernet Link Up, MAC " MACSTR, MAC2STR(mac));
|
||||||
if (have_static_ips()) {
|
xTaskCreate(link_up_task, "link_up", 4096, NULL, 5, NULL);
|
||||||
xTaskCreate(static_ip_task, "static_ip", 4096, NULL, 5, NULL);
|
|
||||||
}
|
|
||||||
ESP_LOGI(TAG, "%s Mbps %s Duplex",
|
ESP_LOGI(TAG, "%s Mbps %s Duplex",
|
||||||
speed == ETH_SPEED_100M ? "100" : "10",
|
speed == ETH_SPEED_100M ? "100" : "10",
|
||||||
duplex == ETH_DUPLEX_FULL ? "Full" : "Half");
|
duplex == ETH_DUPLEX_FULL ? "Full" : "Half");
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ static const char *const DEFAULTS =
|
|||||||
"\"pattern\":\"on\",\"colors\":[\"000000\",\"FF0000\"],\"brightness\":100,\"delay\":100,\"step_offset\":0,"
|
"\"pattern\":\"on\",\"colors\":[\"000000\",\"FF0000\"],\"brightness\":100,\"delay\":100,\"step_offset\":0,"
|
||||||
"\"step_increment\":1,\"n1\":0,\"n2\":0,\"n3\":0,\"n4\":0,\"n5\":0,\"n6\":0,\"n7\":0,\"n8\":0}";
|
"\"step_increment\":1,\"n1\":0,\"n2\":0,\"n3\":0,\"n4\":0,\"n5\":0,\"n6\":0,\"n7\":0,\"n8\":0}";
|
||||||
|
|
||||||
|
void api_add_group(const char *name, char *id, size_t len)
|
||||||
|
{
|
||||||
|
cJSON *g = cJSON_Parse(DEFAULTS);
|
||||||
|
api_set(g, "name", cJSON_CreateString(name));
|
||||||
|
api_add("group", g, id, len);
|
||||||
|
store_save("group");
|
||||||
|
}
|
||||||
|
|
||||||
bool api_mac(const cJSON *v, char out[13])
|
bool api_mac(const cJSON *v, char out[13])
|
||||||
{
|
{
|
||||||
if (!cJSON_IsString(v)) {
|
if (!cJSON_IsString(v)) {
|
||||||
|
|||||||
+8
-2
@@ -277,11 +277,17 @@ void api_seed_defaults(void)
|
|||||||
}
|
}
|
||||||
cJSON *fields = cJSON_CreateObject();
|
cJSON *fields = cJSON_CreateObject();
|
||||||
cJSON_AddStringToObject(fields, "name", "default");
|
cJSON_AddStringToObject(fields, "name", "default");
|
||||||
char pid[16];
|
char pid[16], gid[16];
|
||||||
seed_profile(fields,
|
cJSON *prof = seed_profile(fields,
|
||||||
cJSON_Parse("[\"#FF0000\",\"#00FF00\",\"#0000FF\",\"#FFFF00\",\"#FF00FF\",\"#00FFFF\",\"#FFFFFF\",\"#000000\"]"),
|
cJSON_Parse("[\"#FF0000\",\"#00FF00\",\"#0000FF\",\"#FFFF00\",\"#FF00FF\",\"#00FFFF\",\"#FFFFFF\",\"#000000\"]"),
|
||||||
false, pid, sizeof(pid));
|
false, pid, sizeof(pid));
|
||||||
cJSON_Delete(fields);
|
cJSON_Delete(fields);
|
||||||
|
api_add_group("default", gid, sizeof(gid));
|
||||||
|
cJSON *gids = cJSON_CreateArray();
|
||||||
|
cJSON_AddItemToArray(gids, cJSON_CreateString(gid));
|
||||||
|
const cJSON *zid = cJSON_GetArrayItem(cJSON_GetObjectItem(prof, "zones"), 0);
|
||||||
|
api_set(cJSON_GetObjectItem(store_coll("zone"), zid->valuestring), "group_ids", gids);
|
||||||
|
store_save("zone");
|
||||||
}
|
}
|
||||||
|
|
||||||
static const cJSON *profile_zones(const cJSON *prof)
|
static const cJSON *profile_zones(const cJSON *prof)
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ def test_static(c, path):
|
|||||||
assert c.get(f"/static/{path}").status_code == 200
|
assert c.get(f"/static/{path}").status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
def test_status_reset_reason(c):
|
||||||
|
assert c.get("/status").json()["reset_reason"]
|
||||||
|
|
||||||
|
|
||||||
def test_settings_page(c):
|
def test_settings_page(c):
|
||||||
resp = c.get("/settings/page")
|
resp = c.get("/settings/page")
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
|
|||||||
@@ -1178,7 +1178,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Static IPs</label>
|
<label>Static IPs</label>
|
||||||
<small>Tried in order each time the Ethernet link comes up; the first whose gateway answers is used. If none does, or the list is empty, DHCP is used.</small>
|
<small>Tried in order each time the Ethernet link comes up; the first whose gateway answers is used. If none does, or the list is empty, DHCP is used. With no DHCP server, as on a cable straight to a PC, the controller is at <code>192.168.4.1</code>; give the PC a static IP such as <code>192.168.4.2</code>.</small>
|
||||||
<div id="static-ips-list"></div>
|
<div id="static-ips-list"></div>
|
||||||
<button type="button" class="btn btn-secondary" id="static-ip-add-btn">Add network</button>
|
<button type="button" class="btn btn-secondary" id="static-ip-add-btn">Add network</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user