Skip to content

feat(matter): enables BLE Matter commissioning with NimBLE #11537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ set(ARDUINO_LIBRARY_Matter_SRCS
libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp
libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp
libraries/Matter/src/MatterEndpoints/MatterThermostat.cpp
libraries/Matter/src/Matter.cpp)
libraries/Matter/src/Matter.cpp
libraries/Matter/src/MatterEndPoint.cpp)

set(ARDUINO_LIBRARY_PPP_SRCS
libraries/PPP/src/PPP.cpp
Expand Down
15 changes: 12 additions & 3 deletions libraries/Matter/examples/MatterColorLight/MatterColorLight.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,22 @@

// Matter Manager
#include <Matter.h>
#if !CONFIG_ENABLE_CHIPOBLE
// if the device can be commissioned using BLE, WiFi is not used - save flash space
#include <WiFi.h>
#endif
#include <Preferences.h>

// List of Matter Endpoints for this Node
// Color Light Endpoint
MatterColorLight ColorLight;

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

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

Serial.begin(115200);

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

// Initialize Matter EndPoint
matterPref.begin("MatterPrefs", false);
Expand All @@ -121,7 +130,7 @@ void setup() {
Matter.begin();
// This may be a restart of a already commissioned Matter accessory
if (Matter.isDeviceCommissioned()) {
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
Serial.printf(
"Initial state: %s | RGB Color: (%d,%d,%d) \r\n", ColorLight ? "ON" : "OFF", ColorLight.getColorRGB().r, ColorLight.getColorRGB().g,
ColorLight.getColorRGB().b
Expand Down Expand Up @@ -154,7 +163,7 @@ void loop() {
);
// configure the Light based on initial on-off state and its color
ColorLight.updateAccessory();
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
}

// A button is also used to control the light
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,19 +14,27 @@

// Matter Manager
#include <Matter.h>
#if !CONFIG_ENABLE_CHIPOBLE
// if the device can be commissioned using BLE, WiFi is not used - save flash space
#include <WiFi.h>
#endif

// List of Matter Endpoints for this Node
// On/Off Light Endpoint
MatterOnOffLight OnOffLight;

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

void setup() {
Serial.begin(115200);

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

// Initialize at least one Matter EndPoint
OnOffLight.begin();
Expand All @@ -64,7 +73,7 @@ void loop() {
Serial.println("Matter Fabric not commissioned yet. Waiting for commissioning.");
}
}
Serial.println("Matter Node is commissioned and connected to Wi-Fi.");
Serial.println("Matter Node is commissioned and connected to the network.");
Serial.println("====> Decommissioning in 30 seconds. <====");
delay(30000);
Matter.decommission();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,17 +14,23 @@

// Matter Manager
#include <Matter.h>
#if !CONFIG_ENABLE_CHIPOBLE
// if the device can be commissioned using BLE, WiFi is not used - save flash space
#include <WiFi.h>
#endif

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

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

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

Serial.begin(115200);

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

// Initialize all 3 Matter EndPoints
Light1.begin();
Expand Down Expand Up @@ -103,7 +112,7 @@ void loop() {
Serial.println("Matter Node not commissioned yet. Waiting for commissioning.");
}
}
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
}

//displays the Light state every 5 seconds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,15 +30,21 @@

// Matter Manager
#include <Matter.h>
#if !CONFIG_ENABLE_CHIPOBLE
// if the device can be commissioned using BLE, WiFi is not used - save flash space
#include <WiFi.h>
#endif

// List of Matter Endpoints for this Node
// Matter Contact Sensor Endpoint
MatterContactSensor ContactSensor;

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

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

Serial.begin(115200);

// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
#if !CONFIG_ENABLE_CHIPOBLE
// Manually connect to WiFi
WiFi.begin(ssid, password);
// Wait for connection
Expand All @@ -75,6 +83,7 @@ void setup() {
Serial.print(".");
}
Serial.println();
#endif

// set initial contact sensor state as false (default)
ContactSensor.begin();
Expand All @@ -99,7 +108,7 @@ void setup() {
Serial.println("Matter Node not commissioned yet. Waiting for commissioning.");
}
}
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,22 @@

// Matter Manager
#include <Matter.h>
#if !CONFIG_ENABLE_CHIPOBLE
// if the device can be commissioned using BLE, WiFi is not used - save flash space
#include <WiFi.h>
#endif
#include <Preferences.h>

// List of Matter Endpoints for this Node
// Dimmable Light Endpoint
MatterDimmableLight DimmableLight;

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

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

Serial.begin(115200);

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

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

// A button is also used to control the light
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,22 @@

// Matter Manager
#include <Matter.h>
#if !CONFIG_ENABLE_CHIPOBLE
// if the device can be commissioned using BLE, WiFi is not used - save flash space
#include <WiFi.h>
#endif
#include <Preferences.h>

// List of Matter Endpoints for this Node
// Color Light Endpoint
MatterEnhancedColorLight EnhancedColorLight;

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

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

Serial.begin(115200);

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

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

// A button is also used to control the light
Expand Down
9 changes: 9 additions & 0 deletions libraries/Matter/examples/MatterEvents/MatterEvents.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@

// Matter Manager
#include <Matter.h>
#if !CONFIG_ENABLE_CHIPOBLE
// if the device can be commissioned using BLE, WiFi is not used - save flash space
#include <WiFi.h>
#endif

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

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

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

// Initialize at least one Matter EndPoint
OnOffLight.begin();
Expand Down
Loading
Loading