Encapsulate notifier/realtime UDP socket state behind accessors - #12
Open
netmindz wants to merge 1 commit into
Open
Encapsulate notifier/realtime UDP socket state behind accessors#12netmindz wants to merge 1 commit into
netmindz wants to merge 1 commit into
Conversation
notifierUdp/notifier2Udp/rgbUdp and their udpConnected/udp2Connected/ udpRgbConnected flags were WLED_GLOBAL. Once udp.cpp was split into per-protocol files (wled00/sync/), each protocol file ended up reaching into these directly - fan-out grew from a clean 2-file pair to 3-5 files each, exactly the kind of implicit cross-file coupling an accessor boundary is meant to prevent. Moved them into a NotifierSockets struct owned by wled.cpp (where the sockets are actually opened via .begin()), exposed to every other file via six small accessors: getNotifierUdp()/getNotifier2Udp()/getRgbUdp() (returning WiFiUDP& so callers can call methods directly, no copies) and isUdpConnected()/isUdp2Connected()/isUdpRgbConnected(). Call sites that use a socket more than once alias it to a local reference at the top of the function rather than repeating the accessor call. Found and fixed one real external consumer: usermods/udp_name_sync reached into notifierUdp/udpConnected directly. It isn't part of the default esp32dev usermod set, so this would have been a silent build break for anyone enabling it - caught by building the dedicated `usermods` env, which compiles every usermod. No behavior change - purely a storage/access-pattern change. Verified: - esp32dev builds and links cleanly via `pio run -e esp32dev` (1,320,311 bytes flash). - usermods env (builds all 59 usermods, including the fixed udp_name_sync) builds and links cleanly via `pio run -e usermods`. - Repo-wide grep confirms no remaining raw references to any of the six converted identifiers outside wled.cpp's NotifierSockets struct. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (4)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on the udp.cpp sync split (targets that branch, not
main, since it depends on it).notifierUdp/notifier2Udp/rgbUdpand theirudpConnected/udp2Connected/udpRgbConnectedflags wereWLED_GLOBAL. Onceudp.cppwas split into per-protocol files (wled00/sync/), each protocol file ended up reaching into these directly — fan-out grew from a clean 2-file pair to 3-5 files each, exactly the kind of implicit cross-file coupling an accessor boundary is meant to prevent.Moved them into a
NotifierSocketsstruct owned bywled.cpp(where the sockets are actually opened via.begin()), exposed to every other file via six small accessors:getNotifierUdp()/getNotifier2Udp()/getRgbUdp()(returningWiFiUDP&so callers can call methods directly, no copies) andisUdpConnected()/isUdp2Connected()/isUdpRgbConnected(). Call sites that use a socket more than once alias it to a local reference at the top of the function rather than repeating the accessor call.Found and fixed one real external consumer:
usermods/udp_name_syncreached intonotifierUdp/udpConnecteddirectly. It isn't part of the defaultesp32devusermod set, so this would have been a silent build break for anyone enabling it — caught by building the dedicatedusermodsenv, which compiles every usermod.No behavior change — purely a storage/access-pattern change.
Test plan
esp32dev: builds and links cleanly viapio run -e esp32dev(1,320,311 bytes flash).usermodsenv (builds all 59 usermods, including the fixedudp_name_sync): builds and links cleanly viapio run -e usermods.wled.cpp'sNotifierSocketsstruct.🤖 Generated with Claude Code
Summary by cubic
Encapsulated notifier and realtime UDP sockets (and their connection flags) behind small accessors to reduce cross-file coupling after the UDP sync split. No behavior change; also fixes a build break in the
udp_name_syncusermod.Refactors
notifierUdp,notifier2Udp,rgbUdpand their flags intoNotifierSocketsinwled.cpp.getNotifierUdp(),getNotifier2Udp(),getRgbUdp(),isUdpConnected(),isUdp2Connected(),isUdpRgbConnected().Bug Fixes
usermods/udp_name_syncto use the new accessors to prevent a build failure when the usermod is enabled.Written for commit a196171. Summary will update on new commits.