Skip to content

Encapsulate ntp.cpp's own runtime state as static, not global - #5781

Merged
netmindz merged 1 commit into
wled:mainfrom
netmindz:refactor/ntpcpp-globals
Aug 8, 2026
Merged

Encapsulate ntp.cpp's own runtime state as static, not global#5781
netmindz merged 1 commit into
wled:mainfrom
netmindz:refactor/ntpcpp-globals

Conversation

@netmindz

@netmindz netmindz commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

Part of an ongoing pass identifying WLED_GLOBAL declarations that are actually only referenced in one file (see #5777-#5780 for earlier ones). 3 more turned out to be private to ntp.cpp: lastTimerMinute, ntpPacketSentTime, ntpServerIP.

Converted all 3 to file-local static, same types and initial values as before.

No behavior change — purely a storage-class change.

Test plan

  • esp32dev: builds and links cleanly via pio run -e esp32dev — 1,320,323 bytes flash, no warnings.
  • Confirmed via repo-wide grep (wled00/, usermods/) that none of the 3 converted variables are referenced outside ntp.cpp.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved internal handling of network time synchronization state.
    • No user-facing behavior or functionality changes.

3 WLED_GLOBAL variables were referenced only in ntp.cpp:
lastTimerMinute, ntpPacketSentTime, ntpServerIP. Converted all 3 to
file-local `static`.

No behavior change - purely a storage-class change.

Verified: esp32dev builds and links cleanly via `pio run -e esp32dev`
(1,320,323 bytes flash, no warnings from either changed file).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UtCyBD91vAYWvBzaMyQSHd
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change moves three NTP runtime variables from shared wled.h declarations to file-local static storage in ntp.cpp.

Changes

NTP state encapsulation

Layer / File(s) Summary
Localize NTP runtime state
wled00/ntp.cpp, wled00/wled.h
lastTimerMinute, ntpPacketSentTime, and ntpServerIP are defined as file-local static variables in ntp.cpp. Their shared declarations are removed from wled.h.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • wled/WLED#5777: Applies similar file-local state encapsulation to hue.cpp.
  • wled/WLED#5778: Applies similar encapsulation to variables in wled.cpp and ntp.cpp.
  • wled/WLED#5779: Applies similar encapsulation to file-specific runtime state.

Suggested reviewers: dedehai, softhack007

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making ntp.cpp runtime state file-local static instead of global.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netmindz
netmindz merged commit bfa8cef into wled:main Aug 8, 2026
30 checks passed
@netmindz
netmindz deleted the refactor/ntpcpp-globals branch August 8, 2026 11:40
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.

2 participants