Skip to content

feat(matter): Adds Matter Events callback plus example #11465

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented Jun 13, 2025

Description of Change

Adds a new feature to ESP32 Arduino Matter Library that allows users to add a Matter Event Callback function.
All possible ESP32 Matter Events are covered in this implementation.

An example sketch is provided.

Tests scenarios

Using the provided example sketch.

Related links

None

@SuGlider SuGlider self-assigned this Jun 13, 2025
@SuGlider SuGlider requested a review from lucasssvaz as a code owner June 13, 2025 14:59
Copy link
Contributor

github-actions bot commented Jun 13, 2025

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello SuGlider, 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.
- 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 4b3f58f

Copy link
Contributor

github-actions bot commented Jun 13, 2025

Test Results

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

Results for commit 4b3f58f.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Jun 13, 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
ESP32S30⚠️ +1560.00⚠️ +0.010⚠️ +160.00⚠️ +0.02
ESP32S20⚠️ +1560.00⚠️ +0.010⚠️ +160.00⚠️ +0.02
ESP32C30⚠️ +1400.00⚠️ +0.010⚠️ +160.00⚠️ +0.02
ESP32C60⚠️ +1400.00⚠️ +0.010⚠️ +160.00⚠️ +0.02
ESP320⚠️ +1600.00⚠️ +0.010⚠️ +160.00⚠️ +0.02
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32S3ESP32S2ESP32C3ESP32C6ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
libraries/Matter/examples/MatterColorLight⚠️ +148⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +140⚠️ +16
libraries/Matter/examples/MatterCommissionTest⚠️ +152⚠️ +16⚠️ +156⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +160⚠️ +16
libraries/Matter/examples/MatterComposedLights⚠️ +148⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +148⚠️ +16
libraries/Matter/examples/MatterContactSensor⚠️ +152⚠️ +16⚠️ +156⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +156⚠️ +16
libraries/Matter/examples/MatterDimmableLight⚠️ +144⚠️ +16⚠️ +148⚠️ +16⚠️ +136⚠️ +16⚠️ +136⚠️ +16⚠️ +148⚠️ +16
libraries/Matter/examples/MatterEnhancedColorLight⚠️ +128⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +148⚠️ +16
libraries/Matter/examples/MatterEvents----------
libraries/Matter/examples/MatterFan⚠️ +152⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +152⚠️ +16
libraries/Matter/examples/MatterHumiditySensor⚠️ +148⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +152⚠️ +16
libraries/Matter/examples/MatterMinimum⚠️ +152⚠️ +16⚠️ +156⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +148⚠️ +16
libraries/Matter/examples/MatterOccupancySensor⚠️ +148⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +152⚠️ +16
libraries/Matter/examples/MatterOnIdentify⚠️ +148⚠️ +16⚠️ +144⚠️ +16⚠️ +138⚠️ +16⚠️ +138⚠️ +16⚠️ +144⚠️ +16
libraries/Matter/examples/MatterOnOffLight⚠️ +136⚠️ +16⚠️ +148⚠️ +16⚠️ +138⚠️ +16⚠️ +138⚠️ +16⚠️ +132⚠️ +16
libraries/Matter/examples/MatterOnOffPlugin⚠️ +132⚠️ +16⚠️ +152⚠️ +16⚠️ +140⚠️ +16⚠️ +140⚠️ +16⚠️ +128⚠️ +16
libraries/Matter/examples/MatterPressureSensor⚠️ +148⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +152⚠️ +16
libraries/Matter/examples/MatterSmartButon⚠️ +156⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +148⚠️ +16
libraries/Matter/examples/MatterTemperatureLight⚠️ +148⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +156⚠️ +16
libraries/Matter/examples/MatterTemperatureSensor⚠️ +148⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +152⚠️ +16
libraries/Matter/examples/MatterThermostat⚠️ +152⚠️ +16⚠️ +152⚠️ +16⚠️ +134⚠️ +16⚠️ +136⚠️ +16⚠️ +148⚠️ +16
libraries/Matter/examples/WiFiProvWithinMatter⚠️ +148⚠️ +16⚠️ +148⚠️ +16⚠️ +134⚠️ +16⚠️ +134⚠️ +16⚠️ +148⚠️ +16

