Skip to content
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

feat(zigbee): Add check, boolean returns, fix Analog, add optional reset on factoryReset #11153

Merged

Conversation

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

@P-R-O-C-H-Y P-R-O-C-H-Y commented Mar 20, 2025

Description of Change

  • Fix memory leak
  • Updated almost all methods to return a boolean value and print error message with code and string of the error.
  • factoryReset method now have an optional parameter bool restart, by default its set to TRUE, but if false is passed, the Zigbee will just erase the nvram and the reset or reboot will need to be managed in user sketch. Example of how it can be used is the Temperature Humidity Sleepy example.
  • Simplified the AnalogSensor Endpoint -> removed AnalogValue, as its not commonly used in any device
  • Fixed AnalogSensor compilation warning message

Tests scenarios

Related links

Closes #11178

@P-R-O-C-H-Y P-R-O-C-H-Y added this to the 3.3.0 milestone Mar 20, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y added the Area: Zigbee Issues and Feature Request about Zigbee label Mar 20, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Mar 20, 2025
Copy link
Contributor

github-actions bot commented Mar 20, 2025

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "fix(zigbee): Fix memory leak, print esp_zb_zcl_status_t error, remove analogValue from analog EP":
    • summary appears to be too long
  • the commit message "fix(zigbee): Hope its finished now..":
    • summary should not end with a period (full stop)
  • the commit message "fix/zigbee): Add missing return in WindowCovering":
    • summary looks empty
    • type/action looks empty

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 10 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

Messages
📖 This PR seems to be quite large (total lines of code: 1266), you might consider splitting it into smaller PRs

👋 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 ...


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

DangerJS is triggered with each push 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 is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- Addressing info messages (📖) is strongly recommended; they're less critical but valuable.
- To manually retry these Danger checks, please navigate to the Actions 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 against 3bebb79

@P-R-O-C-H-Y P-R-O-C-H-Y added the Status: In Progress ⚠️ Issue is in progress label Mar 20, 2025
Copy link
Contributor

github-actions bot commented Mar 20, 2025

Test Results

 76 files   76 suites   13m 27s ⏱️
 38 tests  38 ✅ 0 💤 0 ❌
241 runs  241 ✅ 0 💤 0 ❌

Results for commit 3bebb79.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Mar 20, 2025

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
ESP32S3💚 -440💚 -0.010.00000.000.00
ESP32S2💚 -520💚 -0.010.00000.000.00
ESP32C3💚 -540💚 -0.010.00000.000.00
ESP32C6💚 -88⚠️ +432💚 -0.02⚠️ +0.08000.000.00
ESP32H2💚 -786⚠️ +448💚 -0.13⚠️ +0.08000.000.00
ESP32💚 -520💚 -0.010.00000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32S3ESP32S2ESP32C3ESP32C6ESP32H2ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch💚 -440💚 -520💚 -540💚 -540💚 -540💚 -520
libraries/Zigbee/examples/Zigbee_Gateway💚 -40💚 -40💚 -320----💚 -200
libraries/Zigbee/examples/Zigbee_On_Off_Switch💚 -280💚 -160💚 -300💚 -280💚 -300💚 -280
libraries/Zigbee/examples/Zigbee_Range_Extender💚 -20000💚 -420💚 -420💚 -380💚 -200
libraries/Zigbee/examples/Zigbee_Thermostat💚 -240💚 -200💚 -380💚 -380💚 -380💚 -280
libraries/Zigbee/examples/Zigbee_Analog_Input_Output------💚 -880💚 -880--
libraries/Zigbee/examples/Zigbee_CarbonDioxide_Sensor------00💚 -20--
libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light------💚 -280💚 -280--
libraries/Zigbee/examples/Zigbee_Contact_Switch------00💚 -40--
libraries/Zigbee/examples/Zigbee_Dimmable_Light------💚 -300💚 -300--
libraries/Zigbee/examples/Zigbee_Illuminance_Sensor------⚠️ +280⚠️ +280--
libraries/Zigbee/examples/Zigbee_OTA_Client------💚 -240💚 -7860--
libraries/Zigbee/examples/Zigbee_Occupancy_Sensor------💚 -220💚 -220--
libraries/Zigbee/examples/Zigbee_On_Off_Light------💚 -340💚 -300--
libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor------⚠️ +460⚠️ +460--
libraries/Zigbee/examples/Zigbee_Scan_Networks------0000--
libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy------⚠️ +4320⚠️ +4480--
libraries/Zigbee/examples/Zigbee_Temperature_Sensor------⚠️ +300⚠️ +320--
libraries/Zigbee/examples/Zigbee_Vibration_Sensor------💚 -260💚 -260--
libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor------⚠️ +20⚠️ +20--
libraries/Zigbee/examples/Zigbee_Window_Covering------⚠️ +100⚠️ +100--

