Skip to content

Comments

Add Ethernet Static IP Configuration via Web UI#186

Closed
craigmillard86 wants to merge 18 commits intoCarlosDerSeher:developfrom
anabolyc:feature/ethernet-static-ip
Closed

Add Ethernet Static IP Configuration via Web UI#186
craigmillard86 wants to merge 18 commits intoCarlosDerSeher:developfrom
anabolyc:feature/ethernet-static-ip

Conversation

@craigmillard86
Copy link

Summary

  • Adds a new "Ethernet Configuration" section to the General Settings page
  • Supports three Ethernet modes: Disabled, DHCP (Automatic), and Static IP (Manual)
  • Static IP mode allows configuring IP address, netmask, gateway, and DNS server
  • Includes gateway reachability check via ICMP ping with automatic DHCP fallback if gateway is unreachable

Features

  • Mode Selection: Dropdown to choose between Disabled, DHCP, or Static IP
  • IP Validation: Real-time validation of IPv4 address format with error messages
  • Gateway Ping Check: Verifies gateway is reachable before committing static IP config
  • Automatic Fallback: Falls back to DHCP if static IP gateway check fails
  • Settings Persistence: All settings stored in NVS and survive reboots
  • Conditional UI: Static IP fields only shown when Static mode is selected
  • Build-time Control: Ethernet section hidden if Ethernet not enabled in firmware

craigmillard86 and others added 17 commits January 12, 2026 13:27
- Add network_has_ip() function to check if interface has valid IP
- Wait for Ethernet to get IP before selecting it (not just link up)
- If WiFi connects first, wait up to 5 seconds for Ethernet
- Disable WiFi when Ethernet is active to save power
- Don't overwrite netif from mDNS results

This ensures Ethernet is reliably selected when both interfaces are
configured, even if WiFi's DHCP completes faster.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add support for configuring Ethernet interface mode (Disabled/DHCP/Static)
through the general settings page. Settings are persisted in NVS and applied
at boot.

Features:
- Three Ethernet modes: Disabled, DHCP (default), Static IP
- Static IP configuration: IP address, netmask, gateway, DNS
- Gateway reachability check with ICMP ping after static IP is applied
- Automatic fallback to DHCP if gateway is unreachable
- Web UI with IPv4 validation and enable/disable of fields based on mode
Make CMakeLists.txt conditionally include eth_interface.c based on
CONFIG_SNAPCLIENT_USE_INTERNAL_ETHERNET or CONFIG_SNAPCLIENT_USE_SPI_ETHERNET
so the project builds when ethernet is disabled in menuconfig.
- Removed GPIO noise prevention block (removed upstream in CarlosDerSeher#135/CarlosDerSeher#138)
- Removed commented out dead code
- Kept ethernet priority and static IP features
@anabolyc
Copy link
Contributor

Hey @craigmillard86 , looks interesting, would you like to include a screenshot "after" changes?

@craigmillard86
Copy link
Author

Hey @craigmillard86 , looks interesting, would you like to include a screenshot "after" changes?

No Problem, attached:

ethernet1

Static option:

ethernet2

@anabolyc
Copy link
Contributor

This assumes SPI Ethernet is configured in sdkconfig, right? Pinouts and everything.

Just thinking, with this change and other one is it safe to enable Ethernet in sdkconfig by default? My goal is to make things as simple as possible for people attaching w5500 eth to the Louder-ESP32 boards. Plug-and-play would be ideal.

@craigmillard86
Copy link
Author

This assumes SPI Ethernet is configured in sdkconfig, right? Pinouts and everything.

Just thinking, with this change and other one is it safe to enable Ethernet in sdkconfig by default? My goal is to make things as simple as possible for people attaching w5500 eth to the Louder-ESP32 boards. Plug-and-play would be ideal.

Yeah currently needs all configured in menuconfig - if configured with ethernet but not wired up results in hard reboot, will have a think

@anabolyc
Copy link
Contributor

This assumes SPI Ethernet is configured in sdkconfig, right? Pinouts and everything.
Just thinking, with this change and other one is it safe to enable Ethernet in sdkconfig by default? My goal is to make things as simple as possible for people attaching w5500 eth to the Louder-ESP32 boards. Plug-and-play would be ideal.

Yeah currently needs all configured in menuconfig - if configured with ethernet but not wired up results in hard reboot, will have a think

If you can make it survive a missing or failed device, that would be ideal. Squeezelite currently reboots into wifi mode if ethernet init fails, not sure if reboot is necessary, but good to have that resilience.

Refactored based on anabolyc review comments.

UI improvements:
- Move restart button to nav-bar (visible on all pages)
- Remove per-section restart buttons from general-settings
- Add netmask validation (contiguous bits check)
- Add required field validation for static IP mode
- Add confirmation dialog before saving static IP settings

Ethernet robustness:
- Change default eth_mode to Disabled (safer boot default)
- Auto-disable Ethernet on init failure and persist to NVS
- Prevents boot loops when Ethernet hardware unavailable
- Better cleanup on driver initialization failure
- Non-fatal IPv6 link-local creation error handling
@craigmillard86
Copy link
Author

Based on the comments above and a few other reasons i have refactored this and merged with the static-IP changes as they interact a fair bit.
Suggest this is closed in favor of a new PR here: #195

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants