Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

P-R-O-C-H-Y
Copy link
Member

@P-R-O-C-H-YP-R-O-C-H-Y commentedApr 28, 2025
edited
Loading

Description of Change

New Example: Zigbee Multi-Switch

  • Implemented theZigbee_On_Off_MultiSwitch.ino sketch, which includes:
    • Configuration and control of up to three Zigbee lights.
    • Persistent storage of light configurations in NVS.
    • Serial command handling for light control, network management, and factory reset.

Enhancements to Zigbee Core Library

  • Added a new APS data indication handler to process bind/unbind requests and update the bound devices list dynamically.[1][2]
  • Introduced acloseNetwork method to complement the existingopenNetwork method, allowing for better network management.
  • Enhanced the Zigbee application signal handler to handle device updates for routers and improve endpoint binding logic.[1][2]
  • Added a_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).

  • When MultiSwitch acted as coordinator, all lights were able to join. and bind to the switch and can be controlled
  • When MultiSwitch acted as a router, it connects to a network running in HomeAssistant (ZHA), and when I bind all 6 lights that were also connected, I was able to control them.

Related links

Please provide links to related issue, PRs etc.

Closes#11219
Closes#11006

@P-R-O-C-H-YP-R-O-C-H-Y added Status: Review neededIssue or PR is awaiting review Area: ZigbeeIssues and Feature Request about Zigbee labelsApr 28, 2025
@P-R-O-C-H-YP-R-O-C-H-Y added this to the3.3.0 milestoneApr 28, 2025
@P-R-O-C-H-YP-R-O-C-H-Y self-assigned thisApr 28, 2025
@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedApr 28, 2025
edited
Loading

Messages
📖🎉 Good Job! All checks are passing!

👋Hello P-R-O-C-H-Y, we appreciate your contribution to this project!


📘 Please review the project'sContributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you haveread and signed theContributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by thePR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with eachpush event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger isnot a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manuallyretry these Danger checks, please navigate to theActions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫dangerJS against4dff4ec

@github-actionsGitHub Actions
Copy link
Contributor

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.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32S30‼️ +4K0.00⚠️ +0.550⚠️ +1120.00⚠️ +0.30
ESP32S20‼️ +3K0.00⚠️ +0.440⚠️ +800.00⚠️ +0.25
ESP32C30‼️ +3K0.00⚠️ +0.510⚠️ +800.00⚠️ +0.28
ESP32C60‼️ +4K0.00⚠️ +0.790⚠️ +880.00⚠️ +0.31
ESP32H20‼️ +4K0.00⚠️ +0.770⚠️ +960.00⚠️ +0.34
ESP320‼️ +4K0.00⚠️ +0.580⚠️ +1040.00⚠️ +0.26
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32S3ESP32S2ESP32C3ESP32C6ESP32H2ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch‼️ +3K⚠️ +104‼️ +3K⚠️ +80‼️ +3K⚠️ +72‼️ +4K⚠️ +72‼️ +4K⚠️ +80‼️ +4K⚠️ +96
libraries/Zigbee/examples/Zigbee_Gateway‼️ +3K⚠️ +104‼️ +3K⚠️ +72‼️ +3K⚠️ +64----‼️ +4K⚠️ +104
libraries/Zigbee/examples/Zigbee_On_Off_Switch‼️ +3K⚠️ +88‼️ +3K⚠️ +72‼️ +3K⚠️ +72‼️ +4K⚠️ +72‼️ +4K⚠️ +80‼️ +4K⚠️ +88
libraries/Zigbee/examples/Zigbee_Range_Extender‼️ +3K⚠️ +112‼️ +3K⚠️ +80‼️ +3K⚠️ +56‼️ +4K⚠️ +88‼️ +4K⚠️ +80‼️ +4K⚠️ +96
libraries/Zigbee/examples/Zigbee_Thermostat‼️ +4K⚠️ +96‼️ +3K⚠️ +80‼️ +3K⚠️ +80‼️ +4K⚠️ +80‼️ +4K⚠️ +88‼️ +4K⚠️ +96
libraries/Zigbee/examples/Zigbee_Analog_Input_Output------‼️ +4K⚠️ +88‼️ +4K⚠️ +80--
libraries/Zigbee/examples/Zigbee_CarbonDioxide_Sensor------‼️ +4K⚠️ +72‼️ +4K⚠️ +80--
libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light------‼️ +4K⚠️ +64‼️ +4K⚠️ +72--
libraries/Zigbee/examples/Zigbee_Contact_Switch------‼️ +4K⚠️ +88‼️ +4K⚠️ +96--
libraries/Zigbee/examples/Zigbee_Dimmable_Light------‼️ +4K⚠️ +80‼️ +4K⚠️ +72--
libraries/Zigbee/examples/Zigbee_Illuminance_Sensor------‼️ +4K⚠️ +80‼️ +4K⚠️ +80--
libraries/Zigbee/examples/Zigbee_OTA_Client------‼️ +4K⚠️ +80‼️ +4K⚠️ +72--
libraries/Zigbee/examples/Zigbee_Occupancy_Sensor------‼️ +4K⚠️ +80‼️ +4K⚠️ +88--
libraries/Zigbee/examples/Zigbee_On_Off_Light------‼️ +4K⚠️ +80‼️ +4K⚠️ +72--
libraries/Zigbee/examples/Zigbee_On_Off_MultiSwitch------------
libraries/Zigbee/examples/Zigbee_PM25_Sensor------‼️ +4K⚠️ +72‼️ +4K⚠️ +80--
libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor------‼️ +4K⚠️ +88‼️ +4K⚠️ +80--
libraries/Zigbee/examples/Zigbee_Scan_Networks------‼️ +4K⚠️ +88‼️ +4K⚠️ +72--
libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy------‼️ +4K⚠️ +80‼️ +4K⚠️ +72--
libraries/Zigbee/examples/Zigbee_Temperature_Sensor------‼️ +4K⚠️ +88‼️ +4K⚠️ +80--
libraries/Zigbee/examples/Zigbee_Vibration_Sensor------‼️ +4K⚠️ +88‼️ +4K⚠️ +96--
libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor------‼️ +4K⚠️ +80‼️ +4K⚠️ +72--
libraries/Zigbee/examples/Zigbee_Window_Covering------‼️ +4K⚠️ +80‼️ +4K⚠️ +80--

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedApr 28, 2025
edited
Loading

Test Results

 76 files   76 suites   12m 45s ⏱️
 38 tests  38 ✅ 0 💤 0 ❌
241 runs  241 ✅ 0 💤 0 ❌

Results for commit4dff4ec.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@CopilotCopilotAI left a 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
FileDescription
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)

Copy link
Collaborator

@lucasssvazlucasssvaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

@P-R-O-C-H-YP-R-O-C-H-Y added Status: Pending MergePull Request is ready to be merged and removed Status: Review neededIssue or PR is awaiting review labelsMay 23, 2025
@me-no-devme-no-dev merged commit542274d intoespressif:masterMay 27, 2025
56 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@me-no-devme-no-devme-no-dev approved these changes

@lucasssvazlucasssvazlucasssvaz approved these changes

@SuGliderSuGliderSuGlider approved these changes

Assignees

@P-R-O-C-H-YP-R-O-C-H-Y

Labels
Area: ZigbeeIssues and Feature Request about ZigbeeStatus: Pending MergePull Request is ready to be merged
Projects
Milestone
3.3.0
4 participants
@P-R-O-C-H-Y@me-no-dev@lucasssvaz@SuGlider

[8]ページ先頭

©2009-2025 Movatter.jp