Skip to content

Commit 30e55fc

Browse files
authoredDec 16, 2024··
Merge pull request #10732 from SuGlider/matter_while_serial
feat(matter): General Review - remove while(!serial) ipv6(enable) and fixes some commentaries in the code
·
3.3.03.1.0
2 parents 1ef1e7d + 43c419e commit 30e55fc

37 files changed

+153
-185
lines changed
 

‎libraries/Matter/examples/MatterColorLight/MatterColorLight.ino

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
// Color Light Endpoint
2222
MatterColorLight ColorLight;
2323

24+
// WiFi is manually set and started
25+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
26+
const char *password = "your-password"; // Change this to your WiFi password
27+
2428
// it will keep last OnOff & HSV Color state stored, using Preferences
2529
Preferences matterPref;
2630
const char *onOffPrefKey = "OnOff";
@@ -43,10 +47,6 @@ bool button_state = false; // false = released | true = pres
4347
const uint32_t debouceTime = 250; // button debouncing time (ms)
4448
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
4549

46-
// WiFi is manually set and started
47-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
48-
const char *password = "your-password"; // Change this to your WiFi password
49-
5050
// Set the RGB LED Light based on the current state of the Color Light
5151
bool setLightState(bool state, espHsvColor_t colorHSV) {
5252

@@ -76,15 +76,10 @@ void setup() {
7676
pinMode(ledPin, OUTPUT);
7777

7878
Serial.begin(115200);
79-
while (!Serial) {
80-
delay(100);
81-
}
8279

8380
// We start by connecting to a WiFi network
8481
Serial.print("Connecting to ");
8582
Serial.println(ssid);
86-
// enable IPv6
87-
WiFi.enableIPv6(true);
8883
// Manually connect to WiFi
8984
WiFi.begin(ssid, password);
9085
// Wait for connection

‎libraries/Matter/examples/MatterCommissionTest/MatterCommissionTest.ino

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,10 @@ const char *password = "your-password"; // Change this to your WiFi password
2626

2727
void setup() {
2828
Serial.begin(115200);
29-
while (!Serial) {
30-
delay(100);
31-
}
3229

3330
// We start by connecting to a WiFi network
3431
Serial.print("Connecting to ");
3532
Serial.println(ssid);
36-
// enable IPv6
37-
WiFi.enableIPv6(true);
3833
// Manually connect to WiFi
3934
WiFi.begin(ssid, password);
4035
// Wait for connection

‎libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,10 @@ void setup() {
5555
pinMode(buttonPin, INPUT_PULLUP);
5656

5757
Serial.begin(115200);
58-
while (!Serial) {
59-
delay(100);
60-
}
6158

6259
// We start by connecting to a WiFi network
6360
Serial.print("Connecting to ");
6461
Serial.println(ssid);
65-
// enable IPv6
66-
WiFi.enableIPv6(true);
6762
// Manually connect to WiFi
6863
WiFi.begin(ssid, password);
6964
// Wait for connection

‎libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
// Matter Contact Sensor Endpoint
3737
MatterContactSensor ContactSensor;
3838

39+
// WiFi is manually set and started
40+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
41+
const char *password = "your-password"; // Change this to your WiFi password
42+
3943
// LED will be used to indicate the Contact Sensor state
4044
// set your board RGB LED pin here
4145
#ifdef RGB_BUILTIN
@@ -48,10 +52,6 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE
4852
// set your board USER BUTTON pin here - decommissioning and Manual Contact Sensor toggle button
4953
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
5054

51-
// WiFi is manually set and started
52-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
53-
const char *password = "your-password"; // Change this to your WiFi password
54-
5555
// Button control
5656
uint32_t button_time_stamp = 0; // debouncing control
5757
bool button_state = false; // false = released | true = pressed

‎libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
// Dimmable Light Endpoint
2222
MatterDimmableLight DimmableLight;
2323

24+
// WiFi is manually set and started
25+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
26+
const char *password = "your-password"; // Change this to your WiFi password
27+
2428
// it will keep last OnOff & Brightness state stored, using Preferences
2529
Preferences matterPref;
2630
const char *onOffPrefKey = "OnOff";
@@ -43,10 +47,6 @@ bool button_state = false; // false = released | true = pres
4347
const uint32_t debouceTime = 250; // button debouncing time (ms)
4448
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
4549

46-
// WiFi is manually set and started
47-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
48-
const char *password = "your-password"; // Change this to your WiFi password
49-
5050
// Set the RGB LED Light based on the current state of the Dimmable Light
5151
bool setLightState(bool state, uint8_t brightness) {
5252
if (state) {
@@ -72,15 +72,10 @@ void setup() {
7272
pinMode(ledPin, OUTPUT);
7373

7474
Serial.begin(115200);
75-
while (!Serial) {
76-
delay(100);
77-
}
7875

7976
// We start by connecting to a WiFi network
8077
Serial.print("Connecting to ");
8178
Serial.println(ssid);
82-
// enable IPv6
83-
WiFi.enableIPv6(true);
8479
// Manually connect to WiFi
8580
WiFi.begin(ssid, password);
8681
// Wait for connection

‎libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
// Color Light Endpoint
2222
MatterEnhancedColorLight EnhancedColorLight;
2323

24+
// WiFi is manually set and started
25+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
26+
const char *password = "your-password"; // Change this to your WiFi password
27+
2428
// It will use HSV color to control all Matter Attribute Changes
2529
HsvColor_t currentHSVColor = {0, 0, 0};
2630

@@ -46,10 +50,6 @@ bool button_state = false; // false = released | true = pres
4650
const uint32_t debouceTime = 250; // button debouncing time (ms)
4751
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
4852

49-
// WiFi is manually set and started
50-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
51-
const char *password = "your-password"; // Change this to your WiFi password
52-
5353
// Set the RGB LED Light based on the current state of the Enhanced Color Light
5454
bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint16_t temperature_Mireds) {
5555

@@ -80,15 +80,10 @@ void setup() {
8080
pinMode(ledPin, OUTPUT);
8181

8282
Serial.begin(115200);
83-
while (!Serial) {
84-
delay(100);
85-
}
8683

8784
// We start by connecting to a WiFi network
8885
Serial.print("Connecting to ");
8986
Serial.println(ssid);
90-
// enable IPv6
91-
WiFi.enableIPv6(true);
9287
// Manually connect to WiFi
9388
WiFi.begin(ssid, password);
9489
// Wait for connection

‎libraries/Matter/examples/MatterFan/MatterFan.ino

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
// Fan Endpoint - On/Off control + Speed Percent Control + Fan Modes
2121
MatterFan Fan;
2222

23+
// WiFi is manually set and started
24+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
25+
const char *password = "your-password"; // Change this to your WiFi password
26+
2327
// set your board USER BUTTON pin here - used for toggling On/Off and decommission the Matter Node
2428
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
2529

@@ -41,10 +45,6 @@ const uint8_t dcMotorPin = 2; // Set your pin here if your board has not define
4145
#warning "Do not forget to set the RGB LED pin"
4246
#endif
4347

44-
// WiFi is manually set and started
45-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
46-
const char *password = "your-password"; // Change this to your WiFi password
47-
4848
void fanDCMotorDrive(bool fanState, uint8_t speedPercent) {
4949
// drive the Fan DC motor
5050
if (fanState == false) {
@@ -71,15 +71,10 @@ void setup() {
7171
pinMode(dcMotorPin, OUTPUT);
7272

7373
Serial.begin(115200);
74-
while (!Serial) {
75-
delay(100);
76-
}
7774

7875
// We start by connecting to a WiFi network
7976
Serial.print("Connecting to ");
8077
Serial.println(ssid);
81-
// enable IPv6
82-
WiFi.enableIPv6(true);
8378
// Manually connect to WiFi
8479
WiFi.begin(ssid, password);
8580
// Wait for connection

‎libraries/Matter/examples/MatterHumiditySensor/MatterHumiditySensor.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
// Matter Humidity Sensor Endpoint
2828
MatterHumiditySensor SimulatedHumiditySensor;
2929

30-
// set your board USER BUTTON pin here - decommissioning button
31-
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
32-
3330
// WiFi is manually set and started
3431
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
3532
const char *password = "your-password"; // Change this to your WiFi password
3633

34+
// set your board USER BUTTON pin here - decommissioning button
35+
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
36+
3737
// Button control - decommision the Matter Node
3838
uint32_t button_time_stamp = 0; // debouncing control
3939
bool button_state = false; // false = released | true = pressed

‎libraries/Matter/examples/MatterMinimum/MatterMinimum.ino

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
// Single On/Off Light Endpoint - at least one per node
2929
MatterOnOffLight OnOffLight;
3030

31+
// WiFi is manually set and started
32+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
33+
const char *password = "your-password"; // Change this to your WiFi password
34+
3135
// Light GPIO that can be controlled by Matter APP
3236
#ifdef LED_BUILTIN
3337
const uint8_t ledPin = LED_BUILTIN;
@@ -44,23 +48,18 @@ bool button_state = false; // false = released | true = pres
4448
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
4549

4650
// Matter Protocol Endpoint (On/OFF Light) Callback
47-
bool matterCB(bool state) {
51+
bool onOffLightCallback(bool state) {
4852
digitalWrite(ledPin, state ? HIGH : LOW);
4953
// This callback must return the success state to Matter core
5054
return true;
5155
}
5256

53-
// WiFi is manually set and started
54-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
55-
const char *password = "your-password"; // Change this to your WiFi password
56-
5757
void setup() {
5858
// Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node
5959
pinMode(buttonPin, INPUT_PULLUP);
6060
// Initialize the LED GPIO
6161
pinMode(ledPin, OUTPUT);
6262

63-
WiFi.enableIPv6(true);
6463
// Manually connect to WiFi
6564
WiFi.begin(ssid, password);
6665
// Wait for connection
@@ -72,7 +71,7 @@ void setup() {
7271
OnOffLight.begin();
7372

7473
// Associate a callback to the Matter Controller
75-
OnOffLight.onChange(matterCB);
74+
OnOffLight.onChange(onOffLightCallback);
7675

7776
// Matter beginning - Last step, after all EndPoints are initialized
7877
Matter.begin();

‎libraries/Matter/examples/MatterOccupancySensor/MatterOccupancySensor.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
// Matter Occupancy Sensor Endpoint
3535
MatterOccupancySensor OccupancySensor;
3636

37-
// set your board USER BUTTON pin here - decommissioning only
38-
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
39-
4037
// WiFi is manually set and started
4138
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
4239
const char *password = "your-password"; // Change this to your WiFi password
4340

41+
// set your board USER BUTTON pin here - decommissioning only
42+
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
43+
4444
// Button control
4545
uint32_t button_time_stamp = 0; // debouncing control
4646
bool button_state = false; // false = released | true = pressed

‎libraries/Matter/examples/MatterOnOffLight/MatterOnOffLight.ino

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include <WiFi.h>
1818
#include <Preferences.h>
1919

20+
// WiFi is manually set and started
21+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
22+
const char *password = "your-password"; // Change this to your WiFi password
23+
2024
// List of Matter Endpoints for this Node
2125
// On/Off Light Endpoint
2226
MatterOnOffLight OnOffLight;
@@ -42,10 +46,6 @@ bool button_state = false; // false = released | true = pres
4246
const uint32_t debouceTime = 250; // button debouncing time (ms)
4347
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
4448

45-
// WiFi is manually set and started
46-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
47-
const char *password = "your-password"; // Change this to your WiFi password
48-
4949
// Matter Protocol Endpoint Callback
5050
bool setLightOnOff(bool state) {
5151
Serial.printf("User Callback :: New Light State = %s\r\n", state ? "ON" : "OFF");
@@ -67,15 +67,10 @@ void setup() {
6767
pinMode(ledPin, OUTPUT);
6868

6969
Serial.begin(115200);
70-
while (!Serial) {
71-
delay(100);
72-
}
7370

7471
// We start by connecting to a WiFi network
7572
Serial.print("Connecting to ");
7673
Serial.println(ssid);
77-
// enable IPv6
78-
WiFi.enableIPv6(true);
7974
// Manually connect to WiFi
8075
WiFi.begin(ssid, password);
8176
// Wait for connection

‎libraries/Matter/examples/MatterOnOffPlugin/MatterOnOffPlugin.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
// On/Off Plugin Endpoint
2222
MatterOnOffPlugin OnOffPlugin;
2323

24+
// WiFi is manually set and started
25+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
26+
const char *password = "your-password"; // Change this to your WiFi password
27+
2428
// it will keep last OnOff state stored, using Preferences
2529
Preferences matterPref;
2630
const char *onOffPrefKey = "OnOff";
@@ -41,10 +45,6 @@ uint32_t button_time_stamp = 0; // debouncing control
4145
bool button_state = false; // false = released | true = pressed
4246
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
4347

44-
// WiFi is manually set and started
45-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
46-
const char *password = "your-password"; // Change this to your WiFi password
47-
4848
// Matter Protocol Endpoint Callback
4949
bool setPluginOnOff(bool state) {
5050
Serial.printf("User Callback :: New Plugin State = %s\r\n", state ? "ON" : "OFF");

‎libraries/Matter/examples/MatterPressureSensor/MatterPressureSensor.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
// Matter Pressure Sensor Endpoint
2828
MatterPressureSensor SimulatedPressureSensor;
2929

30-
// set your board USER BUTTON pin here - decommissioning button
31-
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
32-
3330
// WiFi is manually set and started
3431
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
3532
const char *password = "your-password"; // Change this to your WiFi password
3633

34+
// set your board USER BUTTON pin here - decommissioning button
35+
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
36+
3737
// Button control - decommision the Matter Node
3838
uint32_t button_time_stamp = 0; // debouncing control
3939
bool button_state = false; // false = released | true = pressed

‎libraries/Matter/examples/MatterSmartButon/MatterSmartButon.ino

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
// Generic Switch Endpoint - works as a smart button with a single click
2121
MatterGenericSwitch SmartButton;
2222

23+
// WiFi is manually set and started
24+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
25+
const char *password = "your-password"; // Change this to your WiFi password
26+
2327
// set your board USER BUTTON pin here
2428
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
2529

@@ -29,24 +33,16 @@ bool button_state = false; // false = released | true = pres
2933
const uint32_t debouceTime = 250; // button debouncing time (ms)
3034
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
3135

32-
// WiFi is manually set and started
33-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
34-
const char *password = "your-password"; // Change this to your WiFi password
35-
3636
void setup() {
3737
// Initialize the USER BUTTON (Boot button) GPIO that will act as a smart button or to decommission the Matter Node
3838
pinMode(buttonPin, INPUT_PULLUP);
3939

4040
Serial.begin(115200);
41-
while (!Serial) {
42-
delay(100);
43-
}
4441

4542
// We start by connecting to a WiFi network
4643
Serial.print("Connecting to ");
4744
Serial.println(ssid);
48-
// enable IPv6
49-
WiFi.enableIPv6(true);
45+
5046
// Manually connect to WiFi
5147
WiFi.begin(ssid, password);
5248
// Wait for connection

‎libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
// Color Temperature CW/WW Light Endpoint
2222
MatterColorTemperatureLight CW_WW_Light;
2323

24+
// WiFi is manually set and started
25+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
26+
const char *password = "your-password"; // Change this to your WiFi password
27+
2428
// it will keep last OnOff & Brightness state stored, using Preferences
2529
Preferences matterPref;
2630
const char *onOffPrefKey = "OnOff";
@@ -44,10 +48,6 @@ bool button_state = false; // false = released | true = pres
4448
const uint32_t debouceTime = 250; // button debouncing time (ms)
4549
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
4650

47-
// WiFi is manually set and started
48-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
49-
const char *password = "your-password"; // Change this to your WiFi password
50-
5151
// Set the RGB LED Light based on the current state of the Color Temperature Light
5252
bool setLightState(bool state, uint8_t brightness, uint16_t temperature_Mireds) {
5353

@@ -83,15 +83,10 @@ void setup() {
8383
pinMode(ledPin, OUTPUT);
8484

8585
Serial.begin(115200);
86-
while (!Serial) {
87-
delay(100);
88-
}
8986

9087
// We start by connecting to a WiFi network
9188
Serial.print("Connecting to ");
9289
Serial.println(ssid);
93-
// enable IPv6
94-
WiFi.enableIPv6(true);
9590
// Manually connect to WiFi
9691
WiFi.begin(ssid, password);
9792
// Wait for connection

‎libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
// Matter Temperature Sensor Endpoint
2828
MatterTemperatureSensor SimulatedTemperatureSensor;
2929

30+
// WiFi is manually set and started
31+
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
32+
const char *password = "your-password"; // Change this to your WiFi password
33+
3034
// set your board USER BUTTON pin here - decommissioning button
3135
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
3236

@@ -35,10 +39,6 @@ uint32_t button_time_stamp = 0; // debouncing control
3539
bool button_state = false; // false = released | true = pressed
3640
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
3741

38-
// WiFi is manually set and started
39-
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
40-
const char *password = "your-password"; // Change this to your WiFi password
41-
4242
// Simulate a temperature sensor - add your preferred temperature sensor library code here
4343
float getSimulatedTemperature() {
4444
// The Endpoint implementation keeps an int16_t as internal value information,

‎libraries/Matter/src/MatterEndpoints/MatterColorLight.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ bool MatterColorLight::setOnOff(bool newState) {
206206
return false;
207207
}
208208

209-
// avoid processing the a "no-change"
209+
// avoid processing if there was no change
210210
if (onOffState == newState) {
211211
return true;
212212
}
@@ -256,7 +256,7 @@ bool MatterColorLight::setColorHSV(espHsvColor_t _hsvColor) {
256256
return false;
257257
}
258258

259-
// avoid processing the a "no-change"
259+
// avoid processing if there was no change
260260
if (colorHSV.h == _hsvColor.h && colorHSV.s == _hsvColor.s && colorHSV.v == _hsvColor.v) {
261261
return true;
262262
}

‎libraries/Matter/src/MatterEndpoints/MatterColorLight.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ class MatterColorLight : public MatterEndPoint {
3737
bool setColorHSV(espHsvColor_t hsvColor); // returns true if successful
3838
espHsvColor_t getColorHSV(); // returns current HSV Color
3939

40-
// used to update the state of the light using the current Matter Light internal state
41-
// It is necessary to set a user callback function using onChange() to handle the physical light state
42-
void updateAccessory();
43-
44-
operator bool(); // returns current on/off light state
45-
void operator=(bool state); // turns light on or off
46-
47-
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
48-
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
49-
5040
// User Callback for whenever the Light On/Off state is changed by the Matter Controller
5141
using EndPointOnOffCB = std::function<bool(bool)>;
5242
void onChangeOnOff(EndPointOnOffCB onChangeCB) {
@@ -64,6 +54,16 @@ class MatterColorLight : public MatterEndPoint {
6454
_onChangeCB = onChangeCB;
6555
}
6656

57+
// used to update the state of the light using the current Matter Light internal state
58+
// It is necessary to set a user callback function using onChange() to handle the physical light state
59+
void updateAccessory();
60+
61+
operator bool(); // returns current on/off light state
62+
void operator=(bool state); // turns light on or off
63+
64+
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
65+
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
66+
6767
protected:
6868
bool started = false;
6969
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)

‎libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ bool MatterColorTemperatureLight::setOnOff(bool newState) {
138138
return false;
139139
}
140140

141-
// avoid processing the a "no-change"
141+
// avoid processing if there was no change
142142
if (onOffState == newState) {
143143
return true;
144144
}
@@ -179,7 +179,7 @@ bool MatterColorTemperatureLight::setBrightness(uint8_t newBrightness) {
179179
return false;
180180
}
181181

182-
// avoid processing the a "no-change"
182+
// avoid processing if there was no change
183183
if (brightnessLevel == newBrightness) {
184184
return true;
185185
}
@@ -210,7 +210,7 @@ bool MatterColorTemperatureLight::setColorTemperature(uint16_t newTemperature) {
210210
return false;
211211
}
212212

213-
// avoid processing the a "no-change"
213+
// avoid processing if there was no change
214214
if (colorTemperatureLevel == newTemperature) {
215215
return true;
216216
}

‎libraries/Matter/src/MatterEndpoints/MatterColorTemperatureLight.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ class MatterColorTemperatureLight : public MatterEndPoint {
4242
bool setColorTemperature(uint16_t newTemperature); // returns true if successful
4343
uint16_t getColorTemperature(); // returns current temperature
4444

45-
// used to update the state of the light using the current Matter Light internal state
46-
// It is necessary to set a user callback function using onChange() to handle the physical light state
47-
void updateAccessory();
48-
49-
operator bool(); // returns current on/off light state
50-
void operator=(bool state); // turns light on or off
51-
52-
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
53-
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
54-
5545
// User Callback for whenever the Light On/Off state is changed by the Matter Controller
5646
using EndPointOnOffCB = std::function<bool(bool)>;
5747
void onChangeOnOff(EndPointOnOffCB onChangeCB) {
@@ -76,6 +66,16 @@ class MatterColorTemperatureLight : public MatterEndPoint {
7666
_onChangeCB = onChangeCB;
7767
}
7868

69+
// used to update the state of the light using the current Matter Light internal state
70+
// It is necessary to set a user callback function using onChange() to handle the physical light state
71+
void updateAccessory();
72+
73+
operator bool(); // returns current on/off light state
74+
void operator=(bool state); // turns light on or off
75+
76+
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
77+
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
78+
7979
protected:
8080
bool started = false;
8181
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)

‎libraries/Matter/src/MatterEndpoints/MatterContactSensor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ bool MatterContactSensor::setContact(bool _contactState) {
6969
return false;
7070
}
7171

72-
// avoid processing the a "no-change"
72+
// avoid processing if there was no change
7373
if (contactState == _contactState) {
7474
return true;
7575
}

‎libraries/Matter/src/MatterEndpoints/MatterDimmableLight.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ bool MatterDimmableLight::setOnOff(bool newState) {
114114
return false;
115115
}
116116

117-
// avoid processing the a "no-change"
117+
// avoid processing if there was no change
118118
if (onOffState == newState) {
119119
return true;
120120
}
@@ -155,7 +155,7 @@ bool MatterDimmableLight::setBrightness(uint8_t newBrightness) {
155155
return false;
156156
}
157157

158-
// avoid processing the a "no-change"
158+
// avoid processing if there was no change
159159
if (brightnessLevel == newBrightness) {
160160
return true;
161161
}

‎libraries/Matter/src/MatterEndpoints/MatterDimmableLight.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,12 @@ class MatterDimmableLight : public MatterEndPoint {
3737
bool setBrightness(uint8_t newBrightness); // returns true if successful
3838
uint8_t getBrightness(); // returns current brightness
3939

40-
// used to update the state of the light using the current Matter Light internal state
41-
// It is necessary to set a user callback function using onChange() to handle the physical light state
42-
void updateAccessory();
43-
44-
operator bool(); // returns current on/off light state
45-
void operator=(bool state); // turns light on or off
46-
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
47-
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
4840
// User Callback for whenever the Light On/Off state is changed by the Matter Controller
4941
using EndPointOnOffCB = std::function<bool(bool)>;
5042
void onChangeOnOff(EndPointOnOffCB onChangeCB) {
5143
_onChangeOnOffCB = onChangeCB;
5244
}
45+
5346
// User Callback for whenever the Light brightness value [0..255] is changed by the Matter Controller
5447
using EndPointBrightnessCB = std::function<bool(uint8_t)>;
5548
void onChangeBrightness(EndPointBrightnessCB onChangeCB) {
@@ -62,6 +55,15 @@ class MatterDimmableLight : public MatterEndPoint {
6255
_onChangeCB = onChangeCB;
6356
}
6457

58+
// used to update the state of the light using the current Matter Light internal state
59+
// It is necessary to set a user callback function using onChange() to handle the physical light state
60+
void updateAccessory();
61+
62+
operator bool(); // returns current on/off light state
63+
void operator=(bool state); // turns light on or off
64+
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
65+
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
66+
6567
protected:
6668
bool started = false;
6769
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)

‎libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ bool MatterEnhancedColorLight::setOnOff(bool newState) {
226226
return false;
227227
}
228228

229-
// avoid processing the a "no-change"
229+
// avoid processing if there was no change
230230
if (onOffState == newState) {
231231
return true;
232232
}
@@ -267,7 +267,7 @@ bool MatterEnhancedColorLight::setBrightness(uint8_t newBrightness) {
267267
return false;
268268
}
269269

270-
// avoid processing the a "no-change"
270+
// avoid processing if there was no change
271271
if (brightnessLevel == newBrightness) {
272272
return true;
273273
}
@@ -298,7 +298,7 @@ bool MatterEnhancedColorLight::setColorTemperature(uint16_t newTemperature) {
298298
return false;
299299
}
300300

301-
// avoid processing the a "no-change"
301+
// avoid processing if there was no change
302302
if (colorTemperatureLevel == newTemperature) {
303303
return true;
304304
}
@@ -338,7 +338,7 @@ bool MatterEnhancedColorLight::setColorHSV(espHsvColor_t _hsvColor) {
338338
return false;
339339
}
340340

341-
// avoid processing the a "no-change"
341+
// avoid processing if there was no change
342342
if (colorHSV.h == _hsvColor.h && colorHSV.s == _hsvColor.s && colorHSV.v == _hsvColor.v) {
343343
return true;
344344
}

‎libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ class MatterEnhancedColorLight : public MatterEndPoint {
4747
bool setColorHSV(espHsvColor_t hsvColor); // returns true if successful
4848
espHsvColor_t getColorHSV(); // returns current HSV Color
4949

50-
// used to update the state of the light using the current Matter Light internal state
51-
// It is necessary to set a user callback function using onChange() to handle the physical light state
52-
void updateAccessory();
53-
54-
operator bool(); // returns current on/off light state
55-
void operator=(bool state); // turns light on or off
56-
57-
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
58-
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
59-
6050
// User Callback for whenever the Light On/Off state is changed by the Matter Controller
6151
using EndPointOnOffCB = std::function<bool(bool)>;
6252
void onChangeOnOff(EndPointOnOffCB onChangeCB) {
@@ -87,6 +77,16 @@ class MatterEnhancedColorLight : public MatterEndPoint {
8777
_onChangeCB = onChangeCB;
8878
}
8979

80+
// used to update the state of the light using the current Matter Light internal state
81+
// It is necessary to set a user callback function using onChange() to handle the physical light state
82+
void updateAccessory();
83+
84+
operator bool(); // returns current on/off light state
85+
void operator=(bool state); // turns light on or off
86+
87+
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
88+
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
89+
9090
protected:
9191
bool started = false;
9292
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)

‎libraries/Matter/src/MatterEndpoints/MatterFan.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ bool MatterFan::setMode(FanMode_t newMode, bool performUpdate) {
118118
log_w("Matter Fan device has not begun.");
119119
return false;
120120
}
121-
// avoid processing the a "no-change"
121+
// avoid processing if there was no change
122122
if (currentFanMode == newMode) {
123123
return true;
124124
}
@@ -159,7 +159,7 @@ bool MatterFan::setSpeedPercent(uint8_t newPercent, bool performUpdate) {
159159
log_w("Matter Fan device has not begun.");
160160
return false;
161161
}
162-
// avoid processing the a "no-change"
162+
// avoid processing if there was no change
163163
if (currentPercent == newPercent) {
164164
return true;
165165
}
@@ -193,7 +193,7 @@ bool MatterFan::setOnOff(bool newState, bool performUpdate) {
193193
log_w("Matter Fan device has not begun.");
194194
return false;
195195
}
196-
// avoid processing the a "no-change"
196+
// avoid processing if there was no change
197197
if (getOnOff() == newState) {
198198
return true;
199199
}

‎libraries/Matter/src/MatterEndpoints/MatterFan.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ class MatterFan : public MatterEndPoint {
9898
operator uint8_t() {
9999
return getSpeedPercent();
100100
}
101-
// sets Fan speed percent
102-
void operator=(uint8_t speedPercent) {
103-
setSpeedPercent(speedPercent);
104-
}
105-
106-
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
107-
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
108101

109102
// User Callback for whenever the Fan Mode (state) is changed by the Matter Controller
110103
using EndPointModeCB = std::function<bool(FanMode_t)>;
@@ -124,6 +117,14 @@ class MatterFan : public MatterEndPoint {
124117
_onChangeCB = onChangeCB;
125118
}
126119

120+
// sets Fan speed percent
121+
void operator=(uint8_t speedPercent) {
122+
setSpeedPercent(speedPercent);
123+
}
124+
125+
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
126+
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
127+
127128
protected:
128129
bool started = false;
129130
uint8_t validFanModes = 0; // bitmap for valid Fan Modes - index of fanModeSequence[]

‎libraries/Matter/src/MatterEndpoints/MatterHumiditySensor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ bool MatterHumiditySensor::setRawHumidity(uint16_t _rawHumidity) {
8282
return false;
8383
}
8484

85-
// avoid processing the a "no-change"
85+
// avoid processing if there was no change
8686
if (rawHumidity == _rawHumidity) {
8787
return true;
8888
}
@@ -98,7 +98,7 @@ bool MatterHumiditySensor::setRawHumidity(uint16_t _rawHumidity) {
9898
bool ret;
9999
ret = updateAttributeVal(RelativeHumidityMeasurement::Id, RelativeHumidityMeasurement::Attributes::MeasuredValue::Id, &humidityVal);
100100
if (!ret) {
101-
log_e("Failed to update Fan Speed Percent Attribute.");
101+
log_e("Failed to update Humidity Sensor Attribute.");
102102
return false;
103103
}
104104
rawHumidity = _rawHumidity;

‎libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ bool MatterOccupancySensor::setOccupancy(bool _occupancyState) {
8080
return false;
8181
}
8282

83-
// avoid processing the a "no-change"
83+
// avoid processing if there was no change
8484
if (occupancyState == _occupancyState) {
8585
return true;
8686
}

‎libraries/Matter/src/MatterEndpoints/MatterOnOffLight.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ bool MatterOnOffLight::setOnOff(bool newState) {
9494
return false;
9595
}
9696

97-
// avoid processing the a "no-change"
97+
// avoid processing if there was no change
9898
if (onOffState == newState) {
9999
return true;
100100
}

‎libraries/Matter/src/MatterEndpoints/MatterOnOffLight.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,27 @@ class MatterOnOffLight : public MatterEndPoint {
3030
bool getOnOff(); // returns current light state
3131
bool toggle(); // returns true if successful
3232

33-
// used to update the state of the light using the current Matter Light internal state
34-
// It is necessary to set a user callback function using onChange() to handle the physical light state
35-
void updateAccessory();
36-
37-
operator bool(); // returns current light state
38-
void operator=(bool state); // turns light on or off
39-
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
40-
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
4133
// User Callback for whenever the Light state is changed by the Matter Controller
4234
using EndPointCB = std::function<bool(bool)>;
4335
void onChange(EndPointCB onChangeCB) {
4436
_onChangeCB = onChangeCB;
4537
}
38+
39+
// User Callback for whenever the Light On/Off state is changed by the Matter Controller
4640
void onChangeOnOff(EndPointCB onChangeCB) {
4741
_onChangeOnOffCB = onChangeCB;
4842
}
4943

44+
// used to update the state of the light using the current Matter Light internal state
45+
// It is necessary to set a user callback function using onChange() to handle the physical light state
46+
void updateAccessory();
47+
48+
operator bool(); // returns current light state
49+
void operator=(bool state); // turns light on or off
50+
51+
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
52+
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
53+
5054
protected:
5155
bool started = false;
5256
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)

‎libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ bool MatterOnOffPlugin::setOnOff(bool newState) {
9393
return false;
9494
}
9595

96-
// avoid processing the a "no-change"
96+
// avoid processing if there was no change
9797
if (onOffState == newState) {
9898
return true;
9999
}

‎libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,27 @@ class MatterOnOffPlugin : public MatterEndPoint {
3030
bool getOnOff(); // returns current plugin state
3131
bool toggle(); // returns true if successful
3232

33-
// used to update the state of the plugin using the current Matter Plugin internal state
34-
// It is necessary to set a user callback function using onChange() to handle the physical plugin state
35-
void updateAccessory();
36-
37-
operator bool(); // returns current plugin state
38-
void operator=(bool state); // turns plugin on or off
39-
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
40-
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
4133
// User Callback for whenever the Plugin state is changed by the Matter Controller
4234
using EndPointCB = std::function<bool(bool)>;
4335
void onChange(EndPointCB onChangeCB) {
4436
_onChangeCB = onChangeCB;
4537
}
38+
39+
// User Callback for whenever the On/Off state is changed by the Matter Controller
4640
void onChangeOnOff(EndPointCB onChangeCB) {
4741
_onChangeOnOffCB = onChangeCB;
4842
}
4943

44+
// used to update the state of the plugin using the current Matter Plugin internal state
45+
// It is necessary to set a user callback function using onChange() to handle the physical plugin state
46+
void updateAccessory();
47+
48+
operator bool(); // returns current plugin state
49+
void operator=(bool state); // turns plugin on or off
50+
51+
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary.
52+
bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
53+
5054
protected:
5155
bool started = false;
5256
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)

‎libraries/Matter/src/MatterEndpoints/MatterPressureSensor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ bool MatterPressureSensor::setRawPressure(int16_t _rawPressure) {
7070
return false;
7171
}
7272

73-
// avoid processing the a "no-change"
73+
// avoid processing if there was no change
7474
if (rawPressure == _rawPressure) {
7575
return true;
7676
}

‎libraries/Matter/src/MatterEndpoints/MatterPressureSensor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class MatterPressureSensor : public MatterEndPoint {
3939
double getPressure() {
4040
return (double)rawPressure;
4141
}
42+
4243
// double conversion operator
4344
void operator=(double pressure) {
4445
setPressure(pressure);

‎libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) {
7070
return false;
7171
}
7272

73-
// avoid processing the a "no-change"
73+
// avoid processing if there was no change
7474
if (rawTemperature == _rawTemperature) {
7575
return true;
7676
}
@@ -86,7 +86,7 @@ bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) {
8686
bool ret;
8787
ret = updateAttributeVal(TemperatureMeasurement::Id, TemperatureMeasurement::Attributes::MeasuredValue::Id, &temperatureVal);
8888
if (!ret) {
89-
log_e("Failed to update Fan Speed Percent Attribute.");
89+
log_e("Failed to update Temperature Sensor Attribute.");
9090
return false;
9191
}
9292
rawTemperature = _rawTemperature;

‎libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class MatterTemperatureSensor : public MatterEndPoint {
4040
double getTemperature() {
4141
return (double)rawTemperature / 100.0;
4242
}
43+
4344
// double conversion operator
4445
void operator=(double temperature) {
4546
setTemperature(temperature);

0 commit comments

Comments
 (0)
Please sign in to comment.