Skip to content

Commit 46f5588

Browse files
committed
feat(matter): adds ways to check matter features in execution time
1 parent b859bdf commit 46f5588

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

libraries/Matter/src/Matter.cpp

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,67 @@ void ArduinoMatter::begin() {
175175
}
176176
}
177177

178+
// Network and Commissioning Capability Queries
179+
bool ArduinoMatter::isWiFiStationEnabled() {
180+
// Check hardware support (SOC capabilities) AND Matter configuration
181+
#ifdef SOC_WIFI_SUPPORTED
182+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
183+
return true;
184+
#else
185+
return false;
186+
#endif
187+
#else
188+
return false;
189+
#endif
190+
}
191+
192+
bool ArduinoMatter::isWiFiAccessPointEnabled() {
193+
// Check hardware support (SOC capabilities) AND Matter configuration
194+
#ifdef SOC_WIFI_SUPPORTED
195+
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP
196+
return true;
197+
#else
198+
return false;
199+
#endif
200+
#else
201+
return false;
202+
#endif
203+
}
204+
205+
bool ArduinoMatter::isThreadEnabled() {
206+
// Check hardware support (SOC capabilities) AND Matter configuration
207+
// Thread requires IEEE 802.15.4 radio support (ESP32-H2, ESP32-C6, ESP32-C5)
208+
// For now, we check Matter configuration as hardware detection is complex
209+
#if CONFIG_ENABLE_MATTER_OVER_THREAD || CHIP_DEVICE_CONFIG_ENABLE_THREAD
210+
return true;
211+
#else
212+
return false;
213+
#endif
214+
}
215+
216+
bool ArduinoMatter::isBLECommissioningEnabled() {
217+
// Check hardware support (SOC capabilities) AND Matter/ESP configuration
218+
// BLE commissioning requires: SOC BLE support AND (CHIPoBLE or NimBLE enabled)
219+
#ifdef SOC_BLE_SUPPORTED
220+
#if CONFIG_NETWORK_LAYER_BLE || CONFIG_ENABLE_CHIPOBLE
221+
return true;
222+
#else
223+
// Also check if BLE stack is enabled (Bluedroid or NimBLE)
224+
#if defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)
225+
return true;
226+
#else
227+
return false;
228+
#endif
229+
#endif
230+
#else
231+
return false;
232+
#endif
233+
}
234+
235+
178236
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
179237
bool ArduinoMatter::isThreadConnected() {
180-
return false; // Thread Network TBD
238+
return chip::DeviceLayer::ConnectivityMgr().IsThreadAttached();
181239
}
182240
#endif
183241

libraries/Matter/src/Matter.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ class ArduinoMatter {
179179
return String("https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT:Y.K9042C00KA0648G00");
180180
}
181181
static void begin();
182+
183+
// Network and Commissioning Capability Queries
184+
// These methods check both hardware support (SOC capabilities) and Matter configuration
185+
static bool isWiFiStationEnabled(); // Check if WiFi Station mode is supported and enabled
186+
static bool isWiFiAccessPointEnabled(); // Check if WiFi AP mode is supported and enabled
187+
static bool isThreadEnabled(); // Check if Thread network is supported and enabled
188+
static bool isBLECommissioningEnabled(); // Check if BLE commissioning is supported and enabled
189+
182190
static bool isDeviceCommissioned();
183191
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
184192
static bool isWiFiConnected();

0 commit comments

Comments
 (0)