-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Added ability to test if Usermod is enabled from UsermodManager #4660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
* added isEnabled() to Usermod base class * standardized mod_id parameter in UsermodManager (some were uint8_t, some were uint16_t)
WalkthroughThe changes introduce enhancements to the usermod management system. A new virtual method, Changes
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code Graph Analysis (1)wled00/um_manager.cpp (2)
🪛 Cppcheck (2.10-2)wled00/um_manager.cpp[error] 35-35: Comparing pointers that point to different objects (comparePointers) [error] 42-42: Comparing pointers that point to different objects (comparePointers) 🔇 Additional comments (5)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Thank you for the contribution. For enabled feature I would expect modification of all existing usermods that employ enabled functionality. It would also make sense to add private variable to base class if this is something that's beneficial. |
I'm currently working on 2 mods (Enable/Disable WiFi and BLE). one of which depends on the other. Since 'enabled' is a simple bool check, it seemed more practical to add a public method to check if a mod was enabled rather than all the code needed (and probably binary size) for the getUMData call
by "I would expect" do you mean that I should include the modifications to the other usermods in this PR? I don't mind doing that. I wasn't certain on the communitie's preferences to modifying other contributors mods. |
I don't think enabling/disabling WiFi should be a usermod. In fact I've added a short snippet into JSON handling to start/stop AP mode on JSON API request. See json.cpp,
Yes, if you are adding a feature, make sure it is used where appropriate. Some usermods indeed have |
interestingly, I came to that same conclusion today. LOL The BLE mod that I'm writing will use BLE advertising, so a paired connection should not be needed.... I'll keep it as a separate PR, though. The trick is in managing the radio which is why I had to back up and implement the wifi-disable first.
understood. I'll make those changes and update the PR |
I'm not sure that we need this to be a global feature. Every currently merged usermod that interacts with another usermod does so by either (a) making custom calls directly on the other usermod's object, or (b) uses getUMData(). If you're implementing a specialized communication between two modules, I'd recommend the former approach. If you're instead trying to ask "does this usermod exist in this build", I would recommend a compile-time test; see https://github.com/wled/WLED/blob/354a0aef5205c2c56f4784a554d85eeb84972ec0/usermods/PWM_fan/setup_deps.py for an example of how to do that. That said: if we do want to adopt an "enabled" state as a queryable property on all usermods, I think we should adopt MoonModules' approach to improve compatibility between the forks. https://github.com/MoonModules/WLED-MM/blob/7cb8eebba61e0e14f15cbf036f68f6030e9f5ca0/wled00/fcn_declare.h#L301C2-L302C32 (I was pretty sure I'd seen a PR for this, but I can't find it now -- maybe it was just a suggestion on the Discord?) |
The idea was to test if an installed mod (that could be enabled or disabled) was enabled in a simpler way than using the getUMData() method. That felt like a lot of code to write to a) make a simple bool available to other usermods. It makes sense to me if you're needing access to a large set of data like with the AR mod, but for a simple bool test. If you all don't see it as a value-add, I can see your point of view. We can close the PR, if you want. |
I agree What I'm uncertain about is the use case for "the set of modules that expose an enable", especially since in this fork there's no API to do pretty much anything with them in a generic way on them except get their ID code. (The MM fork also requires each usermod provide a name, which permits making a generic UI to manipulate the enable setting.) Can you help me understand what is the use case for this set that isn't served by |
Nope.... LOL Thank you for useful feedback and great conversation. If you agree, I'll close this PR and focus on disabling WiFi... LOL |
Summary by CodeRabbit
New Features
Improvements