Skip to content

Commit c2d2325

Browse files
feat(matter): enables BLE Matter commissioning with NimBLE (#11537)
* feat(matter): enables BLE Matter commissioning with NimBLE * fix(matter): commentary typo and formatting * fix(matter): commentary typo and formatting * fix(matter): removes forcing second network clustter * fix(matter): adds matter source code to CMakeLists.txt * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent d4e5c5f commit c2d2325

File tree

52 files changed

+447
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+447
-155
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ set(ARDUINO_LIBRARY_Matter_SRCS
184184
libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp
185185
libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp
186186
libraries/Matter/src/MatterEndpoints/MatterThermostat.cpp
187-
libraries/Matter/src/Matter.cpp)
187+
libraries/Matter/src/Matter.cpp
188+
libraries/Matter/src/MatterEndPoint.cpp)
188189

189190
set(ARDUINO_LIBRARY_PPP_SRCS
190191
libraries/PPP/src/PPP.cpp

libraries/Matter/examples/MatterColorLight/MatterColorLight.ino

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,16 +14,22 @@
1414

1515
// Matter Manager
1616
#include <Matter.h>
17+
#if !CONFIG_ENABLE_CHIPOBLE
18+
// if the device can be commissioned using BLE, WiFi is not used - save flash space
1719
#include <WiFi.h>
20+
#endif
1821
#include <Preferences.h>
1922

2023
// List of Matter Endpoints for this Node
2124
// Color Light Endpoint
2225
MatterColorLight ColorLight;
2326

27+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
28+
#if !CONFIG_ENABLE_CHIPOBLE
2429
// WiFi is manually set and started
2530
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
2631
const char *password = "your-password"; // Change this to your WiFi password
32+
#endif
2733

2834
// it will keep last OnOff & HSV Color state stored, using Preferences
2935
Preferences matterPref;
@@ -81,6 +87,8 @@ void setup() {
8187

8288
Serial.begin(115200);
8389

90+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
91+
#if !CONFIG_ENABLE_CHIPOBLE
8492
// We start by connecting to a WiFi network
8593
Serial.print("Connecting to ");
8694
Serial.println(ssid);
@@ -95,6 +103,7 @@ void setup() {
95103
Serial.println("IP address: ");
96104
Serial.println(WiFi.localIP());
97105
delay(500);
106+
#endif
98107

99108
// Initialize Matter EndPoint
100109
matterPref.begin("MatterPrefs", false);
@@ -121,7 +130,7 @@ void setup() {
121130
Matter.begin();
122131
// This may be a restart of a already commissioned Matter accessory
123132
if (Matter.isDeviceCommissioned()) {
124-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
133+
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
125134
Serial.printf(
126135
"Initial state: %s | RGB Color: (%d,%d,%d) \r\n", ColorLight ? "ON" : "OFF", ColorLight.getColorRGB().r, ColorLight.getColorRGB().g,
127136
ColorLight.getColorRGB().b
@@ -154,7 +163,7 @@ void loop() {
154163
);
155164
// configure the Light based on initial on-off state and its color
156165
ColorLight.updateAccessory();
157-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
166+
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
158167
}
159168

160169
// A button is also used to control the light

libraries/Matter/examples/MatterCommissionTest/MatterCommissionTest.ino

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,19 +14,27 @@
1414

1515
// Matter Manager
1616
#include <Matter.h>
17+
#if !CONFIG_ENABLE_CHIPOBLE
18+
// if the device can be commissioned using BLE, WiFi is not used - save flash space
1719
#include <WiFi.h>
20+
#endif
1821

1922
// List of Matter Endpoints for this Node
2023
// On/Off Light Endpoint
2124
MatterOnOffLight OnOffLight;
2225

26+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
27+
#if !CONFIG_ENABLE_CHIPOBLE
2328
// WiFi is manually set and started
2429
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
2530
const char *password = "your-password"; // Change this to your WiFi password
31+
#endif
2632

2733
void setup() {
2834
Serial.begin(115200);
2935

36+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
37+
#if !CONFIG_ENABLE_CHIPOBLE
3038
// We start by connecting to a WiFi network
3139
Serial.print("Connecting to ");
3240
Serial.println(ssid);
@@ -41,6 +49,7 @@ void setup() {
4149
Serial.println("IP address: ");
4250
Serial.println(WiFi.localIP());
4351
delay(500);
52+
#endif
4453

4554
// Initialize at least one Matter EndPoint
4655
OnOffLight.begin();
@@ -64,7 +73,7 @@ void loop() {
6473
Serial.println("Matter Fabric not commissioned yet. Waiting for commissioning.");
6574
}
6675
}
67-
Serial.println("Matter Node is commissioned and connected to Wi-Fi.");
76+
Serial.println("Matter Node is commissioned and connected to the network.");
6877
Serial.println("====> Decommissioning in 30 seconds. <====");
6978
delay(30000);
7079
Matter.decommission();

libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,17 +14,23 @@
1414

1515
// Matter Manager
1616
#include <Matter.h>
17+
#if !CONFIG_ENABLE_CHIPOBLE
18+
// if the device can be commissioned using BLE, WiFi is not used - save flash space
1719
#include <WiFi.h>
20+
#endif
1821

1922
// List of Matter Endpoints for this Node
2023
// There will be 3 On/Off Light Endpoints in the same Node
2124
MatterOnOffLight Light1;
2225
MatterDimmableLight Light2;
2326
MatterColorLight Light3;
2427

28+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
29+
#if !CONFIG_ENABLE_CHIPOBLE
2530
// WiFi is manually set and started
2631
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
2732
const char *password = "your-password"; // Change this to your WiFi password
33+
#endif
2834

2935
// set your board USER BUTTON pin here - USED to decommission the Matter Node
3036
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
@@ -56,6 +62,8 @@ void setup() {
5662

5763
Serial.begin(115200);
5864

65+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
66+
#if !CONFIG_ENABLE_CHIPOBLE
5967
// We start by connecting to a WiFi network
6068
Serial.print("Connecting to ");
6169
Serial.println(ssid);
@@ -71,6 +79,7 @@ void setup() {
7179
Serial.println("IP address: ");
7280
Serial.println(WiFi.localIP());
7381
delay(500);
82+
#endif
7483

7584
// Initialize all 3 Matter EndPoints
7685
Light1.begin();
@@ -103,7 +112,7 @@ void loop() {
103112
Serial.println("Matter Node not commissioned yet. Waiting for commissioning.");
104113
}
105114
}
106-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
115+
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
107116
}
108117

109118
//displays the Light state every 5 seconds

libraries/Matter/examples/MatterContactSensor/MatterContactSensor.ino

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -30,15 +30,21 @@
3030

3131
// Matter Manager
3232
#include <Matter.h>
33+
#if !CONFIG_ENABLE_CHIPOBLE
34+
// if the device can be commissioned using BLE, WiFi is not used - save flash space
3335
#include <WiFi.h>
36+
#endif
3437

3538
// List of Matter Endpoints for this Node
3639
// Matter Contact Sensor Endpoint
3740
MatterContactSensor ContactSensor;
3841

42+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
43+
#if !CONFIG_ENABLE_CHIPOBLE
3944
// WiFi is manually set and started
4045
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
4146
const char *password = "your-password"; // Change this to your WiFi password
47+
#endif
4248

4349
// LED will be used to indicate the Contact Sensor state
4450
// set your board RGB LED pin here
@@ -67,6 +73,8 @@ void setup() {
6773

6874
Serial.begin(115200);
6975

76+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
77+
#if !CONFIG_ENABLE_CHIPOBLE
7078
// Manually connect to WiFi
7179
WiFi.begin(ssid, password);
7280
// Wait for connection
@@ -75,6 +83,7 @@ void setup() {
7583
Serial.print(".");
7684
}
7785
Serial.println();
86+
#endif
7887

7988
// set initial contact sensor state as false (default)
8089
ContactSensor.begin();
@@ -99,7 +108,7 @@ void setup() {
99108
Serial.println("Matter Node not commissioned yet. Waiting for commissioning.");
100109
}
101110
}
102-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
111+
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
103112
}
104113
}
105114

libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,16 +14,22 @@
1414

1515
// Matter Manager
1616
#include <Matter.h>
17+
#if !CONFIG_ENABLE_CHIPOBLE
18+
// if the device can be commissioned using BLE, WiFi is not used - save flash space
1719
#include <WiFi.h>
20+
#endif
1821
#include <Preferences.h>
1922

2023
// List of Matter Endpoints for this Node
2124
// Dimmable Light Endpoint
2225
MatterDimmableLight DimmableLight;
2326

27+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
28+
#if !CONFIG_ENABLE_CHIPOBLE
2429
// WiFi is manually set and started
2530
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
2631
const char *password = "your-password"; // Change this to your WiFi password
32+
#endif
2733

2834
// it will keep last OnOff & Brightness state stored, using Preferences
2935
Preferences matterPref;
@@ -77,6 +83,8 @@ void setup() {
7783

7884
Serial.begin(115200);
7985

86+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
87+
#if !CONFIG_ENABLE_CHIPOBLE
8088
// We start by connecting to a WiFi network
8189
Serial.print("Connecting to ");
8290
Serial.println(ssid);
@@ -91,6 +99,7 @@ void setup() {
9199
Serial.println("IP address: ");
92100
Serial.println(WiFi.localIP());
93101
delay(500);
102+
#endif
94103

95104
// Initialize Matter EndPoint
96105
matterPref.begin("MatterPrefs", false);
@@ -116,7 +125,7 @@ void setup() {
116125
Matter.begin();
117126
// This may be a restart of a already commissioned Matter accessory
118127
if (Matter.isDeviceCommissioned()) {
119-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
128+
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
120129
Serial.printf("Initial state: %s | brightness: %d\r\n", DimmableLight ? "ON" : "OFF", DimmableLight.getBrightness());
121130
// configure the Light based on initial on-off state and brightness
122131
DimmableLight.updateAccessory();
@@ -143,7 +152,7 @@ void loop() {
143152
Serial.printf("Initial state: %s | brightness: %d\r\n", DimmableLight ? "ON" : "OFF", DimmableLight.getBrightness());
144153
// configure the Light based on initial on-off state and brightness
145154
DimmableLight.updateAccessory();
146-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
155+
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
147156
}
148157

149158
// A button is also used to control the light

libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -14,16 +14,22 @@
1414

1515
// Matter Manager
1616
#include <Matter.h>
17+
#if !CONFIG_ENABLE_CHIPOBLE
18+
// if the device can be commissioned using BLE, WiFi is not used - save flash space
1719
#include <WiFi.h>
20+
#endif
1821
#include <Preferences.h>
1922

2023
// List of Matter Endpoints for this Node
2124
// Color Light Endpoint
2225
MatterEnhancedColorLight EnhancedColorLight;
2326

27+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
28+
#if !CONFIG_ENABLE_CHIPOBLE
2429
// WiFi is manually set and started
2530
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
2631
const char *password = "your-password"; // Change this to your WiFi password
32+
#endif
2733

2834
// It will use HSV color to control all Matter Attribute Changes
2935
HsvColor_t currentHSVColor = {0, 0, 0};
@@ -85,6 +91,8 @@ void setup() {
8591

8692
Serial.begin(115200);
8793

94+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
95+
#if !CONFIG_ENABLE_CHIPOBLE
8896
// We start by connecting to a WiFi network
8997
Serial.print("Connecting to ");
9098
Serial.println(ssid);
@@ -99,6 +107,7 @@ void setup() {
99107
Serial.println("IP address: ");
100108
Serial.println(WiFi.localIP());
101109
delay(500);
110+
#endif
102111

103112
// Initialize Matter EndPoint
104113
matterPref.begin("MatterPrefs", false);
@@ -143,7 +152,7 @@ void setup() {
143152
Matter.begin();
144153
// This may be a restart of a already commissioned Matter accessory
145154
if (Matter.isDeviceCommissioned()) {
146-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
155+
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
147156
Serial.printf(
148157
"Initial state: %s | RGB Color: (%d,%d,%d) \r\n", EnhancedColorLight ? "ON" : "OFF", EnhancedColorLight.getColorRGB().r,
149158
EnhancedColorLight.getColorRGB().g, EnhancedColorLight.getColorRGB().b
@@ -176,7 +185,7 @@ void loop() {
176185
);
177186
// configure the Light based on initial on-off state and its color
178187
EnhancedColorLight.updateAccessory();
179-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
188+
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
180189
}
181190

182191
// A button is also used to control the light

libraries/Matter/examples/MatterEvents/MatterEvents.ino

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@
1414

1515
// Matter Manager
1616
#include <Matter.h>
17+
#if !CONFIG_ENABLE_CHIPOBLE
18+
// if the device can be commissioned using BLE, WiFi is not used - save flash space
1719
#include <WiFi.h>
20+
#endif
1821

22+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
23+
#if !CONFIG_ENABLE_CHIPOBLE
1924
// WiFi is manually set and started
2025
const char *ssid = "your-ssid"; // Change this to your WiFi SSID
2126
const char *password = "your-password"; // Change this to your WiFi password
27+
#endif
2228

2329
// List of Matter Endpoints for this Node
2430
// On/Off Light Endpoint
@@ -119,6 +125,8 @@ void setup() {
119125
delay(10); // Wait for Serial to initialize
120126
}
121127

128+
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
129+
#if !CONFIG_ENABLE_CHIPOBLE
122130
// We start by connecting to a WiFi network
123131
Serial.print("Connecting to ");
124132
Serial.println(ssid);
@@ -134,6 +142,7 @@ void setup() {
134142
Serial.println("IP address: ");
135143
Serial.println(WiFi.localIP());
136144
delay(500);
145+
#endif
137146

138147
// Initialize at least one Matter EndPoint
139148
OnOffLight.begin();

0 commit comments

Comments
 (0)