Skip to content

Commit c3866bb

Browse files
authored
feat(matter): add a new example for a minimum matter device
1 parent 6bc3ce6 commit c3866bb

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/*
16+
* This example ha the smallest code that will create a Matter Device which can be
17+
* commissioned and controlled from a Matter Environment APP.
18+
* It doesn't control any light, but the ESP32 will send debug messages indicating the Matter activity.
19+
* Therefore, turning DEBUG Level may be useful to follow Matter Accessory and Controller messages.
20+
*/
21+
22+
// Matter Manager
23+
#include <Matter.h>
24+
#include <WiFi.h>
25+
26+
// List of Matter Endpoints for this Node
27+
// Single On/Off Light Endpoint - at least one per node
28+
MatterOnOffLight OnOffLight;
29+
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+
34+
void setup() {
35+
WiFi.enableIPv6(true);
36+
// Manually connect to WiFi
37+
WiFi.begin(ssid, password);
38+
// Wait for connection
39+
while (WiFi.status() != WL_CONNECTED) {
40+
delay(500);
41+
}
42+
43+
// Initialize at least one Matter EndPoint
44+
OnOffLight.begin();
45+
46+
// Matter beginning - Last step, after all EndPoints are initialized
47+
Matter.begin();
48+
49+
if (!Matter.isDeviceCommissioned()) {
50+
log_i("Matter Node is not commissioned yet.");
51+
log_i("Initiate the device discovery in your Matter environment.");
52+
log_i("Commission it to your Matter hub with the manual pairing code or QR code");
53+
log_i("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str());
54+
log_i("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str());
55+
}
56+
}
57+
58+
void loop() {
59+
delay(500);
60+
}

0 commit comments

Comments
 (0)