Skip to content

Remove the "obtain NTP server from DHCP" option - #1335

Merged
gskjold merged 1 commit into
mainfrom
fix/remove-ntp-dhcp-option
Dec 4, 2026
Merged

gskjold merged 1 commit into
mainfrom
fix/remove-ntp-dhcp-option

Conversation

@gskjold

@gskjold gskjold commented Nov 26, 2026

Copy link
Copy Markdown
Member

Why

"Obtain NTP server from DHCP" never worked on ESP32 (#1330, thanks @LordMike for the analysis). Arduino-ESP32 2.0.x is built without CONFIG_LWIP_DHCP_GET_NTP_SRV, so sntp_servermode_dhcp() is an empty macro and the precompiled lwIP never asks for DHCP option 42. On ESP8266 it only took effect at a lease renewal or WiFi reconnect.

Making it work on ESP32 means either running our own DHCPINFORM next to lwIP's DHCP client (#1331, about 2 kB flash) or moving to Arduino-ESP32 3.x. Since the option has never worked on ESP32, we remove it instead. The device always uses the configured NTP server, or pool.ntp.org when none is set.

Changes

  • The "from DHCP" checkbox is removed from the network settings, along with the tick_ntp_dhcp string in localazy/source/en.json.
  • The configuration JSON, MQTT setconfig (n.h), the web form (ntpd) and the config export (ntpDhcp) no longer carry the option. Importing an old export that still has ntpDhcp works; the line is ignored.
  • sntp_servermode_dhcp(0) is still called. The ESP8266 core turns SNTP-from-DHCP on by default, so without this call a DHCP-provided server would replace the configured one at lease renewal. On ESP32 the call compiles to nothing.
  • NtpConfig.dhcp is renamed to unused. The byte stays, so the EEPROM layout is unchanged.

Verification

  • pio run -e esp8266 and pio run -e esp32s2 build.
  • pio test -e native_config passes.
  • The UI is rebuilt and ui/dist is committed.
  • Not tested on a device.

Closes #1330

🤖 Generated with Claude Code

@gskjold gskjold added this to the v2.6.1 milestone Nov 26, 2026
The option never worked on ESP32: the Arduino-ESP32 2.0.x framework is
built without CONFIG_LWIP_DHCP_GET_NTP_SRV, so sntp_servermode_dhcp() is
an empty macro and lwIP never requests DHCP option 42. On ESP8266 it only
took effect at a lease renewal or WiFi reconnect.

The device now always uses the configured NTP server, or pool.ntp.org
when none is set. The ESP8266 core takes NTP servers from DHCP by
default, so sntp_servermode_dhcp(0) is still called to keep a DHCP
server from replacing the configured one at lease renewal.

The checkbox, the "h" key in the configuration JSON and MQTT setconfig,
and the ntpDhcp line in the config export are gone; old exports with
that line still import. The byte in NtpConfig is kept as "unused" so the
EEPROM layout does not change.

Refs #1330

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@gskjold
gskjold force-pushed the fix/remove-ntp-dhcp-option branch from b20120e to be38ad0 Compare December 4, 2026 09:20
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

🔧 PR Build Artifacts

Version: be38ad0

All environments built successfully. Download the zip files:

Artifacts expire after 7 days. View workflow run

@gskjold
gskjold merged commit 7277cf0 into main Dec 4, 2026
8 checks passed
@gskjold
gskjold deleted the fix/remove-ntp-dhcp-option branch December 4, 2026 09:32
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.

"Obtain NTP server from DHCP" has no effect on ESP32

1 participant