File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
libraries/Matter/examples/MatterMinimum Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 27
27
// Single On/Off Light Endpoint - at least one per node
28
28
MatterOnOffLight OnOffLight;
29
29
30
+ // Light GPIO that can be controlled by Matter APP
31
+ #ifdef LED_BUILTIN
32
+ const uint8_t ledPin = LED_BUILTIN;
33
+ #else
34
+ const uint8_t ledPin = 2 ; // Set your pin here if your board has not defined LED_BUILTIN
35
+ #endif
36
+
37
+ // Matter Protocol Endpoint (On/OFF Light) Callback
38
+ bool matterCB (bool state) {
39
+ digitalWrite (ledPin, state ? HIGH : LOW);
40
+ // This callback must return the success state to Matter core
41
+ return true ;
42
+ }
43
+
30
44
// WiFi is manually set and started
31
45
const char *ssid = " your-ssid" ; // Change this to your WiFi SSID
32
46
const char *password = " your-password" ; // Change this to your WiFi password
33
47
34
48
void setup () {
49
+ // Initialise the LED GPIO
50
+ pinMode (ledPin, OUTPUT);
51
+
35
52
WiFi.enableIPv6 (true );
36
53
// Manually connect to WiFi
37
54
WiFi.begin (ssid, password);
@@ -43,6 +60,9 @@ void setup() {
43
60
// Initialize at least one Matter EndPoint
44
61
OnOffLight.begin ();
45
62
63
+ // Associate a callback to the Matter Controller
64
+ OnOffLight.onChange (matterCB);
65
+
46
66
// Matter beginning - Last step, after all EndPoints are initialized
47
67
Matter.begin ();
48
68
You can’t perform that action at this time.
0 commit comments