Skip to content

Commit 4b83b04

Browse files
[Darwin] VID and PID accessors to MTRDevice (project-chip#36239)
* [Darwin] VID and PID accessors to MTRDevice - Exposes VID/PID on MTRDevice as API * apply restyle suggestions --------- Co-authored-by: Kiel Oleson <kielo@apple.com>
1 parent c7414a6 commit 4b83b04

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/darwin/Framework/CHIP/MTRDevice.h

+14
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
107107
*/
108108
@property (nonatomic, readonly, nullable, copy) NSNumber * estimatedSubscriptionLatency MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6));
109109

110+
/**
111+
* The Vendor Identifier associated with the device.
112+
*
113+
* A non-nil value if the vendor identifier has been determined from the device, nil if unknown.
114+
*/
115+
@property (nonatomic, readonly, nullable, copy) NSNumber * vendorID MTR_NEWLY_AVAILABLE;
116+
117+
/**
118+
* The Product Identifier associated with the device.
119+
*
120+
* A non-nil value if the product identifier has been determined from the device, nil if unknown.
121+
*/
122+
@property (nonatomic, readonly, nullable, copy) NSNumber * productID MTR_NEWLY_AVAILABLE;
123+
110124
/**
111125
* Set the delegate to receive asynchronous callbacks about the device.
112126
*

src/darwin/Framework/CHIP/MTRDevice_Concrete.mm

+12
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,18 @@ - (NSDictionary *)_internalProperties
488488
return properties;
489489
}
490490

491+
- (nullable NSNumber *)vendorID
492+
{
493+
std::lock_guard lock(_descriptionLock);
494+
return [_vid copy];
495+
}
496+
497+
- (nullable NSNumber *)productID
498+
{
499+
std::lock_guard lock(_descriptionLock);
500+
return [_pid copy];
501+
}
502+
491503
- (void)_notifyDelegateOfPrivateInternalPropertiesChanges
492504
{
493505
os_unfair_lock_assert_owner(&self->_lock);

src/darwin/Framework/CHIP/MTRDevice_XPC.mm

+10
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ - (NSString *)description
131131
_deviceController.uniqueIdentifier];
132132
}
133133

134+
- (nullable NSNumber *)vendorID
135+
{
136+
return [[self._internalState objectForKey:kMTRDeviceInternalPropertyKeyVendorID] copy];
137+
}
138+
139+
- (nullable NSNumber *)productID
140+
{
141+
return [[self._internalState objectForKey:kMTRDeviceInternalPropertyKeyProductID] copy];
142+
}
143+
134144
#pragma mark - Client Callbacks (MTRDeviceDelegate)
135145

136146
// required methods for MTRDeviceDelegates

0 commit comments

Comments
 (0)