Skip to content

Commit

Permalink
[Darwin] API to list all network commissioning features supported by …
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Dec 11, 2024
1 parent 814cb6a commit 14f4055
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#import <Foundation/Foundation.h>
#import <Matter/MTRAttributeValueWaiter.h>
#import <Matter/MTRBaseClusters.h>
#import <Matter/MTRBaseDevice.h>
#import <Matter/MTRDefines.h>

Expand Down Expand Up @@ -122,6 +123,11 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
*/
@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.
*
Expand Down
6 changes: 6 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice_Concrete.mm
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,12 @@ - (nullable NSNumber *)productID
return [_pid copy];
}

- (MTRNetworkCommissioningFeature)networkCommissioningFeatures
{
std::lock_guard lock(_descriptionLock);
return [_allNetworkFeatures unsignedIntValue];
}

- (void)_notifyDelegateOfPrivateInternalPropertiesChanges
{
os_unfair_lock_assert_owner(&self->_lock);
Expand Down
5 changes: 5 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ - (nullable NSNumber *)productID
return [[self._internalState objectForKey:kMTRDeviceInternalPropertyKeyProductID] copy];
}

- (MTRNetworkCommissioningFeature)networkCommissioningFeatures
{
return [[self._internalState objectForKey:kMTRDeviceInternalPropertyNetworkFeatures] unsignedIntValue];
}

#pragma mark - Client Callbacks (MTRDeviceDelegate)

// required methods for MTRDeviceDelegates
Expand Down

0 comments on commit 14f4055

Please sign in to comment.