From c3866bb10d89f7997f93d7aec3afec23c82cc262 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 22 Nov 2024 13:16:38 -0300 Subject: [PATCH 01/11] feat(matter): add a new example for a minimum matter device --- .../examples/MatterMinimum/MatterMinimum.ino | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 libraries/Matter/examples/MatterMinimum/MatterMinimum.ino diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino new file mode 100644 index 00000000000..e8526840224 --- /dev/null +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -0,0 +1,60 @@ +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* + * This example ha the smallest code that will create a Matter Device which can be + * commissioned and controlled from a Matter Environment APP. + * It doesn't control any light, but the ESP32 will send debug messages indicating the Matter activity. + * Therefore, turning DEBUG Level may be useful to follow Matter Accessory and Controller messages. + */ + +// Matter Manager +#include +#include + +// List of Matter Endpoints for this Node +// Single On/Off Light Endpoint - at least one per node +MatterOnOffLight OnOffLight; + +// WiFi is manually set and started +const char *ssid = "your-ssid"; // Change this to your WiFi SSID +const char *password = "your-password"; // Change this to your WiFi password + +void setup() { + WiFi.enableIPv6(true); + // Manually connect to WiFi + WiFi.begin(ssid, password); + // Wait for connection + while (WiFi.status() != WL_CONNECTED) { + delay(500); + } + + // Initialize at least one Matter EndPoint + OnOffLight.begin(); + + // Matter beginning - Last step, after all EndPoints are initialized + Matter.begin(); + + if (!Matter.isDeviceCommissioned()) { + log_i("Matter Node is not commissioned yet."); + log_i("Initiate the device discovery in your Matter environment."); + log_i("Commission it to your Matter hub with the manual pairing code or QR code"); + log_i("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str()); + log_i("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str()); + } +} + +void loop() { + delay(500); +} From 86a02c59b7ad53f45508bafe6d98b8e0a67027e6 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 22 Nov 2024 13:17:27 -0300 Subject: [PATCH 02/11] feat(matter): create ci.json necessary for ci testing --- libraries/Matter/examples/MatterMinimum/ci.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 libraries/Matter/examples/MatterMinimum/ci.json diff --git a/libraries/Matter/examples/MatterMinimum/ci.json b/libraries/Matter/examples/MatterMinimum/ci.json new file mode 100644 index 00000000000..556a8a9ee6b --- /dev/null +++ b/libraries/Matter/examples/MatterMinimum/ci.json @@ -0,0 +1,7 @@ +{ + "fqbn_append": "PartitionScheme=huge_app", + "requires": [ + "CONFIG_SOC_WIFI_SUPPORTED=y", + "CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y" + ] +} From b0bbf2acb412f0b9e7b378c6e7063103cb0d88a7 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 22 Nov 2024 14:02:40 -0300 Subject: [PATCH 03/11] feat(matter): simple type correction in commentary --- libraries/Matter/examples/MatterMinimum/MatterMinimum.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index e8526840224..d8814c7aea8 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -13,7 +13,7 @@ // limitations under the License. /* - * This example ha the smallest code that will create a Matter Device which can be + * This example is the smallest code that will create a Matter Device which can be * commissioned and controlled from a Matter Environment APP. * It doesn't control any light, but the ESP32 will send debug messages indicating the Matter activity. * Therefore, turning DEBUG Level may be useful to follow Matter Accessory and Controller messages. From 4eece9b41e449b475c1a3e9f1042834361962324 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 22 Nov 2024 14:18:42 -0300 Subject: [PATCH 04/11] feat(matter): add minimum matter ednpoint action to example --- .../examples/MatterMinimum/MatterMinimum.ino | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index d8814c7aea8..8fbef05b183 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -27,11 +27,28 @@ // Single On/Off Light Endpoint - at least one per node MatterOnOffLight OnOffLight; +// Light GPIO that can be controlled by Matter APP +#ifdef LED_BUILTIN +const uint8_t ledPin = LED_BUILTIN; +#else +const uint8_t ledPin = 2; // Set your pin here if your board has not defined LED_BUILTIN +#endif + +// Matter Protocol Endpoint (On/OFF Light) Callback +bool matterCB(bool state) { + digitalWrite(ledPin, state ? HIGH : LOW); + // This callback must return the success state to Matter core + return true; +} + // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID const char *password = "your-password"; // Change this to your WiFi password void setup() { + // Initialise the LED GPIO + pinMode(ledPin, OUTPUT); + WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); @@ -43,6 +60,9 @@ void setup() { // Initialize at least one Matter EndPoint OnOffLight.begin(); + // Associate a callback to the Matter Controller + OnOffLight.onChange(matterCB); + // Matter beginning - Last step, after all EndPoints are initialized Matter.begin(); From 584b485af230cee87ae363848ce87f08c799b41a Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 22 Nov 2024 14:27:50 -0300 Subject: [PATCH 05/11] fix(matter): commentaty update based on code change --- libraries/Matter/examples/MatterMinimum/MatterMinimum.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index 8fbef05b183..cf747aef3a0 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -15,7 +15,7 @@ /* * This example is the smallest code that will create a Matter Device which can be * commissioned and controlled from a Matter Environment APP. - * It doesn't control any light, but the ESP32 will send debug messages indicating the Matter activity. + * It controls a GPIO that may be used as LED, additionally the ESP32 will send debug messages indicating the Matter activity. * Therefore, turning DEBUG Level may be useful to follow Matter Accessory and Controller messages. */ From 54c01fa9d3420a0d07d6032ef7f124ed75314197 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 22 Nov 2024 14:28:29 -0300 Subject: [PATCH 06/11] feat(matter): simple correction in commentary based on code change --- libraries/Matter/examples/MatterMinimum/MatterMinimum.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index cf747aef3a0..e83ffddf571 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -16,7 +16,7 @@ * This example is the smallest code that will create a Matter Device which can be * commissioned and controlled from a Matter Environment APP. * It controls a GPIO that may be used as LED, additionally the ESP32 will send debug messages indicating the Matter activity. - * Therefore, turning DEBUG Level may be useful to follow Matter Accessory and Controller messages. + * Turning DEBUG Level may be useful to follow Matter Accessory and Controller messages. */ // Matter Manager From 157b7842c4dbb76bc48e6f90201145c7332a4e42 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 22 Nov 2024 14:31:16 -0300 Subject: [PATCH 07/11] feat(matter): better commentary about the GPIO. --- libraries/Matter/examples/MatterMinimum/MatterMinimum.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index e83ffddf571..84f1b555ed5 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -15,7 +15,7 @@ /* * This example is the smallest code that will create a Matter Device which can be * commissioned and controlled from a Matter Environment APP. - * It controls a GPIO that may be used as LED, additionally the ESP32 will send debug messages indicating the Matter activity. + * It controls a GPIO, that could be attached to a LED. Additionally the ESP32 will send debug messages indicating the Matter activity. * Turning DEBUG Level may be useful to follow Matter Accessory and Controller messages. */ From 453d4065d281372ce187241692e8502d0899f426 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 22 Nov 2024 14:32:38 -0300 Subject: [PATCH 08/11] feat(matter): clearer commentary and formatting. --- libraries/Matter/examples/MatterMinimum/MatterMinimum.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index 84f1b555ed5..dac924514a1 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -15,7 +15,8 @@ /* * This example is the smallest code that will create a Matter Device which can be * commissioned and controlled from a Matter Environment APP. - * It controls a GPIO, that could be attached to a LED. Additionally the ESP32 will send debug messages indicating the Matter activity. + * It controls a GPIO that could be attached to a LED for visualization. + * Additionally the ESP32 will send debug messages indicating the Matter activity. * Turning DEBUG Level may be useful to follow Matter Accessory and Controller messages. */ From ab28c4c247dfa4468804a0cf3b88bbd6d7d980cd Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Fri, 22 Nov 2024 14:34:08 -0300 Subject: [PATCH 09/11] feat(matter): commentary change based on code change --- libraries/Matter/examples/MatterMinimum/MatterMinimum.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index dac924514a1..1f1b8c6796f 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -17,7 +17,7 @@ * commissioned and controlled from a Matter Environment APP. * It controls a GPIO that could be attached to a LED for visualization. * Additionally the ESP32 will send debug messages indicating the Matter activity. - * Turning DEBUG Level may be useful to follow Matter Accessory and Controller messages. + * Turning DEBUG Level ON may be useful to following Matter Accessory and Controller messages. */ // Matter Manager From 3c2fd00e8e7ef4c9bd200f484c2a4072dda93a8b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sat, 23 Nov 2024 03:41:08 +0000 Subject: [PATCH 10/11] ci(pre-commit): Apply automatic fixes --- libraries/Matter/examples/MatterMinimum/MatterMinimum.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index 1f1b8c6796f..d0217eda03c 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -49,7 +49,7 @@ const char *password = "your-password"; // Change this to your WiFi password void setup() { // Initialise the LED GPIO pinMode(ledPin, OUTPUT); - + WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); From 73ffd5e37caeb4e0de2b9ea5e0e96cc5f96e2712 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Sat, 23 Nov 2024 15:16:30 -0300 Subject: [PATCH 11/11] fix(matter): codespell ci commentary fixed --- libraries/Matter/examples/MatterMinimum/MatterMinimum.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index d0217eda03c..719c91db23b 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -47,7 +47,7 @@ const char *ssid = "your-ssid"; // Change this to your WiFi SSID const char *password = "your-password"; // Change this to your WiFi password void setup() { - // Initialise the LED GPIO + // Initialize the LED GPIO pinMode(ledPin, OUTPUT); WiFi.enableIPv6(true);