@me-no-dev
Copy link
Member

Please format errors like this:

  esp_err_t err = esp_wifi_set_max_tx_power(power);
  if (err != ESP_OK) {
    log_e("Failed to set TX Power: 0x%x: %s", err, esp_err_to_name(err));
  }

@P-R-O-C-H-Y P-R-O-C-H-Y force-pushed the feat/zigbee-commands-return-check branch from 104a381 to 80eba94 Compare March 21, 2025 11:43
@P-R-O-C-H-Y P-R-O-C-H-Y added Status: Review needed Issue or PR is awaiting review and removed Status: In Progress ⚠️ Issue is in progress labels Mar 24, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y marked this pull request as ready for review March 24, 2025 13:10
@SuGlider
Copy link
Collaborator

SuGlider commented Mar 27, 2025

@P-R-O-C-H-Y - please review the code in ZigbeeEP.cpp :: void ZigbeeEP::zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute). It has 2 malloc() with no correspondent free(). This will certainly cause memory leak.

Better think and review the whole zigbee code whenever using new or malloc.

@SuGlider SuGlider self-requested a review March 27, 2025 02:55
Copy link
Collaborator

@SuGlider SuGlider left a comment

Choose a reason for hiding this comment

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

From a fast code read, I understand that ZigbeeEP.cpp can cause memory leaks.
It may happen in other code files as well.

I recommend reviewing all places where new or malloc is used.

@me-no-dev me-no-dev marked this pull request as draft March 27, 2025 10:32
@P-R-O-C-H-Y
Copy link
Member Author

Thanks @SuGlider, will take a look.

@P-R-O-C-H-Y P-R-O-C-H-Y added Status: In Progress ⚠️ Issue is in progress and removed Status: Review needed Issue or PR is awaiting review labels Mar 27, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y marked this pull request as ready for review March 27, 2025 14:13
@P-R-O-C-H-Y P-R-O-C-H-Y changed the title feat(zigbee): Add checks on set attributes and commands feat(zigbee): Add check, boolean returns, fix Analog, add optional reset on factoryReset Mar 27, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y requested a review from SuGlider March 27, 2025 14:22
@P-R-O-C-H-Y P-R-O-C-H-Y added Status: Review needed Issue or PR is awaiting review and removed Status: In Progress ⚠️ Issue is in progress labels Mar 27, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y modified the milestones: 3.3.0, 3.2.0 Mar 27, 2025
Copy link
Collaborator

@lucasssvaz lucasssvaz 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-Y P-R-O-C-H-Y force-pushed the feat/zigbee-commands-return-check branch from 909606a to f5e28e1 Compare March 27, 2025 16:02
@P-R-O-C-H-Y
Copy link
Member Author

All done now.

@P-R-O-C-H-Y P-R-O-C-H-Y added Status: Pending Merge Pull Request is ready to be merged and removed Status: Review needed Issue or PR is awaiting review labels Mar 27, 2025
@me-no-dev me-no-dev merged commit a3b6fe6 into espressif:master Mar 27, 2025
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Zigbee Issues and Feature Request about Zigbee Status: Pending Merge Pull Request is ready to be merged
Projects
Development

Successfully merging this pull request may close these issues.

Make Reboot after Factory Reset on an EP optional
4 participants