From e9f1b928bf5fd28a39c27474906611741fbc543d Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 22:23:52 -0300 Subject: [PATCH 1/3] feat(matter_examples): apply boot button change to all examples --- .../MatterColorLight.ino} | 7 +- .../ci.json | 0 .../MatterComposedLights.ino | 72 ++++++++++++++----- .../MatterDimmableLight.ino | 7 +- .../MatterEnhancedColorLight.ino | 7 +- .../Matter/examples/MatterFan/MatterFan.ino | 12 +++- .../examples/MatterMinimum/MatterMinimum.ino | 35 ++++++++- .../MatterOnOffLight/MatterOnOffLight.ino | 7 +- .../MatterSmartButon/MatterSmartButon.ino | 9 ++- .../MatterTemperatureLight.ino} | 7 +- .../ci.json | 0 .../MatterTemperatureSensor.ino | 39 +++++++++- .../WiFiProvWithinMatter.ino | 36 +++++++++- 13 files changed, 206 insertions(+), 32 deletions(-) rename libraries/Matter/examples/{Matter_ColorLight/Matter_ColorLight.ino => MatterColorLight/MatterColorLight.ino} (97%) rename libraries/Matter/examples/{Matter_ColorLight => MatterColorLight}/ci.json (100%) rename libraries/Matter/examples/{Matter_CW_WW_Light/Matter_CW_WW_Light.ino => MatterTemperatureLight/MatterTemperatureLight.ino} (97%) rename libraries/Matter/examples/{Matter_CW_WW_Light => MatterTemperatureLight}/ci.json (100%) diff --git a/libraries/Matter/examples/Matter_ColorLight/Matter_ColorLight.ino b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino similarity index 97% rename from libraries/Matter/examples/Matter_ColorLight/Matter_ColorLight.ino rename to libraries/Matter/examples/MatterColorLight/MatterColorLight.ino index 2b9c4e4033a..eb68dd09cfc 100644 --- a/libraries/Matter/examples/Matter_ColorLight/Matter_ColorLight.ino +++ b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino @@ -35,7 +35,12 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -const uint8_t buttonPin = 0; // Set your pin here. Using BOOT Button. C6/C3 use GPIO9. +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID diff --git a/libraries/Matter/examples/Matter_ColorLight/ci.json b/libraries/Matter/examples/MatterColorLight/ci.json similarity index 100% rename from libraries/Matter/examples/Matter_ColorLight/ci.json rename to libraries/Matter/examples/MatterColorLight/ci.json diff --git a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino index 85fcd9e8973..3ed35b55181 100644 --- a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino +++ b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino @@ -18,31 +18,42 @@ // List of Matter Endpoints for this Node // There will be 3 On/Off Light Endpoints in the same Node -MatterOnOffLight OnOffLight1; -MatterOnOffLight OnOffLight2; -MatterOnOffLight OnOffLight3; +MatterOnOffLight Light1; +MatterDimmableLight Light2; +MatterColorLight Light3; // 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 +// set your board USER BUTTON pin here - USED to decommission the Matter Node +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif + // Matter Protocol Endpoint Callback for each Light Accessory bool setLightOnOff1(bool state) { - Serial.printf("CB-Light1 changed state to: %s\r\n", state ? "ON" : "OFF"); + Serial.printf("Light1 changed state to: %s\r\n", state ? "ON" : "OFF"); return true; } bool setLightOnOff2(bool state) { - Serial.printf("CB-Light2 changed state to: %s\r\n", state ? "ON" : "OFF"); + Serial.printf("Light2 changed state to: %s\r\n", state ? "ON" : "OFF"); return true; } bool setLightOnOff3(bool state) { - Serial.printf("CB-Light3 changed state to: %s\r\n", state ? "ON" : "OFF"); + Serial.printf("Light3 changed state to: %s\r\n", state ? "ON" : "OFF"); return true; } void setup() { + // Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node + pinMode(buttonPin, INPUT_PULLUP); + Serial.begin(115200); while (!Serial) { delay(100); @@ -60,23 +71,29 @@ void setup() { delay(500); Serial.print("."); } - Serial.println("\r\nWiFi connected"); + Serial.println(); + Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); delay(500); // Initialize all 3 Matter EndPoints - OnOffLight1.begin(); - OnOffLight2.begin(); - OnOffLight3.begin(); - OnOffLight1.onChange(setLightOnOff1); - OnOffLight2.onChange(setLightOnOff2); - OnOffLight3.onChange(setLightOnOff3); + Light1.begin(); + Light2.begin(); + Light3.begin(); + Light1.onChangeOnOff(setLightOnOff1); + Light2.onChangeOnOff(setLightOnOff2); + Light3.onChangeOnOff(setLightOnOff3); // Matter beginning - Last step, after all EndPoints are initialized Matter.begin(); } +// Button control +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the light + void loop() { // Check Matter Light Commissioning state if (!Matter.isDeviceCommissioned()) { @@ -97,10 +114,29 @@ void loop() { Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use."); } - //displays the Light state every 3 seconds + //displays the Light state every 5 seconds Serial.println("======================"); - Serial.printf("Matter Light #1 is %s\r\n", OnOffLight1.getOnOff() ? "ON" : "OFF"); - Serial.printf("Matter Light #2 is %s\r\n", OnOffLight2.getOnOff() ? "ON" : "OFF"); - Serial.printf("Matter Light #3 is %s\r\n", OnOffLight3.getOnOff() ? "ON" : "OFF"); - delay(3000); + Serial.printf("Matter Light #1 is %s\r\n", Light1.getOnOff() ? "ON" : "OFF"); + Serial.printf("Matter Light #2 is %s\r\n", Light2.getOnOff() ? "ON" : "OFF"); + Serial.printf("Matter Light #3 is %s\r\n", Light3.getOnOff() ? "ON" : "OFF"); + + // Check if the button has been pressed + if (digitalRead(buttonPin) == LOW && !button_state) { + // deals with button debouncing + button_time_stamp = millis(); // record the time while the button is pressed. + button_state = true; // pressed. + } + + // Onboard User Button is used to decommission matter fabric + uint32_t time_diff = millis() - button_time_stamp; + if (button_state && time_diff > decommissioningTimeout && digitalRead(buttonPin) == HIGH) { + button_state = false; // released + // Factory reset is triggered if the button is pressed longer than 10 seconds + if (time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + } + } + + delay(5000); } diff --git a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino index cac511926aa..b6d205c5b58 100644 --- a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino +++ b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino @@ -35,7 +35,12 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -const uint8_t buttonPin = 0; // Set your pin here. Using BOOT Button. C6/C3 use GPIO9. +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID diff --git a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino index afba203b708..5e9766160be 100644 --- a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino +++ b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino @@ -38,7 +38,12 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -const uint8_t buttonPin = 0; // Set your pin here. Using BOOT Button. C6/C3 use GPIO9. +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino index ac26550f2b6..a4a98e765e2 100644 --- a/libraries/Matter/examples/MatterFan/MatterFan.ino +++ b/libraries/Matter/examples/MatterFan/MatterFan.ino @@ -20,8 +20,14 @@ // Fan Endpoint - On/Off control + Speed Percent Control + Fan Modes MatterFan Fan; -// set your board USER BUTTON pin here - used for toggling On/Off -const uint8_t buttonPin = 0; // Set your pin here. Using BOOT Button. C6/C3 use GPIO9. +// set your board USER BUTTON pin here - used for toggling On/Off and decommission the Matter Node +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif + // set your board Analog Pin here - used for changing the Fan speed const uint8_t analogPin = A0; // Analog Pin depends on each board @@ -56,7 +62,7 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) { } void setup() { - // Initialize the USER BUTTON (Boot button) GPIO that will toggle the Fan (On/Off) + // Initialize the USER BUTTON (Boot button) GPIO that will toggle the Fan (On/Off) and decommission the Matter Node pinMode(buttonPin, INPUT_PULLUP); // Initialize the Analog Pin A0 used to read input voltage and to set the Fan speed accordingly pinMode(analogPin, INPUT); diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index 719c91db23b..950acc3e2f7 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -35,6 +35,14 @@ const uint8_t ledPin = LED_BUILTIN; const uint8_t ledPin = 2; // Set your pin here if your board has not defined LED_BUILTIN #endif +// set your board USER BUTTON pin here +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif + // Matter Protocol Endpoint (On/OFF Light) Callback bool matterCB(bool state) { digitalWrite(ledPin, state ? HIGH : LOW); @@ -47,6 +55,8 @@ const char *ssid = "your-ssid"; // Change this to your WiFi SSID const char *password = "your-password"; // Change this to your WiFi password void setup() { + // Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node + pinMode(buttonPin, INPUT_PULLUP); // Initialize the LED GPIO pinMode(ledPin, OUTPUT); @@ -76,6 +86,29 @@ void setup() { } } +// Button control - decommision the Matter Node +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission + void loop() { - delay(500); + // Check if the button has been pressed + if (digitalRead(buttonPin) == LOW && !button_state) { + // deals with button debouncing + button_time_stamp = millis(); // record the time while the button is pressed. + button_state = true; // pressed. + } + + // Onboard User Button is used to decommission matter node + uint32_t time_diff = millis() - button_time_stamp; + if (button_state && time_diff > decommissioningTimeout && digitalRead(buttonPin) == HIGH) { + button_state = false; // released + // Factory reset is triggered if the button is pressed longer than 10 seconds + if (time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + } + } + + delay(5000); } diff --git a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino index 0bdd0eb19b7..e138f0aa077 100644 --- a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino +++ b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino @@ -34,7 +34,12 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -const uint8_t buttonPin = 0; // Set your pin here. Using BOOT Button. C6/C3 use GPIO9. +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID diff --git a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino index 1d71f2123a6..ae5af6add46 100644 --- a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino +++ b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino @@ -21,14 +21,19 @@ MatterGenericSwitch SmartButton; // set your board USER BUTTON pin here -const uint8_t buttonPin = 0; // Set your pin here. Using BOOT Button. C6/C3 use GPIO9. +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif // 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() { - // Initialize the USER BUTTON (Boot button) GPIO that will act as a toggle switch + // Initialize the USER BUTTON (Boot button) GPIO that will act as a smart button or to decommission the Matter Node pinMode(buttonPin, INPUT_PULLUP); Serial.begin(115200); diff --git a/libraries/Matter/examples/Matter_CW_WW_Light/Matter_CW_WW_Light.ino b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino similarity index 97% rename from libraries/Matter/examples/Matter_CW_WW_Light/Matter_CW_WW_Light.ino rename to libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino index 0ff30f53ec0..4953d5383b4 100644 --- a/libraries/Matter/examples/Matter_CW_WW_Light/Matter_CW_WW_Light.ino +++ b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino @@ -36,7 +36,12 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -const uint8_t buttonPin = 0; // Set your pin here. Using BOOT Button. C6/C3 use GPIO9. +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID diff --git a/libraries/Matter/examples/Matter_CW_WW_Light/ci.json b/libraries/Matter/examples/MatterTemperatureLight/ci.json similarity index 100% rename from libraries/Matter/examples/Matter_CW_WW_Light/ci.json rename to libraries/Matter/examples/MatterTemperatureLight/ci.json diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index 216406d6082..a4581c135c3 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -27,6 +27,14 @@ // Matter Temperature Sensor Endpoint MatterTemperatureSensor SimulatedTemperatureSensor; +// set your board USER BUTTON pin here - decommissioning button +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif + // 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 @@ -47,6 +55,9 @@ float getSimulatedTemperature() { } void setup() { + // Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node + pinMode(buttonPin, INPUT_PULLUP); + Serial.begin(115200); // Manually connect to WiFi @@ -85,10 +96,34 @@ void setup() { } } +// Button control - decommision the Matter Node +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission + void loop() { Serial.printf("Current Temperature is %.02f \r\n", SimulatedTemperatureSensor.getTemperature()); + + // Check if the button has been pressed + if (digitalRead(buttonPin) == LOW && !button_state) { + // deals with button debouncing + button_time_stamp = millis(); // record the time while the button is pressed. + button_state = true; // pressed. + } + + // Onboard User Button is used to decommission matter node + uint32_t time_diff = millis() - button_time_stamp; + if (button_state && time_diff > decommissioningTimeout && digitalRead(buttonPin) == HIGH) { + button_state = false; // released + // Factory reset is triggered if the button is pressed longer than 10 seconds + if (time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + } + } + // update the temperature sensor value every 5 seconds - // Matter APP shall display the updated temperature delay(5000); - SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature()); + // Matter APP shall display the updated temperature + SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature()); } diff --git a/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino b/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino index eaf1f5096e5..df46a46242d 100644 --- a/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino +++ b/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino @@ -41,6 +41,14 @@ const uint8_t ledPin = LED_BUILTIN; const uint8_t ledPin = 2; // Set your pin here if your board has not defined LED_BUILTIN #endif +// set your board USER BUTTON pin here +#ifdef BOOT_PIN +const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. +#else +const uint8_t buttonPin = 0; // Set your button pin here. +#warning "Do not forget to set the USER BUTTON pin" +#endif + // Matter Protocol Endpoint (On/OFF Light) Callback bool matterCB(bool state) { digitalWrite(ledPin, state ? HIGH : LOW); @@ -49,6 +57,9 @@ bool matterCB(bool state) { } void setup() { + // Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node + pinMode(buttonPin, INPUT_PULLUP); + Serial.begin(115200); // Initialize the LED GPIO pinMode(ledPin, OUTPUT); @@ -117,6 +128,29 @@ void setup() { } } +// Button control - decommision the Matter Node +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission + void loop() { - delay(500); + // Check if the button has been pressed + if (digitalRead(buttonPin) == LOW && !button_state) { + // deals with button debouncing + button_time_stamp = millis(); // record the time while the button is pressed. + button_state = true; // pressed. + } + + // Onboard User Button is used to decommission matter node + uint32_t time_diff = millis() - button_time_stamp; + if (button_state && time_diff > decommissioningTimeout && digitalRead(buttonPin) == HIGH) { + button_state = false; // released + // Factory reset is triggered if the button is pressed longer than 10 seconds + if (time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + } + } + + delay(5000); } From 1203f2a72c52c09d68487cc58697bf650ea20ce1 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Tue, 10 Dec 2024 15:30:13 -0300 Subject: [PATCH 2/3] feat(matter): adjusts boot button functionality for all examples --- .../MatterColorLight/MatterColorLight.ino | 33 ++++++------- .../MatterComposedLights.ino | 46 +++++++++--------- .../MatterDimmableLight.ino | 33 ++++++------- .../MatterEnhancedColorLight.ino | 29 +++++------ .../Matter/examples/MatterFan/MatterFan.ino | 29 +++++------ .../examples/MatterMinimum/MatterMinimum.ino | 36 +++++++------- .../MatterOnOffLight/MatterOnOffLight.ino | 29 +++++------ .../MatterSmartButon/MatterSmartButon.ino | 27 +++++------ .../MatterTemperatureLight.ino | 29 +++++------ .../MatterTemperatureSensor.ino | 48 ++++++++++--------- .../WiFiProvWithinMatter.ino | 36 +++++++------- 11 files changed, 173 insertions(+), 202 deletions(-) diff --git a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino index eb68dd09cfc..9953e5cce8d 100644 --- a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino +++ b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino @@ -35,12 +35,13 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -#ifdef BOOT_PIN const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -130,11 +131,6 @@ void setup() { ColorLight.updateAccessory(); } } -// Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the light void loop() { // Check Matter Light Commissioning state, which may change during execution of loop() @@ -172,17 +168,18 @@ void loop() { // Onboard User Button is used as a Light toggle switch or to decommission it uint32_t time_diff = millis() - button_time_stamp; - if (button_state && time_diff > debouceTime && digitalRead(buttonPin) == HIGH) { - button_state = false; // released + if (digitalRead(buttonPin) == HIGH && button_state && time_diff > debouceTime) { // Toggle button is released - toggle the light Serial.println("User button released. Toggling Light!"); ColorLight.toggle(); // Matter Controller also can see the change + button_state = false; // released + } - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); - ColorLight = false; // turn the light off - Matter.decommission(); - } + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + ColorLight = false; // turn the light off + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino index 3ed35b55181..a312ad88879 100644 --- a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino +++ b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino @@ -27,12 +27,12 @@ const char *ssid = "your-ssid"; // Change this to your WiFi SSID const char *password = "your-password"; // Change this to your WiFi password // set your board USER BUTTON pin here - USED to decommission the Matter Node -#ifdef BOOT_PIN const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // Matter Protocol Endpoint Callback for each Light Accessory bool setLightOnOff1(bool state) { @@ -89,12 +89,9 @@ void setup() { Matter.begin(); } -// Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the light - void loop() { + static uint32_t timeCounter = 0; + // Check Matter Light Commissioning state if (!Matter.isDeviceCommissioned()) { Serial.println(""); @@ -115,10 +112,12 @@ void loop() { } //displays the Light state every 5 seconds - Serial.println("======================"); - Serial.printf("Matter Light #1 is %s\r\n", Light1.getOnOff() ? "ON" : "OFF"); - Serial.printf("Matter Light #2 is %s\r\n", Light2.getOnOff() ? "ON" : "OFF"); - Serial.printf("Matter Light #3 is %s\r\n", Light3.getOnOff() ? "ON" : "OFF"); + if (!(timeCounter++ % 10)) { // delaying for 500ms x 10 = 5s + Serial.println("======================"); + Serial.printf("Matter Light #1 is %s\r\n", Light1.getOnOff() ? "ON" : "OFF"); + Serial.printf("Matter Light #2 is %s\r\n", Light2.getOnOff() ? "ON" : "OFF"); + Serial.printf("Matter Light #3 is %s\r\n", Light3.getOnOff() ? "ON" : "OFF"); + } // Check if the button has been pressed if (digitalRead(buttonPin) == LOW && !button_state) { @@ -127,16 +126,17 @@ void loop() { button_state = true; // pressed. } - // Onboard User Button is used to decommission matter fabric - uint32_t time_diff = millis() - button_time_stamp; - if (button_state && time_diff > decommissioningTimeout && digitalRead(buttonPin) == HIGH) { + if (digitalRead(buttonPin) == HIGH && button_state) { button_state = false; // released - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); - Matter.decommission(); - } } - delay(5000); + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + uint32_t time_diff = millis() - button_time_stamp; + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + } + + delay(500); } diff --git a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino index b6d205c5b58..f96c11462d6 100644 --- a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino +++ b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino @@ -35,12 +35,13 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -#ifdef BOOT_PIN const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -122,11 +123,6 @@ void setup() { DimmableLight.updateAccessory(); } } -// Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the light void loop() { // Check Matter Light Commissioning state, which may change during execution of loop() @@ -161,17 +157,18 @@ void loop() { // Onboard User Button is used as a Light toggle switch or to decommission it uint32_t time_diff = millis() - button_time_stamp; - if (button_state && time_diff > debouceTime && digitalRead(buttonPin) == HIGH) { - button_state = false; // released + if (digitalRead(buttonPin) == HIGH && button_state && time_diff > debouceTime) { // Toggle button is released - toggle the light Serial.println("User button released. Toggling Light!"); DimmableLight.toggle(); // Matter Controller also can see the change + button_state = false; // released + } - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); - DimmableLight = false; // turn the light off - Matter.decommission(); - } + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + DimmableLight = false; // turn the light off + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino index 5e9766160be..e668a377bc1 100644 --- a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino +++ b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino @@ -38,12 +38,13 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -#ifdef BOOT_PIN const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -152,11 +153,6 @@ void setup() { EnhancedColorLight.updateAccessory(); } } -// Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the light void loop() { // Check Matter Light Commissioning state, which may change during execution of loop() @@ -199,12 +195,13 @@ void loop() { // Toggle button is released - toggle the light Serial.println("User button released. Toggling Light!"); EnhancedColorLight.toggle(); // Matter Controller also can see the change + } - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); - EnhancedColorLight = false; // turn the light off - Matter.decommission(); - } + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + EnhancedColorLight = false; // turn the light off + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino index a4a98e765e2..b2871fb0838 100644 --- a/libraries/Matter/examples/MatterFan/MatterFan.ino +++ b/libraries/Matter/examples/MatterFan/MatterFan.ino @@ -21,13 +21,13 @@ MatterFan Fan; // set your board USER BUTTON pin here - used for toggling On/Off and decommission the Matter Node -#ifdef BOOT_PIN const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif +// Button control +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // set your board Analog Pin here - used for changing the Fan speed const uint8_t analogPin = A0; // Analog Pin depends on each board @@ -146,12 +146,6 @@ void setup() { } } -// Builtin Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the Matter Fabric - void loop() { // Check Matter Accessory Commissioning state, which may change during execution of loop() if (!Matter.isDeviceCommissioned()) { @@ -187,14 +181,15 @@ void loop() { // button is released - toggle Fan On/Off Fan.toggle(); Serial.printf("User button released. Setting the Fan %s.\r\n", Fan > 0 ? "ON" : "OFF"); - - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Generic Switch Matter Accessory. It shall be commissioned again."); - Matter.decommission(); - } } + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Generic Switch Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + } + // checks Analog pin and adjust the speed only if it has changed static int lastRead = 0; // analog values (0..1023) / 103 => mapped into 10 steps (0..9) diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index 950acc3e2f7..5d8849c903f 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -35,13 +35,13 @@ const uint8_t ledPin = LED_BUILTIN; const uint8_t ledPin = 2; // Set your pin here if your board has not defined LED_BUILTIN #endif -// set your board USER BUTTON pin here -#ifdef BOOT_PIN +// set your board USER BUTTON pin here - decommissioning button const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control - decommision the Matter Node +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // Matter Protocol Endpoint (On/OFF Light) Callback bool matterCB(bool state) { @@ -86,11 +86,6 @@ void setup() { } } -// Button control - decommision the Matter Node -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission - void loop() { // Check if the button has been pressed if (digitalRead(buttonPin) == LOW && !button_state) { @@ -99,16 +94,17 @@ void loop() { button_state = true; // pressed. } - // Onboard User Button is used to decommission matter node - uint32_t time_diff = millis() - button_time_stamp; - if (button_state && time_diff > decommissioningTimeout && digitalRead(buttonPin) == HIGH) { + if (digitalRead(buttonPin) == HIGH && button_state) { button_state = false; // released - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); - Matter.decommission(); - } } - delay(5000); + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + uint32_t time_diff = millis() - button_time_stamp; + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + } + + delay(500); } diff --git a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino index e138f0aa077..7c6ff636ae0 100644 --- a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino +++ b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino @@ -34,12 +34,13 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -#ifdef BOOT_PIN const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -102,11 +103,6 @@ void setup() { OnOffLight.updateAccessory(); // configure the Light based on initial state } } -// Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the light void loop() { // Check Matter Light Commissioning state, which may change during execution of loop() @@ -145,12 +141,13 @@ void loop() { // Toggle button is released - toggle the light Serial.println("User button released. Toggling Light!"); OnOffLight.toggle(); // Matter Controller also can see the change + } - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); - OnOffLight.setOnOff(false); // turn the light off - Matter.decommission(); - } + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + OnOffLight.setOnOff(false); // turn the light off + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino index ae5af6add46..21aa13b7570 100644 --- a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino +++ b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino @@ -21,12 +21,13 @@ MatterGenericSwitch SmartButton; // set your board USER BUTTON pin here -#ifdef BOOT_PIN const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -68,11 +69,6 @@ void setup() { Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use."); } } -// Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the Matter Fabric void loop() { // Check Matter Accessory Commissioning state, which may change during execution of loop() @@ -110,11 +106,12 @@ void loop() { Serial.println("User button released. Sending Click to the Matter Controller!"); // Matter Controller will receive an event and, if programmed, it will trigger an action SmartButton.click(); + } - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Generic Switch Matter Accessory. It shall be commissioned again."); - Matter.decommission(); - } + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Generic Switch Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino index 4953d5383b4..f3780356ff7 100644 --- a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino +++ b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino @@ -36,12 +36,13 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE #endif // set your board USER BUTTON pin here -#ifdef BOOT_PIN const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -142,11 +143,6 @@ void setup() { CW_WW_Light.updateAccessory(); } } -// Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the light void loop() { // Check Matter Light Commissioning state, which may change during execution of loop() @@ -189,12 +185,13 @@ void loop() { // Toggle button is released - toggle the light Serial.println("User button released. Toggling Light!"); CW_WW_Light.toggle(); // Matter Controller also can see the change + } - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); - CW_WW_Light = false; // turn the light off - Matter.decommission(); - } + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + CW_WW_Light = false; // turn the light off + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index a4581c135c3..00849ceb122 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -28,12 +28,12 @@ MatterTemperatureSensor SimulatedTemperatureSensor; // set your board USER BUTTON pin here - decommissioning button -#ifdef BOOT_PIN const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control - decommision the Matter Node +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -96,13 +96,17 @@ void setup() { } } -// Button control - decommision the Matter Node -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission - void loop() { - Serial.printf("Current Temperature is %.02f \r\n", SimulatedTemperatureSensor.getTemperature()); + static uint32_t timeCounter = 0; + + // Print the current temperature value every 5s + if (!(timeCounter++ % 10)) { // delaying for 500ms x 10 = 5s + // Print the current temperature value + Serial.printf("Current Temperature is %.02f \r\n", SimulatedTemperatureSensor.getTemperature()); + // Update Temperature from the (Simulated) Hardware Sensor + // Matter APP shall display the updated temperature percent + SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature()); + } // Check if the button has been pressed if (digitalRead(buttonPin) == LOW && !button_state) { @@ -111,19 +115,17 @@ void loop() { button_state = true; // pressed. } - // Onboard User Button is used to decommission matter node - uint32_t time_diff = millis() - button_time_stamp; - if (button_state && time_diff > decommissioningTimeout && digitalRead(buttonPin) == HIGH) { + if (digitalRead(buttonPin) == HIGH && button_state) { button_state = false; // released - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); - Matter.decommission(); - } + } + + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + uint32_t time_diff = millis() - button_time_stamp; + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } - // update the temperature sensor value every 5 seconds - delay(5000); - // Matter APP shall display the updated temperature - SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature()); + delay(500); } diff --git a/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino b/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino index df46a46242d..1671eb06b5b 100644 --- a/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino +++ b/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino @@ -41,13 +41,13 @@ const uint8_t ledPin = LED_BUILTIN; const uint8_t ledPin = 2; // Set your pin here if your board has not defined LED_BUILTIN #endif -// set your board USER BUTTON pin here -#ifdef BOOT_PIN +// set your board USER BUTTON pin here - decommissioning button const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -#else -const uint8_t buttonPin = 0; // Set your button pin here. -#warning "Do not forget to set the USER BUTTON pin" -#endif + +// Button control - decommision the Matter Node +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // Matter Protocol Endpoint (On/OFF Light) Callback bool matterCB(bool state) { @@ -128,11 +128,6 @@ void setup() { } } -// Button control - decommision the Matter Node -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission - void loop() { // Check if the button has been pressed if (digitalRead(buttonPin) == LOW && !button_state) { @@ -141,16 +136,17 @@ void loop() { button_state = true; // pressed. } - // Onboard User Button is used to decommission matter node - uint32_t time_diff = millis() - button_time_stamp; - if (button_state && time_diff > decommissioningTimeout && digitalRead(buttonPin) == HIGH) { + if (digitalRead(buttonPin) == HIGH && button_state) { button_state = false; // released - // Factory reset is triggered if the button is pressed longer than 10 seconds - if (time_diff > decommissioningTimeout) { - Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); - Matter.decommission(); - } } - delay(5000); + // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node + uint32_t time_diff = millis() - button_time_stamp; + if (button_state && time_diff > decommissioningTimeout) { + Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); + Matter.decommission(); + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + } + + delay(500); } From 58da087084571a37c0d953a3924382110b70554f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 21:04:19 +0000 Subject: [PATCH 3/3] ci(pre-commit): Apply automatic fixes --- .../examples/MatterColorLight/MatterColorLight.ino | 12 ++++++------ .../MatterComposedLights/MatterComposedLights.ino | 8 ++++---- .../MatterDimmableLight/MatterDimmableLight.ino | 12 ++++++------ .../MatterEnhancedColorLight.ino | 10 +++++----- libraries/Matter/examples/MatterFan/MatterFan.ino | 12 ++++++------ .../examples/MatterMinimum/MatterMinimum.ino | 8 ++++---- .../examples/MatterOnOffLight/MatterOnOffLight.ino | 10 +++++----- .../examples/MatterSmartButon/MatterSmartButon.ino | 10 +++++----- .../MatterTemperatureLight.ino | 10 +++++----- .../MatterTemperatureSensor.ino | 14 +++++++------- .../WiFiProvWithinMatter/WiFiProvWithinMatter.ino | 8 ++++---- 11 files changed, 57 insertions(+), 57 deletions(-) diff --git a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino index 9953e5cce8d..ea91baef0ea 100644 --- a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino +++ b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino @@ -38,10 +38,10 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -171,7 +171,7 @@ void loop() { if (digitalRead(buttonPin) == HIGH && button_state && time_diff > debouceTime) { // Toggle button is released - toggle the light Serial.println("User button released. Toggling Light!"); - ColorLight.toggle(); // Matter Controller also can see the change + ColorLight.toggle(); // Matter Controller also can see the change button_state = false; // released } @@ -180,6 +180,6 @@ void loop() { Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); ColorLight = false; // turn the light off Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino index a312ad88879..63062ba36a9 100644 --- a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino +++ b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino @@ -30,9 +30,9 @@ const char *password = "your-password"; // Change this to your WiFi password const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // Matter Protocol Endpoint Callback for each Light Accessory bool setLightOnOff1(bool state) { @@ -135,7 +135,7 @@ void loop() { if (button_state && time_diff > decommissioningTimeout) { Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } delay(500); diff --git a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino index f96c11462d6..f1af4f84dfc 100644 --- a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino +++ b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino @@ -38,10 +38,10 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -161,7 +161,7 @@ void loop() { // Toggle button is released - toggle the light Serial.println("User button released. Toggling Light!"); DimmableLight.toggle(); // Matter Controller also can see the change - button_state = false; // released + button_state = false; // released } // Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node @@ -169,6 +169,6 @@ void loop() { Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); DimmableLight = false; // turn the light off Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino index e668a377bc1..eddbd0f2b21 100644 --- a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino +++ b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino @@ -41,10 +41,10 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -202,6 +202,6 @@ void loop() { Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); EnhancedColorLight = false; // turn the light off Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino index b2871fb0838..a226dedf75d 100644 --- a/libraries/Matter/examples/MatterFan/MatterFan.ino +++ b/libraries/Matter/examples/MatterFan/MatterFan.ino @@ -24,10 +24,10 @@ MatterFan Fan; const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // set your board Analog Pin here - used for changing the Fan speed const uint8_t analogPin = A0; // Analog Pin depends on each board @@ -187,8 +187,8 @@ void loop() { if (button_state && time_diff > decommissioningTimeout) { Serial.println("Decommissioning the Generic Switch Matter Accessory. It shall be commissioned again."); Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so - } + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + } // checks Analog pin and adjust the speed only if it has changed static int lastRead = 0; diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index 5d8849c903f..cc54d3c12c0 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -39,9 +39,9 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control - decommision the Matter Node -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // Matter Protocol Endpoint (On/OFF Light) Callback bool matterCB(bool state) { @@ -103,7 +103,7 @@ void loop() { if (button_state && time_diff > decommissioningTimeout) { Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } delay(500); diff --git a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino index 7c6ff636ae0..c7b8757f37b 100644 --- a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino +++ b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino @@ -37,10 +37,10 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -148,6 +148,6 @@ void loop() { Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); OnOffLight.setOnOff(false); // turn the light off Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino index 21aa13b7570..929c13c1663 100644 --- a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino +++ b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino @@ -24,10 +24,10 @@ MatterGenericSwitch SmartButton; const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -112,6 +112,6 @@ void loop() { if (button_state && time_diff > decommissioningTimeout) { Serial.println("Decommissioning the Generic Switch Matter Accessory. It shall be commissioned again."); Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino index f3780356ff7..7937303de54 100644 --- a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino +++ b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino @@ -39,10 +39,10 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t debouceTime = 250; // button debouncing time (ms) -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t debouceTime = 250; // button debouncing time (ms) +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -192,6 +192,6 @@ void loop() { Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); CW_WW_Light = false; // turn the light off Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } } diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index 00849ceb122..86055be26ee 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -31,9 +31,9 @@ MatterTemperatureSensor SimulatedTemperatureSensor; const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control - decommision the Matter Node -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID @@ -98,14 +98,14 @@ void setup() { void loop() { static uint32_t timeCounter = 0; - + // Print the current temperature value every 5s if (!(timeCounter++ % 10)) { // delaying for 500ms x 10 = 5s // Print the current temperature value Serial.printf("Current Temperature is %.02f \r\n", SimulatedTemperatureSensor.getTemperature()); // Update Temperature from the (Simulated) Hardware Sensor // Matter APP shall display the updated temperature percent - SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature()); + SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature()); } // Check if the button has been pressed @@ -124,8 +124,8 @@ void loop() { if (button_state && time_diff > decommissioningTimeout) { Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } - + delay(500); } diff --git a/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino b/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino index 1671eb06b5b..3434217624d 100644 --- a/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino +++ b/libraries/Matter/examples/WiFiProvWithinMatter/WiFiProvWithinMatter.ino @@ -45,9 +45,9 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. // Button control - decommision the Matter Node -uint32_t button_time_stamp = 0; // debouncing control -bool button_state = false; // false = released | true = pressed -const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission +uint32_t button_time_stamp = 0; // debouncing control +bool button_state = false; // false = released | true = pressed +const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission // Matter Protocol Endpoint (On/OFF Light) Callback bool matterCB(bool state) { @@ -145,7 +145,7 @@ void loop() { if (button_state && time_diff > decommissioningTimeout) { Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again."); Matter.decommission(); - button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so + button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so } delay(500);