From 31dc520c4d1287d1be41e7e13ac53b689fe7acac Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 16 Dec 2024 08:11:50 -0300 Subject: [PATCH 1/4] feat(matter): removed while(serial) and ipv6 enabling, which is a default --- .../Matter/examples/MatterColorLight/MatterColorLight.ino | 5 ----- .../examples/MatterCommissionTest/MatterCommissionTest.ino | 5 ----- .../examples/MatterComposedLights/MatterComposedLights.ino | 5 ----- .../examples/MatterDimmableLight/MatterDimmableLight.ino | 5 ----- .../MatterEnhancedColorLight/MatterEnhancedColorLight.ino | 5 ----- libraries/Matter/examples/MatterFan/MatterFan.ino | 5 ----- libraries/Matter/examples/MatterMinimum/MatterMinimum.ino | 1 - .../Matter/examples/MatterOnOffLight/MatterOnOffLight.ino | 5 ----- .../Matter/examples/MatterSmartButon/MatterSmartButon.ino | 6 +----- .../MatterTemperatureLight/MatterTemperatureLight.ino | 5 ----- 10 files changed, 1 insertion(+), 46 deletions(-) diff --git a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino index ea91baef0ea..4f296a684c9 100644 --- a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino +++ b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino @@ -76,15 +76,10 @@ void setup() { pinMode(ledPin, OUTPUT); Serial.begin(115200); - while (!Serial) { - delay(100); - } // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); - // enable IPv6 - WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection diff --git a/libraries/Matter/examples/MatterCommissionTest/MatterCommissionTest.ino b/libraries/Matter/examples/MatterCommissionTest/MatterCommissionTest.ino index 9024479c881..0e93ed6d155 100644 --- a/libraries/Matter/examples/MatterCommissionTest/MatterCommissionTest.ino +++ b/libraries/Matter/examples/MatterCommissionTest/MatterCommissionTest.ino @@ -26,15 +26,10 @@ const char *password = "your-password"; // Change this to your WiFi password void setup() { Serial.begin(115200); - while (!Serial) { - delay(100); - } // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); - // enable IPv6 - WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection diff --git a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino index 63062ba36a9..9c3dcf05a83 100644 --- a/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino +++ b/libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino @@ -55,15 +55,10 @@ void setup() { pinMode(buttonPin, INPUT_PULLUP); Serial.begin(115200); - while (!Serial) { - delay(100); - } // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); - // enable IPv6 - WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection diff --git a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino index f1af4f84dfc..7e176803c0a 100644 --- a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino +++ b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino @@ -72,15 +72,10 @@ void setup() { pinMode(ledPin, OUTPUT); Serial.begin(115200); - while (!Serial) { - delay(100); - } // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); - // enable IPv6 - WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection diff --git a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino index eddbd0f2b21..5821707a6f7 100644 --- a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino +++ b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino @@ -80,15 +80,10 @@ void setup() { pinMode(ledPin, OUTPUT); Serial.begin(115200); - while (!Serial) { - delay(100); - } // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); - // enable IPv6 - WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino index a226dedf75d..62eaef038ef 100644 --- a/libraries/Matter/examples/MatterFan/MatterFan.ino +++ b/libraries/Matter/examples/MatterFan/MatterFan.ino @@ -71,15 +71,10 @@ void setup() { pinMode(dcMotorPin, OUTPUT); Serial.begin(115200); - while (!Serial) { - delay(100); - } // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); - // enable IPv6 - WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index cc54d3c12c0..bd1e601c53f 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -60,7 +60,6 @@ void setup() { // Initialize the LED GPIO pinMode(ledPin, OUTPUT); - WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection diff --git a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino index c7b8757f37b..93cc12f901f 100644 --- a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino +++ b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino @@ -67,15 +67,10 @@ void setup() { pinMode(ledPin, OUTPUT); Serial.begin(115200); - while (!Serial) { - delay(100); - } // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); - // enable IPv6 - WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection diff --git a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino index 929c13c1663..c0c13e31814 100644 --- a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino +++ b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino @@ -38,15 +38,11 @@ void setup() { pinMode(buttonPin, INPUT_PULLUP); Serial.begin(115200); - while (!Serial) { - delay(100); - } // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); - // enable IPv6 - WiFi.enableIPv6(true); + // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection diff --git a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino index 7937303de54..31bb535bf82 100644 --- a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino +++ b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino @@ -83,15 +83,10 @@ void setup() { pinMode(ledPin, OUTPUT); Serial.begin(115200); - while (!Serial) { - delay(100); - } // We start by connecting to a WiFi network Serial.print("Connecting to "); Serial.println(ssid); - // enable IPv6 - WiFi.enableIPv6(true); // Manually connect to WiFi WiFi.begin(ssid, password); // Wait for connection From 7d465f323bfbc542e7010fa2bf364ca4c22a0161 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 16 Dec 2024 08:14:13 -0300 Subject: [PATCH 2/4] feat(matter): fix commentaries related to feature changes and log messages --- libraries/Matter/src/MatterEndpoints/MatterColorLight.cpp | 4 ++-- .../src/MatterEndpoints/MatterColorTemperatureLight.cpp | 6 +++--- .../Matter/src/MatterEndpoints/MatterContactSensor.cpp | 2 +- .../Matter/src/MatterEndpoints/MatterDimmableLight.cpp | 4 ++-- .../src/MatterEndpoints/MatterEnhancedColorLight.cpp | 8 ++++---- libraries/Matter/src/MatterEndpoints/MatterFan.cpp | 6 +++--- .../Matter/src/MatterEndpoints/MatterHumiditySensor.cpp | 4 ++-- .../Matter/src/MatterEndpoints/MatterOccupancySensor.cpp | 2 +- libraries/Matter/src/MatterEndpoints/MatterOnOffLight.cpp | 2 +- .../Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp | 2 +- .../Matter/src/MatterEndpoints/MatterPressureSensor.cpp | 2 +- .../src/MatterEndpoints/MatterTemperatureSensor.cpp | 4 ++-- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/libraries/Matter/src/MatterEndpoints/MatterColorLight.cpp b/libraries/Matter/src/MatterEndpoints/MatterColorLight.cpp index b67cf6a23b1..6e2a7910433 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterColorLight.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterColorLight.cpp @@ -206,7 +206,7 @@ bool MatterColorLight::setOnOff(bool newState) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (onOffState == newState) { return true; } @@ -256,7 +256,7 @@ bool MatterColorLight::setColorHSV(espHsvColor_t _hsvColor) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (colorHSV.h == _hsvColor.h && colorHSV.s == _hsvColor.s && colorHSV.v == _hsvColor.v) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.cpp b/libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.cpp index 7bbcb83dcfe..f54203b7928 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.cpp @@ -138,7 +138,7 @@ bool MatterColorTemperatureLight::setOnOff(bool newState) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (onOffState == newState) { return true; } @@ -179,7 +179,7 @@ bool MatterColorTemperatureLight::setBrightness(uint8_t newBrightness) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (brightnessLevel == newBrightness) { return true; } @@ -210,7 +210,7 @@ bool MatterColorTemperatureLight::setColorTemperature(uint16_t newTemperature) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (colorTemperatureLevel == newTemperature) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterContactSensor.cpp b/libraries/Matter/src/MatterEndpoints/MatterContactSensor.cpp index 44ba1c75a44..fb08587c6f6 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterContactSensor.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterContactSensor.cpp @@ -69,7 +69,7 @@ bool MatterContactSensor::setContact(bool _contactState) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (contactState == _contactState) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.cpp b/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.cpp index c3991e0c0f3..cd9830be8ac 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.cpp @@ -114,7 +114,7 @@ bool MatterDimmableLight::setOnOff(bool newState) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (onOffState == newState) { return true; } @@ -155,7 +155,7 @@ bool MatterDimmableLight::setBrightness(uint8_t newBrightness) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (brightnessLevel == newBrightness) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.cpp b/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.cpp index 423a6a7d2ef..215e52b4137 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.cpp @@ -226,7 +226,7 @@ bool MatterEnhancedColorLight::setOnOff(bool newState) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (onOffState == newState) { return true; } @@ -267,7 +267,7 @@ bool MatterEnhancedColorLight::setBrightness(uint8_t newBrightness) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (brightnessLevel == newBrightness) { return true; } @@ -298,7 +298,7 @@ bool MatterEnhancedColorLight::setColorTemperature(uint16_t newTemperature) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (colorTemperatureLevel == newTemperature) { return true; } @@ -338,7 +338,7 @@ bool MatterEnhancedColorLight::setColorHSV(espHsvColor_t _hsvColor) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (colorHSV.h == _hsvColor.h && colorHSV.s == _hsvColor.s && colorHSV.v == _hsvColor.v) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterFan.cpp b/libraries/Matter/src/MatterEndpoints/MatterFan.cpp index 8db6a317ead..12de176d176 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterFan.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterFan.cpp @@ -118,7 +118,7 @@ bool MatterFan::setMode(FanMode_t newMode, bool performUpdate) { log_w("Matter Fan device has not begun."); return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (currentFanMode == newMode) { return true; } @@ -159,7 +159,7 @@ bool MatterFan::setSpeedPercent(uint8_t newPercent, bool performUpdate) { log_w("Matter Fan device has not begun."); return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (currentPercent == newPercent) { return true; } @@ -193,7 +193,7 @@ bool MatterFan::setOnOff(bool newState, bool performUpdate) { log_w("Matter Fan device has not begun."); return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (getOnOff() == newState) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterHumiditySensor.cpp b/libraries/Matter/src/MatterEndpoints/MatterHumiditySensor.cpp index 3e911606074..7526b99a7b9 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterHumiditySensor.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterHumiditySensor.cpp @@ -82,7 +82,7 @@ bool MatterHumiditySensor::setRawHumidity(uint16_t _rawHumidity) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (rawHumidity == _rawHumidity) { return true; } @@ -98,7 +98,7 @@ bool MatterHumiditySensor::setRawHumidity(uint16_t _rawHumidity) { bool ret; ret = updateAttributeVal(RelativeHumidityMeasurement::Id, RelativeHumidityMeasurement::Attributes::MeasuredValue::Id, &humidityVal); if (!ret) { - log_e("Failed to update Fan Speed Percent Attribute."); + log_e("Failed to update Humidity Sensor Attribute."); return false; } rawHumidity = _rawHumidity; diff --git a/libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp b/libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp index d893f14b6bb..ad200bc2ad8 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp @@ -80,7 +80,7 @@ bool MatterOccupancySensor::setOccupancy(bool _occupancyState) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (occupancyState == _occupancyState) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterOnOffLight.cpp b/libraries/Matter/src/MatterEndpoints/MatterOnOffLight.cpp index 3f71ff1eb76..1071b595e5b 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterOnOffLight.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterOnOffLight.cpp @@ -94,7 +94,7 @@ bool MatterOnOffLight::setOnOff(bool newState) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (onOffState == newState) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp b/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp index 6b5e5e630e0..546da3b04e9 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp @@ -93,7 +93,7 @@ bool MatterOnOffPlugin::setOnOff(bool newState) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (onOffState == newState) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterPressureSensor.cpp b/libraries/Matter/src/MatterEndpoints/MatterPressureSensor.cpp index a157469c980..f246ea81223 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterPressureSensor.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterPressureSensor.cpp @@ -70,7 +70,7 @@ bool MatterPressureSensor::setRawPressure(int16_t _rawPressure) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (rawPressure == _rawPressure) { return true; } diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp index 4a43650f924..6f59a5b2426 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp @@ -70,7 +70,7 @@ bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) { return false; } - // avoid processing the a "no-change" + // avoid processing if there was no change if (rawTemperature == _rawTemperature) { return true; } @@ -86,7 +86,7 @@ bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) { bool ret; ret = updateAttributeVal(TemperatureMeasurement::Id, TemperatureMeasurement::Attributes::MeasuredValue::Id, &temperatureVal); if (!ret) { - log_e("Failed to update Fan Speed Percent Attribute."); + log_e("Failed to update Temperature Sensor Attribute."); return false; } rawTemperature = _rawTemperature; From 3f7c5976d2fd8f8407546d257a29adaad9faa014 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 16 Dec 2024 11:40:49 -0300 Subject: [PATCH 3/4] feat(matter):replacing code in examples and header files --- .../MatterColorLight/MatterColorLight.ino | 8 ++++---- .../MatterContactSensor.ino | 8 ++++---- .../MatterDimmableLight.ino | 8 ++++---- .../MatterEnhancedColorLight.ino | 8 ++++---- .../Matter/examples/MatterFan/MatterFan.ino | 8 ++++---- .../MatterHumiditySensor.ino | 6 +++--- .../examples/MatterMinimum/MatterMinimum.ino | 12 +++++------ .../MatterOccupancySensor.ino | 6 +++--- .../MatterOnOffLight/MatterOnOffLight.ino | 8 ++++---- .../MatterOnOffPlugin/MatterOnOffPlugin.ino | 8 ++++---- .../MatterPressureSensor.ino | 6 +++--- .../MatterSmartButon/MatterSmartButon.ino | 8 ++++---- .../MatterTemperatureLight.ino | 8 ++++---- .../MatterTemperatureSensor.ino | 8 ++++---- .../src/MatterEndpoints/MatterColorLight.h | 20 +++++++++---------- .../MatterColorTemperatureLight.h | 20 +++++++++---------- .../src/MatterEndpoints/MatterDimmableLight.h | 20 ++++++++++--------- .../MatterEnhancedColorLight.h | 20 +++++++++---------- .../Matter/src/MatterEndpoints/MatterFan.h | 15 +++++++------- .../src/MatterEndpoints/MatterOnOffLight.h | 20 +++++++++++-------- .../src/MatterEndpoints/MatterOnOffPlugin.h | 20 +++++++++++-------- .../MatterEndpoints/MatterPressureSensor.h | 1 + .../MatterEndpoints/MatterTemperatureSensor.h | 1 + 23 files changed, 130 insertions(+), 117 deletions(-) diff --git a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino index 4f296a684c9..dd1724f602d 100644 --- a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino +++ b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino @@ -21,6 +21,10 @@ // Color Light Endpoint MatterColorLight ColorLight; +// 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 + // it will keep last OnOff & HSV Color state stored, using Preferences Preferences matterPref; const char *onOffPrefKey = "OnOff"; @@ -43,10 +47,6 @@ bool button_state = false; // false = released | true = pres 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 -const char *password = "your-password"; // Change this to your WiFi password - // Set the RGB LED Light based on the current state of the Color Light bool setLightState(bool state, espHsvColor_t colorHSV) { diff --git a/libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino b/libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino index 7b4d95a880b..e27f70e613d 100644 --- a/libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino +++ b/libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino @@ -36,6 +36,10 @@ // Matter Contact Sensor Endpoint MatterContactSensor ContactSensor; +// 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 + // LED will be used to indicate the Contact Sensor state // set your board RGB LED pin here #ifdef RGB_BUILTIN @@ -48,10 +52,6 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE // set your board USER BUTTON pin here - decommissioning and Manual Contact Sensor toggle button const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. -// 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 - // Button control uint32_t button_time_stamp = 0; // debouncing control bool button_state = false; // false = released | true = pressed diff --git a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino index 7e176803c0a..cb8b8b6f17f 100644 --- a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino +++ b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino @@ -21,6 +21,10 @@ // Dimmable Light Endpoint MatterDimmableLight DimmableLight; +// 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 + // it will keep last OnOff & Brightness state stored, using Preferences Preferences matterPref; const char *onOffPrefKey = "OnOff"; @@ -43,10 +47,6 @@ bool button_state = false; // false = released | true = pres 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 -const char *password = "your-password"; // Change this to your WiFi password - // Set the RGB LED Light based on the current state of the Dimmable Light bool setLightState(bool state, uint8_t brightness) { if (state) { diff --git a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino index 5821707a6f7..bd2d13899ca 100644 --- a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino +++ b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino @@ -21,6 +21,10 @@ // Color Light Endpoint MatterEnhancedColorLight EnhancedColorLight; +// 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 + // It will use HSV color to control all Matter Attribute Changes HsvColor_t currentHSVColor = {0, 0, 0}; @@ -46,10 +50,6 @@ bool button_state = false; // false = released | true = pres 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 -const char *password = "your-password"; // Change this to your WiFi password - // Set the RGB LED Light based on the current state of the Enhanced Color Light bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint16_t temperature_Mireds) { diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino index 62eaef038ef..3dc0c89fcf4 100644 --- a/libraries/Matter/examples/MatterFan/MatterFan.ino +++ b/libraries/Matter/examples/MatterFan/MatterFan.ino @@ -20,6 +20,10 @@ // Fan Endpoint - On/Off control + Speed Percent Control + Fan Modes MatterFan Fan; +// 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 for toggling On/Off and decommission the Matter Node const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. @@ -41,10 +45,6 @@ const uint8_t dcMotorPin = 2; // Set your pin here if your board has not define #warning "Do not forget to set the RGB LED 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 fanDCMotorDrive(bool fanState, uint8_t speedPercent) { // drive the Fan DC motor if (fanState == false) { diff --git a/libraries/Matter/examples/MatterHumiditySensor/MatterHumiditySensor.ino b/libraries/Matter/examples/MatterHumiditySensor/MatterHumiditySensor.ino index c4977772c1b..3fcab46c565 100644 --- a/libraries/Matter/examples/MatterHumiditySensor/MatterHumiditySensor.ino +++ b/libraries/Matter/examples/MatterHumiditySensor/MatterHumiditySensor.ino @@ -27,13 +27,13 @@ // Matter Humidity Sensor Endpoint MatterHumiditySensor SimulatedHumiditySensor; -// set your board USER BUTTON pin here - decommissioning button -const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. - // 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 - decommissioning button +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 diff --git a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino index bd1e601c53f..fa2599df6dd 100644 --- a/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino +++ b/libraries/Matter/examples/MatterMinimum/MatterMinimum.ino @@ -28,6 +28,10 @@ // 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 + // Light GPIO that can be controlled by Matter APP #ifdef LED_BUILTIN const uint8_t ledPin = LED_BUILTIN; @@ -44,16 +48,12 @@ bool button_state = false; // false = released | true = pres 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) { +bool onOffLightCallback(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() { // Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node pinMode(buttonPin, INPUT_PULLUP); @@ -71,7 +71,7 @@ void setup() { OnOffLight.begin(); // Associate a callback to the Matter Controller - OnOffLight.onChange(matterCB); + OnOffLight.onChange(onOffLightCallback); // Matter beginning - Last step, after all EndPoints are initialized Matter.begin(); diff --git a/libraries/Matter/examples/MatterOccupancySensor/MatterOccupancySensor.ino b/libraries/Matter/examples/MatterOccupancySensor/MatterOccupancySensor.ino index 7582a423dc0..e88a9a8986b 100644 --- a/libraries/Matter/examples/MatterOccupancySensor/MatterOccupancySensor.ino +++ b/libraries/Matter/examples/MatterOccupancySensor/MatterOccupancySensor.ino @@ -34,13 +34,13 @@ // Matter Occupancy Sensor Endpoint MatterOccupancySensor OccupancySensor; -// set your board USER BUTTON pin here - decommissioning only -const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. - // 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 - decommissioning only +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 diff --git a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino index 93cc12f901f..5faa0a385b0 100644 --- a/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino +++ b/libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino @@ -17,6 +17,10 @@ #include #include +// 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 + // List of Matter Endpoints for this Node // On/Off Light Endpoint MatterOnOffLight OnOffLight; @@ -42,10 +46,6 @@ bool button_state = false; // false = released | true = pres 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 -const char *password = "your-password"; // Change this to your WiFi password - // Matter Protocol Endpoint Callback bool setLightOnOff(bool state) { Serial.printf("User Callback :: New Light State = %s\r\n", state ? "ON" : "OFF"); diff --git a/libraries/Matter/examples/MatterOnOffPlugin/MatterOnOffPlugin.ino b/libraries/Matter/examples/MatterOnOffPlugin/MatterOnOffPlugin.ino index 1950b5bb9f3..d14e2189ec1 100644 --- a/libraries/Matter/examples/MatterOnOffPlugin/MatterOnOffPlugin.ino +++ b/libraries/Matter/examples/MatterOnOffPlugin/MatterOnOffPlugin.ino @@ -21,6 +21,10 @@ // On/Off Plugin Endpoint MatterOnOffPlugin OnOffPlugin; +// 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 + // it will keep last OnOff state stored, using Preferences Preferences matterPref; const char *onOffPrefKey = "OnOff"; @@ -41,10 +45,6 @@ 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 -const char *password = "your-password"; // Change this to your WiFi password - // Matter Protocol Endpoint Callback bool setPluginOnOff(bool state) { Serial.printf("User Callback :: New Plugin State = %s\r\n", state ? "ON" : "OFF"); diff --git a/libraries/Matter/examples/MatterPressureSensor/MatterPressureSensor.ino b/libraries/Matter/examples/MatterPressureSensor/MatterPressureSensor.ino index aa6b28f199f..394a217b87a 100644 --- a/libraries/Matter/examples/MatterPressureSensor/MatterPressureSensor.ino +++ b/libraries/Matter/examples/MatterPressureSensor/MatterPressureSensor.ino @@ -27,13 +27,13 @@ // Matter Pressure Sensor Endpoint MatterPressureSensor SimulatedPressureSensor; -// set your board USER BUTTON pin here - decommissioning button -const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. - // 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 - decommissioning button +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 diff --git a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino index c0c13e31814..f8da970595d 100644 --- a/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino +++ b/libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino @@ -20,6 +20,10 @@ // Generic Switch Endpoint - works as a smart button with a single click MatterGenericSwitch SmartButton; +// 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 const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. @@ -29,10 +33,6 @@ bool button_state = false; // false = released | true = pres 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 -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 smart button or to decommission the Matter Node pinMode(buttonPin, INPUT_PULLUP); diff --git a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino index 31bb535bf82..b814ba89704 100644 --- a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino +++ b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino @@ -21,6 +21,10 @@ // Color Temperature CW/WW Light Endpoint MatterColorTemperatureLight CW_WW_Light; +// 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 + // it will keep last OnOff & Brightness state stored, using Preferences Preferences matterPref; const char *onOffPrefKey = "OnOff"; @@ -44,10 +48,6 @@ bool button_state = false; // false = released | true = pres 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 -const char *password = "your-password"; // Change this to your WiFi password - // Set the RGB LED Light based on the current state of the Color Temperature Light bool setLightState(bool state, uint8_t brightness, uint16_t temperature_Mireds) { diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index 86055be26ee..e8513f12aaa 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -27,6 +27,10 @@ // Matter Temperature Sensor Endpoint MatterTemperatureSensor SimulatedTemperatureSensor; +// 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 - decommissioning button const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button. @@ -35,10 +39,6 @@ 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 -const char *password = "your-password"; // Change this to your WiFi password - // Simulate a temperature sensor - add your preferred temperature sensor library code here float getSimulatedTemperature() { // The Endpoint implementation keeps an int16_t as internal value information, diff --git a/libraries/Matter/src/MatterEndpoints/MatterColorLight.h b/libraries/Matter/src/MatterEndpoints/MatterColorLight.h index 13ff0decbc2..b896afa9b7a 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterColorLight.h +++ b/libraries/Matter/src/MatterEndpoints/MatterColorLight.h @@ -37,16 +37,6 @@ class MatterColorLight : public MatterEndPoint { bool setColorHSV(espHsvColor_t hsvColor); // returns true if successful espHsvColor_t getColorHSV(); // returns current HSV Color - // used to update the state of the light using the current Matter Light internal state - // It is necessary to set a user callback function using onChange() to handle the physical light state - void updateAccessory(); - - operator bool(); // returns current on/off light state - void operator=(bool state); // turns light on or off - - // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. - bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); - // User Callback for whenever the Light On/Off state is changed by the Matter Controller using EndPointOnOffCB = std::function; void onChangeOnOff(EndPointOnOffCB onChangeCB) { @@ -64,6 +54,16 @@ class MatterColorLight : public MatterEndPoint { _onChangeCB = onChangeCB; } + // used to update the state of the light using the current Matter Light internal state + // It is necessary to set a user callback function using onChange() to handle the physical light state + void updateAccessory(); + + operator bool(); // returns current on/off light state + void operator=(bool state); // turns light on or off + + // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. + bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); + protected: bool started = false; bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) diff --git a/libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.h b/libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.h index e886a184182..539bc386e92 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.h +++ b/libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.h @@ -42,16 +42,6 @@ class MatterColorTemperatureLight : public MatterEndPoint { bool setColorTemperature(uint16_t newTemperature); // returns true if successful uint16_t getColorTemperature(); // returns current temperature - // used to update the state of the light using the current Matter Light internal state - // It is necessary to set a user callback function using onChange() to handle the physical light state - void updateAccessory(); - - operator bool(); // returns current on/off light state - void operator=(bool state); // turns light on or off - - // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. - bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); - // User Callback for whenever the Light On/Off state is changed by the Matter Controller using EndPointOnOffCB = std::function; void onChangeOnOff(EndPointOnOffCB onChangeCB) { @@ -76,6 +66,16 @@ class MatterColorTemperatureLight : public MatterEndPoint { _onChangeCB = onChangeCB; } + // used to update the state of the light using the current Matter Light internal state + // It is necessary to set a user callback function using onChange() to handle the physical light state + void updateAccessory(); + + operator bool(); // returns current on/off light state + void operator=(bool state); // turns light on or off + + // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. + bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); + protected: bool started = false; bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) diff --git a/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h b/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h index aacce883277..04e658d8c0d 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h +++ b/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h @@ -37,19 +37,12 @@ class MatterDimmableLight : public MatterEndPoint { bool setBrightness(uint8_t newBrightness); // returns true if successful uint8_t getBrightness(); // returns current brightness - // used to update the state of the light using the current Matter Light internal state - // It is necessary to set a user callback function using onChange() to handle the physical light state - void updateAccessory(); - - operator bool(); // returns current on/off light state - void operator=(bool state); // turns light on or off - // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. - bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); - // User Callback for whenever the Light On/Off state is changed by the Matter Controller + // User Callback for whenever the Light On/Off state is changed by the Matter Controller using EndPointOnOffCB = std::function; void onChangeOnOff(EndPointOnOffCB onChangeCB) { _onChangeOnOffCB = onChangeCB; } + // User Callback for whenever the Light brightness value [0..255] is changed by the Matter Controller using EndPointBrightnessCB = std::function; void onChangeBrightness(EndPointBrightnessCB onChangeCB) { @@ -62,6 +55,15 @@ class MatterDimmableLight : public MatterEndPoint { _onChangeCB = onChangeCB; } + // used to update the state of the light using the current Matter Light internal state + // It is necessary to set a user callback function using onChange() to handle the physical light state + void updateAccessory(); + +operator bool(); // returns current on/off light state + void operator=(bool state); // turns light on or off + // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. + bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); + protected: bool started = false; bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) diff --git a/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h b/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h index 66ed1943b8d..ff6e69e3e65 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h +++ b/libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h @@ -47,16 +47,6 @@ class MatterEnhancedColorLight : public MatterEndPoint { bool setColorHSV(espHsvColor_t hsvColor); // returns true if successful espHsvColor_t getColorHSV(); // returns current HSV Color - // used to update the state of the light using the current Matter Light internal state - // It is necessary to set a user callback function using onChange() to handle the physical light state - void updateAccessory(); - - operator bool(); // returns current on/off light state - void operator=(bool state); // turns light on or off - - // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. - bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); - // User Callback for whenever the Light On/Off state is changed by the Matter Controller using EndPointOnOffCB = std::function; void onChangeOnOff(EndPointOnOffCB onChangeCB) { @@ -87,6 +77,16 @@ class MatterEnhancedColorLight : public MatterEndPoint { _onChangeCB = onChangeCB; } + // used to update the state of the light using the current Matter Light internal state + // It is necessary to set a user callback function using onChange() to handle the physical light state + void updateAccessory(); + + operator bool(); // returns current on/off light state + void operator=(bool state); // turns light on or off + + // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. + bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); + protected: bool started = false; bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) diff --git a/libraries/Matter/src/MatterEndpoints/MatterFan.h b/libraries/Matter/src/MatterEndpoints/MatterFan.h index 232577b7bef..a1cd6e42423 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterFan.h +++ b/libraries/Matter/src/MatterEndpoints/MatterFan.h @@ -98,13 +98,6 @@ class MatterFan : public MatterEndPoint { operator uint8_t() { return getSpeedPercent(); } - // sets Fan speed percent - void operator=(uint8_t speedPercent) { - setSpeedPercent(speedPercent); - } - - // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. - bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); // User Callback for whenever the Fan Mode (state) is changed by the Matter Controller using EndPointModeCB = std::function; @@ -124,6 +117,14 @@ class MatterFan : public MatterEndPoint { _onChangeCB = onChangeCB; } + // sets Fan speed percent + void operator=(uint8_t speedPercent) { + setSpeedPercent(speedPercent); + } + + // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. + bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); + protected: bool started = false; uint8_t validFanModes = 0; // bitmap for valid Fan Modes - index of fanModeSequence[] diff --git a/libraries/Matter/src/MatterEndpoints/MatterOnOffLight.h b/libraries/Matter/src/MatterEndpoints/MatterOnOffLight.h index 6d140a9948e..ec524d2c300 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterOnOffLight.h +++ b/libraries/Matter/src/MatterEndpoints/MatterOnOffLight.h @@ -30,23 +30,27 @@ class MatterOnOffLight : public MatterEndPoint { bool getOnOff(); // returns current light state bool toggle(); // returns true if successful - // used to update the state of the light using the current Matter Light internal state - // It is necessary to set a user callback function using onChange() to handle the physical light state - void updateAccessory(); - - operator bool(); // returns current light state - void operator=(bool state); // turns light on or off - // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. - bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); // User Callback for whenever the Light state is changed by the Matter Controller using EndPointCB = std::function; void onChange(EndPointCB onChangeCB) { _onChangeCB = onChangeCB; } + + // User Callback for whenever the Light On/Off state is changed by the Matter Controller void onChangeOnOff(EndPointCB onChangeCB) { _onChangeOnOffCB = onChangeCB; } + // used to update the state of the light using the current Matter Light internal state + // It is necessary to set a user callback function using onChange() to handle the physical light state + void updateAccessory(); + + operator bool(); // returns current light state + void operator=(bool state); // turns light on or off + + // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. + bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); + protected: bool started = false; bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) diff --git a/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h b/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h index 241726a3a46..f95e127ca98 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h +++ b/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h @@ -30,23 +30,27 @@ class MatterOnOffPlugin : public MatterEndPoint { bool getOnOff(); // returns current plugin state bool toggle(); // returns true if successful - // used to update the state of the plugin using the current Matter Plugin internal state - // It is necessary to set a user callback function using onChange() to handle the physical plugin state - void updateAccessory(); - - operator bool(); // returns current plugin state - void operator=(bool state); // turns plugin on or off - // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. - bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); // User Callback for whenever the Plugin state is changed by the Matter Controller using EndPointCB = std::function; void onChange(EndPointCB onChangeCB) { _onChangeCB = onChangeCB; } + + // User Callback for whenever the On/Off state is changed by the Matter Controller void onChangeOnOff(EndPointCB onChangeCB) { _onChangeOnOffCB = onChangeCB; } + // used to update the state of the plugin using the current Matter Plugin internal state + // It is necessary to set a user callback function using onChange() to handle the physical plugin state + void updateAccessory(); + + operator bool(); // returns current plugin state + void operator=(bool state); // turns plugin on or off + + // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. + bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); + protected: bool started = false; bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) diff --git a/libraries/Matter/src/MatterEndpoints/MatterPressureSensor.h b/libraries/Matter/src/MatterEndpoints/MatterPressureSensor.h index 9fdd90c6ebe..0715c05609d 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterPressureSensor.h +++ b/libraries/Matter/src/MatterEndpoints/MatterPressureSensor.h @@ -39,6 +39,7 @@ class MatterPressureSensor : public MatterEndPoint { double getPressure() { return (double)rawPressure; } + // double conversion operator void operator=(double pressure) { setPressure(pressure); diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h index 826abac9a2a..27c61fdb978 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h @@ -40,6 +40,7 @@ class MatterTemperatureSensor : public MatterEndPoint { double getTemperature() { return (double)rawTemperature / 100.0; } + // double conversion operator void operator=(double temperature) { setTemperature(temperature); From 43c419e31b1de080ab00c6e33fad323f48222fad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:41:38 +0000 Subject: [PATCH 4/4] ci(pre-commit): Apply automatic fixes --- libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h | 4 ++-- libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h b/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h index 04e658d8c0d..4497edd2fe2 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h +++ b/libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h @@ -37,7 +37,7 @@ class MatterDimmableLight : public MatterEndPoint { bool setBrightness(uint8_t newBrightness); // returns true if successful uint8_t getBrightness(); // returns current brightness - // User Callback for whenever the Light On/Off state is changed by the Matter Controller + // User Callback for whenever the Light On/Off state is changed by the Matter Controller using EndPointOnOffCB = std::function; void onChangeOnOff(EndPointOnOffCB onChangeCB) { _onChangeOnOffCB = onChangeCB; @@ -59,7 +59,7 @@ class MatterDimmableLight : public MatterEndPoint { // It is necessary to set a user callback function using onChange() to handle the physical light state void updateAccessory(); -operator bool(); // returns current on/off light state + operator bool(); // returns current on/off light state void operator=(bool state); // turns light on or off // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); diff --git a/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h b/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h index f95e127ca98..0b05c0944c4 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h +++ b/libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h @@ -35,7 +35,7 @@ class MatterOnOffPlugin : public MatterEndPoint { void onChange(EndPointCB onChangeCB) { _onChangeCB = onChangeCB; } - + // User Callback for whenever the On/Off state is changed by the Matter Controller void onChangeOnOff(EndPointCB onChangeCB) { _onChangeOnOffCB = onChangeCB;