feat(matter): removing wifi requirement for H2 and C5 (#11581)
This PR removes WiFi provisioning support from CI and examples (shifting to Thread/BLE provisioning), updates the CI configs for all Matter examples to drop the WiFi requirement, and adds new API keywords and a fresh “LambdaSingleCallbackManyEPs” example. - Deleted the WiFiProvWithinMatter example (its .ino and ci.json) since BLE is now used for provisioning. - Stripped "CONFIG_SOC_WIFI_SUPPORTED=y" from the CI JSON of existing examples to test Thread-only builds. - Updated keywords.txt with new Matter API identifiers and introduced a new “LambdaSingleCallbackManyEPs” example with CI and source
This commit is contained in:
parent
fbf3c11daa
commit
c6a3bcb014
24 changed files with 153 additions and 191 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,126 @@
|
||||||
|
// 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.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
/*
|
||||||
|
This example create 6 on-off light endpoint that share the same onChangeOnOff() callback code.
|
||||||
|
It uses Lambda Function with an extra Lambda Capture information that links the Endpoint to its individual information.
|
||||||
|
After the Matter example is commissioned, the expected Serial output shall be similar to this:
|
||||||
|
|
||||||
|
Matter App Control: 'Room 1' (OnOffLight[0], Endpoint 1, GPIO 2) changed to: OFF
|
||||||
|
Matter App Control: 'Room 1' (OnOffLight[0], Endpoint 1, GPIO 2) changed to: ON
|
||||||
|
Matter App Control: 'Room 5' (OnOffLight[4], Endpoint 5, GPIO 10) changed to: ON
|
||||||
|
Matter App Control: 'Room 2' (OnOffLight[1], Endpoint 2, GPIO 4) changed to: ON
|
||||||
|
Matter App Control: 'Room 4' (OnOffLight[3], Endpoint 4, GPIO 8) changed to: ON
|
||||||
|
Matter App Control: 'Room 6' (OnOffLight[5], Endpoint 6, GPIO 12) changed to: ON
|
||||||
|
Matter App Control: 'Room 3' (OnOffLight[2], Endpoint 3, GPIO 6) changed to: ON
|
||||||
|
Matter App Control: 'Room 5' (OnOffLight[4], Endpoint 5, GPIO 10) changed to: OFF
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Matter Manager
|
||||||
|
#include <Matter.h>
|
||||||
|
#include <Preferences.h>
|
||||||
|
#if !CONFIG_ENABLE_CHIPOBLE
|
||||||
|
// if the device can be commissioned using BLE, WiFi is not used - save flash space
|
||||||
|
#include <WiFi.h>
|
||||||
|
// CONFIG_ENABLE_CHIPOBLE is enabled when BLE is used to commission the Matter Network
|
||||||
|
// 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
|
||||||
|
|
||||||
|
//number of On-Off Lights:
|
||||||
|
const uint8_t MAX_LIGHT_NUMBER = 6;
|
||||||
|
|
||||||
|
// array of OnOffLight endpoints
|
||||||
|
MatterOnOffLight OnOffLight[MAX_LIGHT_NUMBER];
|
||||||
|
|
||||||
|
// all pins, one for each on-off light
|
||||||
|
uint8_t lightPins[MAX_LIGHT_NUMBER] = {2, 4, 6, 8, 10, 12}; // must replace it by the real pin for the target SoC and application
|
||||||
|
|
||||||
|
// friendly OnOffLights names used for printing a message in the callback
|
||||||
|
const char *lightName[MAX_LIGHT_NUMBER] = {
|
||||||
|
"Room 1", "Room 2", "Room 3", "Room 4", "Room 5", "Room 6",
|
||||||
|
};
|
||||||
|
|
||||||
|
// simple setup() function
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200); // callback will just print a message in the console
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
// Manually connect to WiFi
|
||||||
|
WiFi.begin(ssid, password);
|
||||||
|
// Wait for connection
|
||||||
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
|
delay(500);
|
||||||
|
Serial.print(".");
|
||||||
|
}
|
||||||
|
Serial.println("\r\nWiFi connected");
|
||||||
|
Serial.println("IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
delay(500);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// setup all the OnOff Light endpoint and their lambda callback functions
|
||||||
|
for (uint8_t i = 0; i < MAX_LIGHT_NUMBER; i++) {
|
||||||
|
pinMode(lightPins[i], OUTPUT); // set the GPIO function
|
||||||
|
OnOffLight[i].begin(false); // off
|
||||||
|
|
||||||
|
// inline lambda function using capture array index -> it will just print a message in the console
|
||||||
|
OnOffLight[i].onChangeOnOff([i](bool state) -> bool {
|
||||||
|
// Display message with the specific light name and details
|
||||||
|
Serial.printf(
|
||||||
|
"Matter App Control: '%s' (OnOffLight[%d], Endpoint %d, GPIO %d) changed to: %s\r\n", lightName[i], i, OnOffLight[i].getEndPointId(), lightPins[i],
|
||||||
|
state ? "ON" : "OFF"
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// last step, starting Matter Stack
|
||||||
|
Matter.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// Check Matter Plugin Commissioning state, which may change during execution of loop()
|
||||||
|
if (!Matter.isDeviceCommissioned()) {
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("Matter Node is not commissioned yet.");
|
||||||
|
Serial.println("Initiate the device discovery in your Matter environment.");
|
||||||
|
Serial.println("Commission it to your Matter hub with the manual pairing code or QR code");
|
||||||
|
Serial.printf("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str());
|
||||||
|
Serial.printf("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str());
|
||||||
|
// waits for Matter Plugin Commissioning.
|
||||||
|
uint32_t timeCount = 0;
|
||||||
|
while (!Matter.isDeviceCommissioned()) {
|
||||||
|
delay(100);
|
||||||
|
if ((timeCount++ % 50) == 0) { // 50*100ms = 5 sec
|
||||||
|
Serial.println("Matter Node not commissioned yet. Waiting for commissioning.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Matter.isDeviceConnected()) {
|
||||||
|
Serial.println("Matter Node is commissioned and connected to the network. Ready for use.");
|
||||||
|
} else {
|
||||||
|
Serial.println("Matter Node is commissioned. Waiting for the network connection.");
|
||||||
|
}
|
||||||
|
// wait 3 seconds for the network connection
|
||||||
|
delay(3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
|
"requires": [
|
||||||
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
"fqbn_append": "PartitionScheme=huge_app",
|
||||||
"requires": [
|
"requires": [
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,152 +0,0 @@
|
||||||
/*
|
|
||||||
Please read README.md file in this folder, or on the web:
|
|
||||||
https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFiProv/examples/WiFiProv
|
|
||||||
|
|
||||||
Note: This sketch takes up a lot of space for the app and may not be able to flash with default setting on some chips.
|
|
||||||
If you see Error like this: "Sketch too big"
|
|
||||||
In Arduino IDE go to: Tools > Partition scheme > chose anything that has more than 1.4MB APP
|
|
||||||
- for example "No OTA (2MB APP/2MB SPIFFS)"
|
|
||||||
|
|
||||||
This example demonstrates that it is possible to provision WiFi using BLE or Software AP using
|
|
||||||
the ESP BLE Prov APP or ESP SoftAP Provisioning APP from Android Play or/and iOS APP Store
|
|
||||||
|
|
||||||
Once the WiFi is provisioned, Matter will start its process as usual.
|
|
||||||
|
|
||||||
This same Example could be used for any other WiFi Provisioning method.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Matter Manager
|
|
||||||
#include <Matter.h>
|
|
||||||
#include <WiFiProv.h>
|
|
||||||
#include <WiFi.h>
|
|
||||||
|
|
||||||
#if !CONFIG_BLUEDROID_ENABLED
|
|
||||||
#define USE_SOFT_AP // ESP32-S2 has no BLE, therefore, it shall use SoftAP Provisioning
|
|
||||||
#endif
|
|
||||||
//#define USE_SOFT_AP // Uncomment if you want to enforce using the Soft AP method instead of BLE
|
|
||||||
|
|
||||||
const char *pop = "abcd1234"; // Proof of possession - otherwise called a PIN - string provided by the device, entered by the user in the phone app
|
|
||||||
const char *service_name = "PROV_123"; // Name of your device (the Espressif apps expects by default device name starting with "Prov_")
|
|
||||||
const char *service_key = NULL; // Password used for SofAP method (NULL = no password needed)
|
|
||||||
bool reset_provisioned = true; // When true the library will automatically delete previously provisioned data.
|
|
||||||
|
|
||||||
// List of Matter Endpoints for this Node
|
|
||||||
// Single On/Off Light Endpoint - at least one per node
|
|
||||||
MatterOnOffLight OnOffLight;
|
|
||||||
|
|
||||||
// Light GPIO that can be controlled by Matter APP
|
|
||||||
#ifdef LED_BUILTIN
|
|
||||||
const uint8_t ledPin = LED_BUILTIN;
|
|
||||||
#else
|
|
||||||
const uint8_t ledPin = 2; // Set your pin here if your board has not defined LED_BUILTIN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set your board USER BUTTON pin here - decommissioning button
|
|
||||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
|
||||||
|
|
||||||
// Button control - decommision the Matter Node
|
|
||||||
uint32_t button_time_stamp = 0; // debouncing control
|
|
||||||
bool button_state = false; // false = released | true = pressed
|
|
||||||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
|
||||||
|
|
||||||
// Matter Protocol Endpoint (On/OFF Light) Callback
|
|
||||||
bool matterCB(bool state) {
|
|
||||||
digitalWrite(ledPin, state ? HIGH : LOW);
|
|
||||||
// This callback must return the success state to Matter core
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
// Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node
|
|
||||||
pinMode(buttonPin, INPUT_PULLUP);
|
|
||||||
|
|
||||||
Serial.begin(115200);
|
|
||||||
// Initialize the LED GPIO
|
|
||||||
pinMode(ledPin, OUTPUT);
|
|
||||||
|
|
||||||
WiFi.begin(); // no SSID/PWD - get it from the Provisioning APP or from NVS (last successful connection)
|
|
||||||
|
|
||||||
// BLE Provisioning using the ESP SoftAP Prov works fine for any BLE SoC, including ESP32, ESP32S3 and ESP32C3.
|
|
||||||
#if CONFIG_BLUEDROID_ENABLED && !defined(USE_SOFT_AP)
|
|
||||||
Serial.println("Begin Provisioning using BLE");
|
|
||||||
// Sample uuid that user can pass during provisioning using BLE
|
|
||||||
uint8_t uuid[16] = {0xb4, 0xdf, 0x5a, 0x1c, 0x3f, 0x6b, 0xf4, 0xbf, 0xea, 0x4a, 0x82, 0x03, 0x04, 0x90, 0x1a, 0x02};
|
|
||||||
WiFiProv.beginProvision(
|
|
||||||
NETWORK_PROV_SCHEME_BLE, NETWORK_PROV_SCHEME_HANDLER_FREE_BLE, NETWORK_PROV_SECURITY_1, pop, service_name, service_key, uuid, reset_provisioned
|
|
||||||
);
|
|
||||||
Serial.println("You may use this BLE QRCode:");
|
|
||||||
WiFiProv.printQR(service_name, pop, "ble");
|
|
||||||
#else
|
|
||||||
Serial.println("Begin Provisioning using Soft AP");
|
|
||||||
WiFiProv.beginProvision(NETWORK_PROV_SCHEME_SOFTAP, NETWORK_PROV_SCHEME_HANDLER_NONE, NETWORK_PROV_SECURITY_1, pop, service_name, service_key);
|
|
||||||
Serial.println("You may use this WiFi QRCode:");
|
|
||||||
WiFiProv.printQR(service_name, pop, "softap");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Wait for WiFi connection
|
|
||||||
uint32_t counter = 0;
|
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
|
||||||
// resets the device after 10 minutes
|
|
||||||
if (counter > 2 * 60 * 10) {
|
|
||||||
Serial.println("\r\n================================================");
|
|
||||||
Serial.println("Already 10 minutes past. The device will reboot.");
|
|
||||||
Serial.println("================================================\r\n");
|
|
||||||
Serial.flush(); // wait until the Serial has sent the whole message.
|
|
||||||
ESP.restart();
|
|
||||||
}
|
|
||||||
// WiFi searching feedback
|
|
||||||
Serial.print(".");
|
|
||||||
delay(500);
|
|
||||||
// adds a new line every 30 seconds
|
|
||||||
counter++;
|
|
||||||
if (!(counter % 60)) {
|
|
||||||
Serial.println();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WiFi shall be connected by now
|
|
||||||
Serial.println();
|
|
||||||
|
|
||||||
// Initialize at least one Matter EndPoint
|
|
||||||
OnOffLight.begin();
|
|
||||||
|
|
||||||
// Associate a callback to the Matter Controller
|
|
||||||
OnOffLight.onChange(matterCB);
|
|
||||||
|
|
||||||
// Matter beginning - Last step, after all EndPoints are initialized
|
|
||||||
Matter.begin();
|
|
||||||
|
|
||||||
while (!Matter.isDeviceCommissioned()) {
|
|
||||||
Serial.println("Matter Node is not commissioned yet.");
|
|
||||||
Serial.println("Initiate the device discovery in your Matter environment.");
|
|
||||||
Serial.println("Commission it to your Matter hub with the manual pairing code or QR code");
|
|
||||||
Serial.printf("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str());
|
|
||||||
Serial.printf("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str());
|
|
||||||
Serial.println();
|
|
||||||
// waits 30 seconds for Matter Commissioning, keeping it blocked until done
|
|
||||||
delay(30000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
// Check if the button has been pressed
|
|
||||||
if (digitalRead(buttonPin) == LOW && !button_state) {
|
|
||||||
// deals with button debouncing
|
|
||||||
button_time_stamp = millis(); // record the time while the button is pressed.
|
|
||||||
button_state = true; // pressed.
|
|
||||||
}
|
|
||||||
|
|
||||||
if (digitalRead(buttonPin) == HIGH && button_state) {
|
|
||||||
button_state = false; // released
|
|
||||||
}
|
|
||||||
|
|
||||||
// Onboard User Button is kept pressed for longer than 5 seconds in order to decommission matter node
|
|
||||||
uint32_t time_diff = millis() - button_time_stamp;
|
|
||||||
if (button_state && time_diff > decommissioningTimeout) {
|
|
||||||
Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again.");
|
|
||||||
Matter.decommission();
|
|
||||||
button_time_stamp = millis(); // avoid running decommissining again, reboot takes a second or so
|
|
||||||
}
|
|
||||||
|
|
||||||
delay(500);
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
{
|
|
||||||
"fqbn_append": "PartitionScheme=huge_app",
|
|
||||||
"requires": [
|
|
||||||
"CONFIG_SOC_WIFI_SUPPORTED=y",
|
|
||||||
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -36,8 +36,10 @@ EndPointSpeedCB KEYWORD1
|
||||||
EndPointOnOffCB KEYWORD1
|
EndPointOnOffCB KEYWORD1
|
||||||
EndPointBrightnessCB KEYWORD1
|
EndPointBrightnessCB KEYWORD1
|
||||||
EndPointRGBColorCB KEYWORD1
|
EndPointRGBColorCB KEYWORD1
|
||||||
|
EndPointIdentifyCB KEYWORD1
|
||||||
matterEvent_t KEYWORD1
|
matterEvent_t KEYWORD1
|
||||||
matterEventCB KEYWORD1
|
matterEventCB KEYWORD1
|
||||||
|
attrOperation_t KEYWORD1
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Methods and Functions (KEYWORD2)
|
# Methods and Functions (KEYWORD2)
|
||||||
|
|
@ -111,6 +113,12 @@ onChangeLocalTemperature KEYWORD2
|
||||||
onChangeCoolingSetpoint KEYWORD2
|
onChangeCoolingSetpoint KEYWORD2
|
||||||
onChangeHeatingSetpoint KEYWORD2
|
onChangeHeatingSetpoint KEYWORD2
|
||||||
onEvent KEYWORD2
|
onEvent KEYWORD2
|
||||||
|
setEndPointId KEYWORD2
|
||||||
|
getEndPointId KEYWORD2
|
||||||
|
getSecondaryNetworkEndPointId KEYWORD2
|
||||||
|
createSecondaryNetworkInterface KEYWORD2
|
||||||
|
onIdentify KEYWORD2
|
||||||
|
endpointIdentifyCB KEYWORD2
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Constants (LITERAL1)
|
# Constants (LITERAL1)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue