Skip to content

Commit 02110e0

Browse files
committed
fix(matter): fixing some ci problems
1 parent 66b5fcf commit 02110e0

File tree

6 files changed

+17
-181
lines changed

6 files changed

+17
-181
lines changed

Diff for: libraries/Matter/examples/MatterCommissionTest/MatterCommissionTest.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void setup() {
3838
// Initialize at least one Matter EndPoint
3939
OnOffLight.begin();
4040

41-
// Matter begining - Last step, after all EndPoints are initialized
41+
// Matter beginning - Last step, after all EndPoints are initialized
4242
Matter.begin();
4343
}
4444

Diff for: libraries/Matter/examples/MatterComposedLights/MatterComposedLights.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void setup() {
6161
OnOffLight2.onChangeOnOff(setLightOnOff2);
6262
OnOffLight3.onChangeOnOff(setLightOnOff3);
6363

64-
// Matter begining - Last step, after all EndPoints are initialized
64+
// Matter beginning - Last step, after all EndPoints are initialized
6565
Matter.begin();
6666
}
6767

+6-137
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,7 @@
1-
// Matter Manager
2-
#include <Matter.h>
3-
#include <WiFi.h>
4-
#include <Preferences.h>
5-
6-
// List of Matter Endpoints for this Node
7-
// On/Off Light Endpoint
8-
#include <MatterOnOffLight.h>
9-
MatterOnOffLight OnOffLight;
10-
11-
// it will keep last OnOff state stored, using Preferences
12-
Preferences lastStatePref;
13-
14-
// set your board LED pin here
15-
#ifdef LED_BUILTIN
16-
const uint8_t ledPin = LED_BUILTIN;
17-
#else
18-
const uint8_t ledPin = 2; // Set your pin here if your board has not defined LED_BUILTIN
19-
#warning "Do not forget to set the LED pin"
20-
#endif
21-
22-
// set your board USER BUTTON pin here
23-
const uint8_t buttonPin = 0; // Set your pin here. Using BOOT Button. C6/C3 use GPIO9.
24-
25-
// Matter Protocol Endpoint Callback
26-
bool setLightOnOff(bool state) {
27-
Serial.printf("User Callback :: New Light State = %s\r\n", state ? "ON" : "OFF");
28-
if (state) {
29-
digitalWrite(ledPin, HIGH);
30-
} else {
31-
digitalWrite(ledPin, LOW);
32-
}
33-
// store last OnOff state for when the Light is restarted / power goes off
34-
lastStatePref.putBool("lastOnOffState", state);
35-
// This callback must return the success state to Matter core
36-
return true;
37-
}
38-
39-
// WiFi is manually set and started
40-
41-
const char *ssid = "Apartment B15"; // Change this to your WiFi SSID
42-
const char *password = "flat-pony-body"; // Change this to your WiFi password
43-
44-
void setup() {
45-
// Initializa the USER BUTTON (Boot button) GPIO that will act as a toggle switch
46-
pinMode(buttonPin, INPUT_PULLUP);
47-
// Initialize the LED (light) GPIO and Matter End Point
48-
pinMode(ledPin, OUTPUT);
49-
50-
Serial.begin(115200);
51-
while (!Serial) {
52-
delay(100);
53-
}
54-
55-
// We start by connecting to a WiFi network
56-
Serial.print("Connecting to ");
57-
Serial.println(ssid);
58-
// enable IPv6
59-
WiFi.enableIPv6(true);
60-
// Manually connect to WiFi
61-
WiFi.begin(ssid, password);
62-
// Wait for connection
63-
while (WiFi.status() != WL_CONNECTED) {
64-
delay(500);
65-
Serial.print(".");
66-
}
67-
Serial.println("\r\nWiFi connected");
68-
Serial.println("IP address: ");
69-
Serial.println(WiFi.localIP());
70-
delay(500);
71-
72-
// Initialize Matter EndPoint
73-
lastStatePref.begin("matterLight", false);
74-
bool lastOnOffState = lastStatePref.getBool("lastOnOffState", true);
75-
OnOffLight.begin(lastOnOffState);
76-
OnOffLight.onChangeOnOff(setLightOnOff);
77-
78-
// Matter begining - Last step, after all EndPoints are initialized
79-
Matter.begin();
80-
// This may be a restart of a already commissioned Matter accessory
81-
if (Matter.isDeviceCommissioned()) {
82-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
83-
Serial.printf("Initial state: %s\r\n", OnOffLight.getOnOff() ? "ON" : "OFF");
84-
setLightOnOff(OnOffLight.getOnOff()); // configure the Light based on initial state
85-
}
86-
}
87-
// Button control
88-
uint32_t button_time_stamp = 0; // debouncing control
89-
bool button_state = false; // false = released | true = pressed
90-
const uint32_t debouceTime = 250; // button debouncing time (ms)
91-
const uint32_t decommissioningTimeout = 10000; // keep the button pressed for 10s to decommission the light
92-
93-
void loop() {
94-
// Check Matter Light Commissioning state, which may change during execution of loop()
95-
if (!Matter.isDeviceCommissioned()) {
96-
Serial.println("");
97-
Serial.println("Matter Node is not commissioned yet.");
98-
Serial.println("Initiate the device discovery in your Matter environment.");
99-
Serial.println("Commission it to your Matter hub with the manual pairing code or QR code");
100-
Serial.printf("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str());
101-
Serial.printf("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str());
102-
// waits for Matter Light Commissioning.
103-
uint32_t timeCount = 0;
104-
while (!Matter.isDeviceCommissioned()) {
105-
delay(100);
106-
if ((timeCount++ % 50) == 0) { // 50*100ms = 5 sec
107-
Serial.println("Matter Node not commissioned yet. Waiting for commissioning.");
108-
}
109-
}
110-
Serial.printf("Initial state: %s\r\n", OnOffLight.getOnOff() ? "ON" : "OFF");
111-
setLightOnOff(OnOffLight.getOnOff()); // configure the Light based on initial state
112-
Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use.");
113-
}
114-
115-
// A button is also used to control the light
116-
// Check if the button has been pressed
117-
if (digitalRead(buttonPin) == LOW && !button_state) {
118-
// deals with button debouncing
119-
button_time_stamp = millis(); // record the time while the button is pressed.
120-
button_state = true; // pressed.
121-
}
122-
123-
// Onboard User Button is used as a Light toggle switch or to decommission it
124-
uint32_t time_diff = millis() - button_time_stamp;
125-
if (button_state && time_diff > debouceTime && digitalRead(buttonPin) == HIGH) {
126-
button_state = false; // released
127-
// Toggle button is released - toggle the light
128-
Serial.println("User button released. Toggling Light!");
129-
OnOffLight.toggle(); // Matter Controller also can see the change
130-
131-
// Factory reset is triggered if the button is pressed longer than 10 seconds
132-
if (time_diff > decommissioningTimeout) {
133-
Serial.println("Decommissioning the Light Matter Accessory. It shall be commissioned again.");
134-
OnOffLight.setOnOff(false); // turn the light off
135-
Matter.decommission();
136-
}
137-
}
1+
{
2+
"fqbn_append": "PartitionScheme=huge_app",
3+
"requires": [
4+
"CONFIG_SOC_WIFI_SUPPORTED=y",
5+
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
6+
]
1387
}

Diff for: libraries/Matter/examples/MatterOnOffLight/ci.json

+7-40
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,7 @@
1-
#pragma once
2-
#include <sdkconfig.h>
3-
#ifdef CONFIG_ESP_MATTER_ENABLE_DATA_MODEL
4-
5-
#include <Arduino.h>
6-
#include <esp_matter.h>
7-
8-
using namespace esp_matter;
9-
10-
class ArduinoMatter {
11-
public:
12-
static inline String getManualPairingCode() {
13-
// return the pairing code for manual pairing
14-
return String("34970112332");
15-
}
16-
static inline String getOnboardingQRCodeUrl() {
17-
// return the URL for the QR code for onboarding
18-
return String("https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT:Y.K9042C00KA0648G00");
19-
}
20-
static void begin();
21-
static bool isDeviceCommissioned();
22-
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
23-
static bool isWiFiConnected();
24-
#endif
25-
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
26-
static bool isThreadConnected();
27-
#endif
28-
static bool isDeviceConnected();
29-
static void decommission();
30-
31-
// list of Matter EndPoints Friend Classes
32-
friend class MatterOnOffLight;
33-
34-
protected:
35-
static void _init();
36-
};
37-
38-
extern ArduinoMatter Matter;
39-
40-
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */
1+
{
2+
"fqbn_append": "PartitionScheme=huge_app",
3+
"requires": [
4+
"CONFIG_SOC_WIFI_SUPPORTED=y",
5+
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y"
6+
]
7+
}

Diff for: libraries/Matter/src/MatterOnOffLight.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ MatterOnOffLight::operator bool() {
105105
void MatterOnOffLight::operator=(bool newState) {
106106
setOnOff(newState);
107107
}
108-
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */
108+
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

Diff for: libraries/Matter/src/MatterOnOffLight.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ class MatterOnOffLight : public MatterEndPoint {
3131
bool state = false; // default initial state is off, but it can be changed by begin(bool)
3232
EndPointCB _onChangeCB = NULL;
3333
};
34-
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */
34+
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

0 commit comments

Comments
 (0)