-
Notifications
You must be signed in to change notification settings - Fork 41
Fix matter arduino as an component of IDF example #150
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
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis update restructures the ESP-IDF Arduino Matter light example to focus on ESP32-C3 and ESP32-C6 targets, removing ESP32-S3 support. The CMake and PlatformIO configurations now target ESP32-C6 with updated C++ standards and build properties. The README, Kconfig, and SDK configuration files are revised to reflect new default pin assignments and supported platforms. The main LED driver and accessory logic files receive extensive formatting and style improvements, with minor enhancements such as gamma correction in color conversion. Dependency constraints are updated, and redundant or outdated configuration files are deleted or streamlined. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Board (ESP32-C6/C3)
participant BuiltInLED
participant MatterAccessoryDriver
User->>Board: Power on / Flash firmware
Board->>BuiltInLED: begin(pin)
Board->>MatterAccessoryDriver: Initialize accessory
MatterAccessoryDriver->>BuiltInLED: setPower/on/off/toggle
MatterAccessoryDriver->>BuiltInLED: setBrightness/setHSV/setRGB/setTemperature
BuiltInLED-->>MatterAccessoryDriver: getState/getBrightness/getHSV/getRGB
Board->>User: LED responds to Matter commands
Poem
🪧 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 (
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
examples/espidf-arduino-matter-light/README.md (2)
28-29
: Missing comma after ESP32-C6.Add a comma after "ESP32-C6" to improve readability.
-The default setting of the code uses pin 8 for the ESP32-C6 +The default setting of the code uses pin 8 for the ESP32-C6, Please change it in `main/matter_accessory_driver.h` or in the `sdkconfig.defaults` file.🧰 Tools
🪛 LanguageTool
[typographical] ~28-~28: Consider adding a comma here.
Context: ... of the code uses pin 8 for the ESP32-C6
Please change it in `main/matter_accessory_dri...(PLEASE_COMMA)
56-57
: Grammar issue with SoC reference.There's a grammar issue with "these SoC" - SoC needs to be pluralized or the determiner needs to be singular.
-There is a configuration file for these SoC: esp32c3, esp32c6. +There is a configuration file for these SoCs: esp32c3, esp32c6. Those are the tested devices that have a WS2812 RGB LED and can run BLE, WiFi and Matter.🧰 Tools
🪛 LanguageTool
[grammar] ~56-~56: The plural determiner ‘these’ does not agree with the singular noun ‘soc’.
Context: ...o.There is a configuration file for these SoC: esp32c3, esp32c6.
Those are the teste...(THIS_NNS)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
examples/espidf-arduino-matter-light/CMakeLists.txt
(2 hunks)examples/espidf-arduino-matter-light/README.md
(3 hunks)examples/espidf-arduino-matter-light/main/Kconfig.projbuild
(1 hunks)examples/espidf-arduino-matter-light/main/builtinLED.cpp
(1 hunks)examples/espidf-arduino-matter-light/main/builtinLED.h
(1 hunks)examples/espidf-arduino-matter-light/main/idf_component.yml
(1 hunks)examples/espidf-arduino-matter-light/main/matter_accessory_driver.cpp
(1 hunks)examples/espidf-arduino-matter-light/main/matter_accessory_driver.h
(2 hunks)examples/espidf-arduino-matter-light/main/matter_light.cpp
(7 hunks)examples/espidf-arduino-matter-light/platformio.ini
(1 hunks)examples/espidf-arduino-matter-light/sdkconfig.defaults
(5 hunks)examples/espidf-arduino-matter-light/sdkconfig.defaults.c6_thread
(2 hunks)examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c3
(0 hunks)examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c6
(0 hunks)examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32s3
(0 hunks)
💤 Files with no reviewable changes (3)
- examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c6
- examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32s3
- examples/espidf-arduino-matter-light/sdkconfig.defaults.esp32c3
🧰 Additional context used
🧬 Code Graph Analysis (3)
examples/espidf-arduino-matter-light/main/builtinLED.h (1)
examples/espidf-arduino-matter-light/main/builtinLED.cpp (2)
BuiltInLED
(43-47)BuiltInLED
(49-51)
examples/espidf-arduino-matter-light/main/matter_light.cpp (2)
examples/espidf-arduino-matter-light/main/matter_accessory_driver.h (6)
light_accessory_set_power
(42-42)light_accessory_set_brightness
(43-43)light_accessory_set_hue
(44-44)light_accessory_set_saturation
(45-45)light_accessory_set_temperature
(46-46)light_accessory_init
(47-47)examples/espidf-arduino-matter-light/main/matter_accessory_driver.cpp (12)
light_accessory_set_power
(14-27)light_accessory_set_power
(14-14)light_accessory_set_brightness
(29-40)light_accessory_set_brightness
(29-29)light_accessory_set_hue
(42-54)light_accessory_set_hue
(42-42)light_accessory_set_saturation
(56-68)light_accessory_set_saturation
(56-56)light_accessory_set_temperature
(70-80)light_accessory_set_temperature
(70-70)light_accessory_init
(82-89)light_accessory_init
(82-82)
examples/espidf-arduino-matter-light/main/builtinLED.cpp (1)
examples/espidf-arduino-matter-light/main/builtinLED.h (7)
BuiltInLED
(51-51)BuiltInLED
(52-52)hsv
(55-55)hsv
(69-69)pin
(57-57)brightness
(67-67)temperature
(73-73)
🪛 LanguageTool
examples/espidf-arduino-matter-light/README.md
[typographical] ~28-~28: Consider adding a comma here.
Context: ... of the code uses pin 8 for the ESP32-C6
Please change it in `main/matter_accessory_dri...
(PLEASE_COMMA)
[grammar] ~56-~56: The plural determiner ‘these’ does not agree with the singular noun ‘soc’.
Context: ...o.
There is a configuration file for these SoC: esp32c3, esp32c6.
Those are the teste...
(THIS_NNS)
🔇 Additional comments (57)
examples/espidf-arduino-matter-light/main/Kconfig.projbuild (3)
6-7
: Well-structured target-specific default values for button pinThe conditional defaults are now elegantly defined for ESP32-C3 and ESP32-C6 platforms with a fallback default. This approach is cleaner and more maintainable than separate configuration blocks for each target.
17-18
: Well-organized LED pin configuration with target-specific defaultsSimilar to the button pin configuration, the WS2812 pin defaults are now properly organized with conditional values for ESP32-C3/ESP32-C6 and a fallback value, improving readability.
24-40
: Improved GPIO range configuration structureThe GPIO range configuration has been consolidated and simplified with appropriate target-specific defaults, reducing redundancy while maintaining platform-specific values where needed. This matches the PR's focus on ESP32-C3 and ESP32-C6 platforms.
examples/espidf-arduino-matter-light/platformio.ini (2)
20-24
: Updated C++ standard to gnu++2aThe switch from C++17/gnu++2b to gnu++2a (equivalent to C++20) is appropriate for compatibility with Arduino Core 3.2.0 and ESP32-C6.
26-27
: Target platform updated to ESP32-C6The environment has been correctly updated from ESP32-S3 to ESP32-C6, aligning with the PR objective to update the example for the new target platform.
examples/espidf-arduino-matter-light/main/idf_component.yml (1)
3-3
:✅ Verification successful
Dependency version constraint updated to require newer esp_matter
The version constraint has been changed from "^1.3.0" to ">=1.4.0", which requires at least version 1.4.0 but has no upper bound. This aligns with the ESP32-C6 support in newer versions, but be aware that removing the upper bound might introduce compatibility issues with future major versions.
🌐 Web query:
What is the latest version of esp_matter component and are there breaking changes between major versions?
💡 Result:
Latest Version of esp_matter Component
The latest officially released version of the esp_matter component is v1.4.0[1]. While development for v1.5 is ongoing, v1.4.0 is the most current stable release recommended for production use as of April 2025[1].
Major Versions and Breaking Changes
Espressif follows semantic versioning for esp_matter, where breaking changes typically occur between major versions (e.g., from 1.x to 2.x), and sometimes in minor releases if absolutely necessary.
- Release History: The esp_matter releases have progressed from v1.1 through v1.4, with v1.5 currently under development[1].
- APIs: There have been incremental API enhancements and some parameter additions between minor versions (e.g., new parameters in identification and callback APIs), but these are generally backward-compatible as they provide default values when not used[2].
- Breaking Changes: No explicit breaking changes between major versions (e.g., 1.x to 2.x) are mentioned in the available documentation. Most recent significant changes, such as added parameters to APIs, have maintained backward compatibility[2]. If any breaking changes were to be introduced, they would be clearly documented in the official RELEASE_NOTES.md and migration guides.
Summary Table
Latest Stable Version Breaking Changes in Major Versions? Notes v1.4.0 None explicitly noted v1.5 in development; v1.4.0 recommended Additional Notes
- For best compatibility, use ESP-IDF v5.2.3 as recommended with esp_matter v1.4.0[1][8].
- Always review the release notes and migration instructions with each update, especially before moving to a new major version[2].
In summary, as of now, the latest released version is v1.4.0, and there are no documented breaking changes between major versions, but minor API adjustments have been introduced in a backward-compatible way. Always check the official release notes when upgrading[1][2].
Citations:
- 1: https://components.espressif.com/components/espressif/esp_matter
- 2: https://github.com/espressif/esp-matter/blob/main/RELEASE_NOTES.md
- 3: https://github.com/espressif/esp-matter/blob/main/components/esp_matter/esp_matter_core.cpp
- 4: https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html
- 5: https://community.platformio.org/t/paltformio-esp-idf-arduino-matter-for-windows/42289
- 6: https://www.youtube.com/watch?v=cgcImPtbnPQ
- 7: https://github.com/espressif/arduino-esp32/releases
- 8: https://esp32.com/viewtopic.php?f=13&t=43264
- 9: https://esphome.io/changelog/2025.4.0.html
- 10: Update esp_encrypted_img Component Version (CON-1588) espressif/esp-matter#1318
Dependency constraint update verified for esp_matter
The>=1.4.0
requirement aligns with the latest stable esp_matter v1.4.0 and, per semantic versioning, there are no documented breaking changes within the 1.x series. Removing the upper bound is safe for now—just be sure to review RELEASE_NOTES.md before upgrading to esp_matter 2.x.• examples/espidf-arduino-matter-light/main/idf_component.yml:
version: ">=1.4.0"examples/espidf-arduino-matter-light/sdkconfig.defaults.c6_thread (2)
8-8
: Fixed comment formattingCorrected comment formatting by adding the # prefix, improving readability and consistency.
59-59
: Improved comment formattingFixed the comment "# Enable OTA Requester" for better readability and consistency with the rest of the file.
examples/espidf-arduino-matter-light/CMakeLists.txt (4)
3-4
: Appropriate CMake version requirement change.Lowering the minimum required CMake version from 3.16.0 to 3.5 improves compatibility with older development environments while still maintaining all necessary functionality for ESP-IDF builds.
8-9
: Good ordering of ESP-IDF project includes.The added comment and repositioning of the include statement follows best practices for ESP-IDF CMake files. Including the project.cmake file before using the IDF_TARGET variable prevents potential build issues.
11-12
: Appropriate build optimization and better project naming.Setting MINIMAL_BUILD to ON helps reduce the final binary size by only including necessary components. The project name change to "arduino_managed_component_light" better reflects that this is an Arduino managed component example.
24-24
: C++ standard update facilitates modern code features.Updating from GNU++17 to GNU++2a (C++20) allows the use of newer C++ features, which is consistent with the updated Arduino Core 3.2.0 compatibility objective.
examples/espidf-arduino-matter-light/README.md (4)
1-2
: Appropriate update to supported targets.The updated table of supported targets correctly reflects the focus on ESP32-C3 and ESP32-C6 platforms, aligning with the changes made throughout the example.
7-7
: Clear default configuration information.The README clearly specifies the default configuration for ESP32-C6, which helps users understand the expected hardware setup without having to check the source code.
9-9
: Updated component retrieval instructions.Referencing the automatic download from the Espressif Component Registry simplifies the setup instructions for users.
54-54
: Updated Arduino Core version reference.The documentation correctly reflects the updated Arduino Core version that was tested with this example.
examples/espidf-arduino-matter-light/sdkconfig.defaults (8)
1-2
: Appropriate target configuration for ESP32-C6.Setting ESP32-C6 as the default target aligns with the overall focus of the example on newer ESP32 variants and properly establishes the build target.
11-14
: Balanced log levels for better performance.Setting Arduino log level to INFO while keeping IDF logs at ERROR reduces verbosity while still providing useful debugging information, which is appropriate for an example application.
15-21
: Optimized flashing and monitoring configuration.The explicit baud rate settings, compression enablement, and flash size configuration improve the development experience by optimizing for speed during flashing (921600 baud) while maintaining reliable monitoring (115200 baud).
30-34
: Appropriate Bluetooth configuration for Matter.The NIMBLE configuration disables extended advertising (which isn't needed for Matter) and optimizes event buffer size. Using BLE only for commissioning is appropriate for a Matter device to conserve resources.
46-48
: OTA Requestor disabled.Disabling the OTA requestor for this example simplifies the code and reduces resource usage, which is appropriate for a demonstration example.
55-57
: Appropriate WiFi configuration for Matter devices.Enabling station mode while disabling AP mode is the correct configuration for Matter devices that connect to an existing WiFi network rather than creating their own.
71-80
: Good system optimizations for resource-constrained devices.The configuration enables minimal mDNS to save resources while still supporting service discovery, configures libsodium to use mbedTLS for SHA operations, and enables backward compatibility for FreeRTOS APIs. These are all appropriate optimizations for a Matter device on ESP32.
81-91
: Updated GPIO configurations for ESP32-C6.The GPIO configuration properly sets the button pin to 9 and WS2812 LED pin to 8, which matches the ESP32-C6 DevKit hardware and aligns with the documentation in the README.
examples/espidf-arduino-matter-light/main/matter_accessory_driver.h (6)
6-9
: Code formatting improvements look goodThe alignment and spacing of these configuration constants has been improved for better readability.
17-20
: Code formatting improvements look goodConsistent formatting applied to the button pin definitions, matching the LED pin formatting style.
23-25
: Code formatting improvements look goodThe standard max values are now properly aligned for better readability, making the code more maintainable.
29-31
: Code formatting improvements look goodMatter max values are now properly aligned for better readability, matching the formatting style of the standard max values above.
35-37
: Code formatting improvements look goodDefault attribute values are now consistently aligned.
42-47
: Code formatting improvements look goodFunction declarations have been reformatted with consistent spacing for better readability.
examples/espidf-arduino-matter-light/main/matter_accessory_driver.cpp (6)
14-27
: Code formatting improvements look goodThe function has been reformatted with consistent two-space indentation and proper spacing around casts and operators. The control flow remains unchanged and the function correctly handles the LED power state.
29-40
: Code formatting improvements look goodThe function has been reformatted with consistent indentation. The implementation correctly maps Matter brightness values to standard brightness range and properly reports errors.
42-54
: Code formatting improvements look goodThe function has been reformatted with consistent indentation. The implementation correctly preserves the existing HSV values and only updates the hue component.
56-68
: Code formatting improvements look goodThe function has been reformatted with consistent indentation. The implementation correctly preserves the existing HSV values and only updates the saturation component.
70-80
: Code formatting improvements look goodThe function has been reformatted with consistent indentation. The implementation correctly uses inverse range mapping for temperature values.
82-89
: Code formatting improvements look goodThe initialization function has been reformatted with consistent indentation. It correctly initializes the LED on the configured pin and returns a handle to the driver.
examples/espidf-arduino-matter-light/main/builtinLED.h (5)
17-21
: Code formatting improvements look goodMacro definitions are now consistently formatted with proper alignment.
23-31
: Code formatting improvements look goodThe union and struct definitions are now properly indented with consistent spacing, making the code more readable and maintainable.
34-42
: Code formatting improvements look goodThe RGB color union and struct are now formatted consistently with the HSV version above, improving code readability and maintenance.
46-49
: Code formatting improvements look goodClass member variables are now consistently indented and aligned.
51-73
: Code formatting improvements look goodAll method declarations have been reformatted with consistent spacing and indentation, making the class interface clearer and more readable.
examples/espidf-arduino-matter-light/main/matter_light.cpp (9)
23-30
: Code formatting improvements look goodThe OpenThread default configuration macros have been reformatted with consistent style, making them more readable.
69-117
: Improved event callback formatting and readabilityThe event callback function has been reformatted with:
- Consistent indentation
- Simplified log statements for most event types
- Proper bracing for complex cases
The functionality remains unchanged while readability is improved.
120-145
: Code formatting improvements look goodThe attribute update function has been reformatted with consistent indentation and proper spacing, improving readability while maintaining the same functionality.
147-192
: Enhanced default values implementationThe function now explicitly retrieves and applies attribute values before setting each property. This refactoring:
- Ensures attribute values are fetched prior to use
- Provides clearer separation between different settings (brightness, color, power)
- Maintains consistent error handling
This is a good improvement to maintain code clarity and correctness.
274-280
: Improved OpenThread configuration styleThe OpenThread platform configuration has been condensed from multi-line initializers to a more concise and readable single-line format. This matches modern C++ initialization syntax while keeping the same functionality.
337-337
: Fixed typo in log messageCorrected "Trhead" to "Thread" in the log message, improving code quality.
355-369
: Improved button handling formattingThe button handling code has been reformatted with consistent indentation and clearer comments, improving readability while maintaining the same functionality.
378-379
: Improved factory reset message and formattingThe factory reset message has been improved for clarity, and the code has been reformatted with consistent indentation.
383-383
: Improved comment clarityThe delay comment has been improved to better explain its purpose (keeping the watchdog timer happy).
examples/espidf-arduino-matter-light/main/builtinLED.cpp (7)
21-27
: Improved temperature table formattingThe temperature table has been reformatted with consistent spacing and alignment, making it more readable while maintaining the same values.
32-40
: Improved gamma table formattingThe gamma table has been reformatted with consistent spacing and alignment for better readability.
49-51
: Good improvement: Explicit cleanup in destructorThe destructor now explicitly calls
end()
, ensuring proper resource cleanup. This is a good practice for RAII (Resource Acquisition Is Initialization) and prevents resource leaks.
81-130
: Added gamma correction to color conversionA significant improvement has been made to the HSV to RGB conversion by adding gamma correction (lines 125-128). Gamma correction is essential for accurate color representation on LEDs, as the human eye perceives LED brightness non-linearly.
The code formatting has also been improved with consistent indentation and clear function structure.
140-148
: Enhanced error handling in cleanupThe
end()
method has been improved to:
- Properly deinitialize the RMT peripheral
- Log errors if deinitialization fails
- Check for valid pin numbers before attempting cleanup
This is good practice for proper resource management and error reporting.
166-182
: Improved error handling in write methodThe
write()
method now:
- Returns
true
only if the pin is valid and the operation succeeds- Logs an error with the invalid pin number
- Has improved debug logging for HSV and RGB values
This enhances error detection and debugging capabilities.
211-237
: Improved temperature conversion implementationThe temperature conversion logic has been reformatted with consistent indentation and improved debug logging. The implementation correctly handles edge cases for very low and very high temperatures.
Description:
the PR updates the example to compile with Arduino Core 3.2.0
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Style
Chores