@@ -42,16 +42,11 @@ const uint8_t MAX_LIGHT_NUMBER = 6;
42
42
MatterOnOffLight OnOffLight[MAX_LIGHT_NUMBER];
43
43
44
44
// all pins, one for each on-off light
45
- uint8_t lightPins[MAX_LIGHT_NUMBER] = { 2 , 4 , 6 , 8 , 10 , 12 }; // must replace it by the real pin for the target SoC and application
45
+ uint8_t lightPins[MAX_LIGHT_NUMBER] = {2 , 4 , 6 , 8 , 10 , 12 }; // must replace it by the real pin for the target SoC and application
46
46
47
47
// friendly OnOffLights names used for printing a message in the callback
48
48
const char *lightName[MAX_LIGHT_NUMBER] = {
49
- " Room 1" ,
50
- " Room 2" ,
51
- " Room 3" ,
52
- " Room 4" ,
53
- " Room 5" ,
54
- " Room 6" ,
49
+ " Room 1" , " Room 2" , " Room 3" , " Room 4" , " Room 5" , " Room 6" ,
55
50
};
56
51
57
52
// simple setup() function
@@ -75,15 +70,16 @@ void setup() {
75
70
76
71
// setup all the OnOff Light endpoint and their lambda callback functions
77
72
for (uint8_t i = 0 ; i < MAX_LIGHT_NUMBER; i++) {
78
- pinMode ( lightPins[i], OUTPUT); // set the GPIO function
79
- OnOffLight[i].begin (false ); // off
73
+ pinMode (lightPins[i], OUTPUT); // set the GPIO function
74
+ OnOffLight[i].begin (false ); // off
80
75
81
76
// inline lambda function using capture array index -> it will just print a message in the console
82
77
OnOffLight[i].onChangeOnOff ([i](bool state) -> bool {
83
78
// Display message with the specific light name and details
84
- Serial.printf (" Matter App Control: '%s' (OnOffLight[%d], Endpoint %d, GPIO %d) changed to: %s\r\n " ,
85
- lightName[i], i, OnOffLight[i].getEndPointId (),
86
- lightPins[i], state ? " ON" : " OFF" );
79
+ Serial.printf (
80
+ " Matter App Control: '%s' (OnOffLight[%d], Endpoint %d, GPIO %d) changed to: %s\r\n " , lightName[i], i, OnOffLight[i].getEndPointId (), lightPins[i],
81
+ state ? " ON" : " OFF"
82
+ );
87
83
88
84
return true ;
89
85
});
@@ -110,7 +106,7 @@ void loop() {
110
106
}
111
107
}
112
108
Serial.println (" Matter Node is commissioned and connected to the WiFi network. Ready for use." );
113
- }
114
-
115
- delay (500 );
109
+ }
110
+
111
+ delay (500 );
116
112
}
0 commit comments