diff --git a/src/darwin/Framework/CHIP/MTRSetupPayload.h b/src/darwin/Framework/CHIP/MTRSetupPayload.h index 547176e2135e54..e5ca4f9ccbce3f 100644 --- a/src/darwin/Framework/CHIP/MTRSetupPayload.h +++ b/src/darwin/Framework/CHIP/MTRSetupPayload.h @@ -59,7 +59,7 @@ typedef NS_ENUM(NSUInteger, MTROptionalQRCodeInfoType) { * setters has no effect. */ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) -@interface MTROptionalQRCodeInfo : NSObject +@interface MTROptionalQRCodeInfo : NSObject /* (see below) */ - (instancetype)initWithTag:(uint8_t)tag stringValue:(NSString *)value MTR_NEWLY_AVAILABLE; - (instancetype)initWithTag:(uint8_t)tag int32Value:(int32_t)value MTR_NEWLY_AVAILABLE; @@ -72,7 +72,7 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) * Tags in the range 0x00 - 0x7F are reserved for Matter-defined elements. * Vendor-specific elements must have tags in the range 0x80 - 0xFF. */ -@property (nonatomic, readonly, assign) uint8_t tagNumber; +@property (nonatomic, readonly, assign) uint8_t tagNumber MTR_NEWLY_AVAILABLE; /** * The value held in this extension element, @@ -88,6 +88,10 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @end +MTR_NEWLY_AVAILABLE +@interface MTROptionalQRCodeInfo () +@end + /** * A Matter Onboarding Payload. * @@ -100,7 +104,7 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) * from the underlying values */ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) -@interface MTRSetupPayload : NSObject +@interface MTRSetupPayload : NSObject /* also (see below) */ /** * Initializes the payload object from the provide QR Code or Manual Pairing Code string. @@ -153,23 +157,23 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) /** * The list of Manufacturer-specific extension elements contained in the setup code. May be empty. */ -@property (nonatomic, readonly, copy) NSArray * vendorElements; +@property (nonatomic, readonly, copy) NSArray * vendorElements MTR_NEWLY_AVAILABLE; /** Returns the Manufacturer-specific extension element with the specified tag, if any. */ -- (nullable MTROptionalQRCodeInfo *)vendorElementWithTag:(uint8_t)tag; +- (nullable MTROptionalQRCodeInfo *)vendorElementWithTag:(uint8_t)tag MTR_NEWLY_AVAILABLE; /** * Removes the extension element with the specified tag, if any. */ -- (void)removeVendorElementWithTag:(uint8_t)tag; +- (void)removeVendorElementWithTag:(uint8_t)tag MTR_NEWLY_AVAILABLE; /** * Adds or replaces a Manufacturer-specific extension element. * The element must have a tag in the vendor-specific range (0x80 - 0xFF). */ -- (void)addOrReplaceVendorElement:(MTROptionalQRCodeInfo *)element; +- (void)addOrReplaceVendorElement:(MTROptionalQRCodeInfo *)element MTR_NEWLY_AVAILABLE; /** * Generate a random Matter-valid setup PIN. @@ -215,6 +219,10 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) @end +MTR_NEWLY_AVAILABLE +@interface MTRSetupPayload () +@end + @interface MTROptionalQRCodeInfo (Deprecated) - (instancetype)init MTR_NEWLY_DEPRECATED("Please use -initWithTag:...value:"); diff --git a/src/darwin/Framework/CHIP/MTRSetupPayload.mm b/src/darwin/Framework/CHIP/MTRSetupPayload.mm index 31a4e62c1736e0..fcdeaa75e83554 100644 --- a/src/darwin/Framework/CHIP/MTRSetupPayload.mm +++ b/src/darwin/Framework/CHIP/MTRSetupPayload.mm @@ -85,6 +85,7 @@ - (MTROptionalQRCodeInfoType)type case chip::optionalQRCodeInfoTypeInt32: return MTROptionalQRCodeInfoTypeInt32; // No 'default:' so we get a warning if new types are added. + // Note: isEqual: also switches over these types. // OptionalQRCodeInfo does not support these types case chip::optionalQRCodeInfoTypeInt64: case chip::optionalQRCodeInfoTypeUInt32: @@ -129,9 +130,14 @@ - (BOOL)isEqual:(id)object MTROptionalQRCodeInfo * other = object; VerifyOrReturnValue(_info.tag == other->_info.tag, NO); VerifyOrReturnValue(_info.type == other->_info.type, NO); - VerifyOrReturnValue(_info.int32 == other->_info.int32, NO); - VerifyOrReturnValue(_info.data == other->_info.data, NO); - return YES; + switch (_info.type) { + case chip::optionalQRCodeInfoTypeString: + return _info.data == other->_info.data; + case chip::optionalQRCodeInfoTypeInt32: + return _info.int32 == other->_info.int32; + default: + return NO; // unreachable, type is checked in init + } } - (NSString *)description