28
28
// Single On/Off Light Endpoint - at least one per node
29
29
MatterOnOffLight OnOffLight;
30
30
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
+
31
35
// Light GPIO that can be controlled by Matter APP
32
36
#ifdef LED_BUILTIN
33
37
const uint8_t ledPin = LED_BUILTIN;
@@ -44,23 +48,18 @@ bool button_state = false; // false = released | true = pres
44
48
const uint32_t decommissioningTimeout = 5000 ; // keep the button pressed for 5s, or longer, to decommission
45
49
46
50
// Matter Protocol Endpoint (On/OFF Light) Callback
47
- bool matterCB (bool state) {
51
+ bool onOffLightCallback (bool state) {
48
52
digitalWrite (ledPin, state ? HIGH : LOW);
49
53
// This callback must return the success state to Matter core
50
54
return true ;
51
55
}
52
56
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
-
57
57
void setup () {
58
58
// Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node
59
59
pinMode (buttonPin, INPUT_PULLUP);
60
60
// Initialize the LED GPIO
61
61
pinMode (ledPin, OUTPUT);
62
62
63
- WiFi.enableIPv6 (true );
64
63
// Manually connect to WiFi
65
64
WiFi.begin (ssid, password);
66
65
// Wait for connection
@@ -72,7 +71,7 @@ void setup() {
72
71
OnOffLight.begin ();
73
72
74
73
// Associate a callback to the Matter Controller
75
- OnOffLight.onChange (matterCB );
74
+ OnOffLight.onChange (onOffLightCallback );
76
75
77
76
// Matter beginning - Last step, after all EndPoints are initialized
78
77
Matter.begin ();
0 commit comments