@SuGlider SuGlider requested review from lucasssvaz and a team June 13, 2025 16:13
@SuGlider SuGlider added the Area: Matter Issues and Feature Request about Matter Protocol label Jun 13, 2025
@SuGlider SuGlider moved this from Todo to In Review in Arduino ESP32 Core Project Roadmap Jun 13, 2025
@SuGlider SuGlider added this to the 3.2.1 milestone Jun 13, 2025
@SuGlider SuGlider added the Status: Review needed Issue or PR is awaiting review label Jun 13, 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

@@ -38,6 +38,133 @@ using namespace esp_matter;

class ArduinoMatter {
public:
// Matter Event types used when there is a user callback for Matter Events
enum matterEvent_t {
Copy link
Member

Choose a reason for hiding this comment

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

A suggestion: move the enum outside of the class. It will be in line with other events in the core

@P-R-O-C-H-Y P-R-O-C-H-Y requested review from Copilot June 16, 2025 12:01
Copilot

This comment was marked as outdated.

Copilot

This comment was marked as outdated.

@lucasssvaz lucasssvaz requested a review from Copilot June 16, 2025 14:04
Copy link
Contributor

@Copilot Copilot AI 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 Matter Events callback mechanism in the ESP32 Arduino Matter library and provides an example sketch and CI config demonstrating its use.

  • Adds a matterEvent_t enum mapping CHIP DeviceEventType values plus ESP32-specific events.
  • Implements onEvent() to register and invoke a user callback for all Matter events.
  • Supplies a new example project (MatterEvents) and CI settings.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
libraries/Matter/src/MatterEndPoint.h Updated NULL returns/checks to use nullptr for consistency.
libraries/Matter/src/Matter.h Added matterEvent_t enum and onEvent callback API.
libraries/Matter/src/Matter.cpp Defined static callback, invoke it in app_event_cb, and adjusted log level.
libraries/Matter/examples/MatterEvents/ci.json New CI configuration for the MatterEvents example.
libraries/Matter/examples/MatterEvents/MatterEvents.ino New example sketch showcasing event callback usage.
Comments suppressed due to low confidence (2)

libraries/Matter/src/Matter.h:126

  • The MATTER_ESP32_SPECIFIC_EVENT enum entry is documented as starting at 0x9000 but isn’t explicitly assigned that value. Consider initializing it explicitly (e.g., = 0x9000) to ensure it falls in the intended range.
MATTER_ESP32_SPECIFIC_EVENT,  // value is previous + 1

libraries/Matter/src/Matter.cpp:127

  • The new callback invocation logic isn’t covered by existing tests. Consider adding unit or integration tests to verify that onEvent callbacks are registered and invoked correctly.
if (ArduinoMatter::_matterEventCB != nullptr) {

// Commissioning Session Stopped: Signals that Commissioning session has stopped
MATTER_COMMISSIONING_SESSION_STOPPED = (uint16_t) chip::DeviceLayer::DeviceEventType::kCommissioningSessionStopped,

// Commissioning Window Opened: Signals that Commissioning window is now opend
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

Typo in comment: replace "opend" with "opened" for clarity.

Suggested change
// Commissioning Window Opened: Signals that Commissioning window is now opend
// Commissioning Window Opened: Signals that Commissioning window is now opened

Copilot uses AI. Check for mistakes.

Serial.println("====> Decommissioning in 60 seconds. <====");
delay(60000);
Matter.decommission();
Serial.println("Matter Node is decommissioned. Commsssioning widget shall start over.");
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

Typo in string literal: "Commsssioning" should be "Commissioning".

Suggested change
Serial.println("Matter Node is decommissioned. Commsssioning widget shall start over.");
Serial.println("Matter Node is decommissioned. Commissioning widget shall start over.");

Copilot uses AI. Check for mistakes.

@espressif espressif deleted a comment from Copilot AI Jun 16, 2025
@espressif espressif deleted a comment from Copilot AI Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Matter Issues and Feature Request about Matter Protocol Status: Review needed Issue or PR is awaiting review
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

4 participants