[Darwin] API to list all network commissioning features supported by an MTRDevice (#36479)
* [Darwin] API to list all network commissioning features supported by an MTRDevice
- Expose the network commissioning feature bitset as API to know what
transports are supported by the device.
* Code review comments
* Code review comments
* Restyled by clang-format
---------
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/src/darwin/Framework/CHIP/MTRDevice.h b/src/darwin/Framework/CHIP/MTRDevice.h
index 16df47b..247223c 100644
--- a/src/darwin/Framework/CHIP/MTRDevice.h
+++ b/src/darwin/Framework/CHIP/MTRDevice.h
@@ -17,6 +17,7 @@
#import <Foundation/Foundation.h>
#import <Matter/MTRAttributeValueWaiter.h>
+#import <Matter/MTRBaseClusters.h>
#import <Matter/MTRBaseDevice.h>
#import <Matter/MTRDefines.h>
@@ -123,6 +124,11 @@
@property (nonatomic, readonly, nullable, copy) NSNumber * productID MTR_NEWLY_AVAILABLE;
/**
+ * Network commissioning features supported by the device.
+ */
+@property (nonatomic, readonly) MTRNetworkCommissioningFeature networkCommissioningFeatures MTR_NEWLY_AVAILABLE;
+
+/**
* Set the delegate to receive asynchronous callbacks about the device.
*
* The delegate will be called on the provided queue, for attribute reports, event reports, and device state changes.
diff --git a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm
index 091d50a..9169507 100644
--- a/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm
+++ b/src/darwin/Framework/CHIP/MTRDevice_Concrete.mm
@@ -514,6 +514,12 @@
return [_pid copy];
}
+- (MTRNetworkCommissioningFeature)networkCommissioningFeatures
+{
+ std::lock_guard lock(_descriptionLock);
+ return [_allNetworkFeatures unsignedIntValue];
+}
+
- (void)_notifyDelegateOfPrivateInternalPropertiesChanges
{
os_unfair_lock_assert_owner(&self->_lock);
diff --git a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm
index b5fea42..b500633 100644
--- a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm
+++ b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm
@@ -141,6 +141,11 @@
return [[self._internalState objectForKey:kMTRDeviceInternalPropertyKeyProductID] copy];
}
+- (MTRNetworkCommissioningFeature)networkCommissioningFeatures
+{
+ return [[self._internalState objectForKey:kMTRDeviceInternalPropertyNetworkFeatures] unsignedIntValue];
+}
+
#pragma mark - Client Callbacks (MTRDeviceDelegate)
// required methods for MTRDeviceDelegates