-
Notifications
You must be signed in to change notification settings - Fork 7.6k
feat(zigbee): Remove static variables, improve binding, new example #11316
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: master
Are you sure you want to change the base?
feat(zigbee): Remove static variables, improve binding, new example #11316
Conversation
👋 Hello P-R-O-C-H-Y, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
Memory usage test (comparing PR against master branch)The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.
Click to expand the detailed deltas report [usage change in BYTES]
|
Test Results 76 files 76 suites 12m 42s ⏱️ Results for commit db5d678. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new Zigbee multi-switch example and refactors the core Zigbee binding functionality to remove global static state in favor of instance‐based callbacks. Key changes include replacing static binding callbacks with instance methods and wrappers in endpoint classes, adding dynamic bound device management methods in ZigbeeEP, and integrating a new example sketch for a multi-switch controller.
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
libraries/Zigbee/src/ep/ZigbeeThermostat.{h,cpp} | Refactored binding callbacks to instance methods and added _device. |
libraries/Zigbee/src/ep/ZigbeeSwitch.{h,cpp} | Updated binding callbacks and improved binding logic for switches. |
libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.{h,cpp} | Similar refactoring for color dimmer switches callbacks. |
libraries/Zigbee/src/ZigbeeEP.{h,cpp} | Removed static state and introduced dynamic bound device management. |
libraries/Zigbee/src/ZigbeeCore.{h,cpp} | Added network close functionality and enhanced binding table logic. |
libraries/Zigbee/examples/Zigbee_On_Off_MultiSwitch/{ino,README.md} | New multi-switch example to demonstrate the improved Zigbee binding. |
Files not reviewed (1)
- libraries/Zigbee/examples/Zigbee_On_Off_MultiSwitch/ci.json: Language not supported
Comments suppressed due to low confidence (3)
libraries/Zigbee/src/ep/ZigbeeSwitch.cpp:56
- Consider checking the return value of malloc to ensure that the allocated pointer is not null, which can prevent potential null pointer dereferences.
zb_device_params_t *light = (zb_device_params_t *)malloc(sizeof(zb_device_params_t));
libraries/Zigbee/src/ZigbeeEP.cpp:562
- The static local variables 'found_devices' and 'all_records' used in bindingTableCb persist across callback invocations; consider adding thread-safety measures or proper documentation to ensure they are safe in concurrent contexts.
static std::set<DeviceIdentifier> found_devices;
libraries/Zigbee/src/ZigbeeCore.cpp:447
- Replace the magic literal 0x00 with a defined constant (e.g., APS_SUCCESS) to improve code clarity and maintainability.
if (ind.status == 0x00)
Description of Change
New Example: Zigbee Multi-Switch
Zigbee_On_Off_MultiSwitch.ino
sketch, which includes:Enhancements to Zigbee Core Library
closeNetwork
method to complement the existingopenNetwork
method, allowing for better network management._debug
flag toZigbeeCore
for enabling detailed logs during development.These changes collectively improve the functionality and usability of the Zigbee library while providing a new example to demonstrate its capabilities.
Tests scenarios
Tested using 7x ESP32C6 (1 piece loaded with the new MultiSwitch example as Coordinator or Router, 6 pieces loaded with On/Off Light example).
Related links
Please provide links to related issue, PRs etc.
Related #11219