Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle Add TLV implementation in the iOS/macOS CHIP framework #908

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/darwin/CHIPTool/CHIPTool.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
};
};
};
buildConfigurationList = B204A617244E1D0600C7C0E1 /* Build configuration list for PBXProject "CHIPTool" */;
buildConfigurationList = B204A617244E1D0600C7C0E1 /* Build configuration list for PBXProject "chiptool" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
Expand Down Expand Up @@ -474,7 +474,7 @@
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
B204A617244E1D0600C7C0E1 /* Build configuration list for PBXProject "CHIPTool" */ = {
B204A617244E1D0600C7C0E1 /* Build configuration list for PBXProject "chiptool" */ = {
isa = XCConfigurationList;
buildConfigurations = (
B204A649244E1D0700C7C0E1 /* Debug iOS */,
Expand Down
36 changes: 28 additions & 8 deletions src/darwin/CHIPTool/CHIPTool/UI/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="jdn-ck-R8w">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="jdn-ck-R8w">
<device id="retina5_9" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
Expand All @@ -19,7 +19,7 @@
<rect key="frame" x="0.0" y="209" width="375" height="356"/>
<subviews>
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2Mj-J7-ksb">
<rect key="frame" x="304.66666666666669" y="15" width="45" height="34"/>
<rect key="frame" x="305" y="15" width="45" height="34"/>
<color key="backgroundColor" systemColor="systemBlueColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="45" id="Ebl-wZ-SPm"/>
Expand All @@ -35,7 +35,7 @@
</connections>
</button>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Manual Code" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="CuJ-0W-LIn">
<rect key="frame" x="38.999999999999986" y="15" width="255.66666666666663" height="34"/>
<rect key="frame" x="39" y="15" width="256" height="34"/>
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand All @@ -61,7 +61,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="YKC-8r-kzn">
<rect key="frame" x="312" y="110" width="30" height="23"/>
<rect key="frame" x="312.66666666666669" y="110" width="29.333333333333314" height="23"/>
<state key="normal" image="camera.fill" catalog="system">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" scale="large"/>
</state>
Expand All @@ -70,7 +70,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eNw-2a-OUY">
<rect key="frame" x="299" y="110" width="56" height="23"/>
<rect key="frame" x="299.33333333333331" y="110" width="56" height="23"/>
<constraints>
<constraint firstAttribute="height" constant="23" id="xVp-Aa-IeI"/>
</constraints>
Expand Down Expand Up @@ -184,11 +184,26 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00000000000000000000" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="faq-rn-i79">
<rect key="frame" x="124.66666666666669" y="-11" width="225" height="20.333333333333332"/>
<rect key="frame" x="125" y="-11" width="225" height="20.333333333333332"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<color key="textColor" systemColor="systemBlueColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="serial #" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1iE-d7-szF">
<rect key="frame" x="294" y="79" width="56" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" systemColor="systemBlueColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="N/A" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FMS-vV-ZwI">
<rect key="frame" x="203" y="105.66666666666669" width="147" height="20.333333333333329"/>
<constraints>
<constraint firstAttribute="width" constant="147" id="iGr-vF-KJR"/>
</constraints>
<fontDescription key="fontDescription" type="italicSystem" pointSize="17"/>
<color key="textColor" systemColor="systemBlueColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
Expand All @@ -209,6 +224,7 @@
<constraint firstAttribute="trailing" secondItem="rNL-CF-kwb" secondAttribute="trailing" constant="22" id="b9Q-dH-RMA"/>
<constraint firstItem="A6N-re-z72" firstAttribute="leading" secondItem="qzu-Wd-XtE" secondAttribute="leading" id="bsV-pY-Ywq"/>
<constraint firstItem="XVG-Ph-rHO" firstAttribute="firstBaseline" secondItem="ml9-Kz-In1" secondAttribute="baseline" constant="24" symbolType="layoutAnchor" id="cMw-wo-i90"/>
<constraint firstItem="FMS-vV-ZwI" firstAttribute="centerY" secondItem="fjy-2o-l8j" secondAttribute="centerY" id="cyE-R2-IX7"/>
<constraint firstItem="fjy-2o-l8j" firstAttribute="firstBaseline" secondItem="qzu-Wd-XtE" secondAttribute="baseline" constant="24" symbolType="layoutAnchor" id="dAU-ik-gFV"/>
<constraint firstAttribute="trailing" secondItem="pcj-Jl-2Wz" secondAttribute="trailing" constant="22" id="eFk-HZ-y7o"/>
<constraint firstItem="HiF-tu-Xki" firstAttribute="firstBaseline" secondItem="eQW-ha-eiK" secondAttribute="baseline" constant="24" symbolType="layoutAnchor" id="eco-wR-pHG"/>
Expand All @@ -217,8 +233,9 @@
<constraint firstAttribute="trailing" secondItem="HiF-tu-Xki" secondAttribute="trailing" constant="22" id="hZO-IV-4Zn"/>
<constraint firstAttribute="trailing" secondItem="CGg-gC-ek0" secondAttribute="trailing" constant="22" id="jsn-SE-Yi2"/>
<constraint firstItem="CGg-gC-ek0" firstAttribute="firstBaseline" secondItem="A6N-re-z72" secondAttribute="baseline" constant="24" symbolType="layoutAnchor" id="lSd-xx-xJ1"/>
<constraint firstAttribute="trailing" secondItem="XVG-Ph-rHO" secondAttribute="trailing" constant="22" id="lyB-Lk-lva"/>
<constraint firstItem="rNL-CF-kwb" firstAttribute="leading" secondItem="zTo-M0-YqB" secondAttribute="leading" id="rD6-rx-hbC"/>
<constraint firstAttribute="trailing" secondItem="XVG-Ph-rHO" secondAttribute="trailing" constant="22" id="tO2-Q4-Vwx"/>
<constraint firstItem="1iE-d7-szF" firstAttribute="centerY" secondItem="qzu-Wd-XtE" secondAttribute="centerY" id="tSS-RD-sD4"/>
<constraint firstItem="zTo-M0-YqB" firstAttribute="top" secondItem="0zj-2E-c4c" secondAttribute="bottom" constant="45" id="xvF-cz-TQK"/>
<constraint firstItem="0zj-2E-c4c" firstAttribute="top" secondItem="A6N-re-z72" secondAttribute="bottom" constant="45" id="xwu-AA-8lr"/>
<constraint firstAttribute="height" constant="420" id="zrG-5a-d69"/>
Expand Down Expand Up @@ -250,6 +267,7 @@
<constraint firstItem="w8i-8R-6Fk" firstAttribute="firstBaseline" secondItem="faq-rn-i79" secondAttribute="baseline" constant="24" symbolType="layoutAnchor" id="QQY-lR-jPw"/>
<constraint firstItem="pR3-Sf-AVi" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="QUe-xX-RNy"/>
<constraint firstItem="eNw-2a-OUY" firstAttribute="centerY" secondItem="YKC-8r-kzn" secondAttribute="centerY" id="SBy-oE-nCI"/>
<constraint firstItem="1iE-d7-szF" firstAttribute="trailing" secondItem="2Mj-J7-ksb" secondAttribute="trailing" id="Tf8-Tj-d4W"/>
<constraint firstItem="faq-rn-i79" firstAttribute="trailing" secondItem="2Mj-J7-ksb" secondAttribute="trailing" id="Vj8-pF-sq6"/>
<constraint firstItem="bp0-Ss-koQ" firstAttribute="top" secondItem="CuJ-0W-LIn" secondAttribute="bottom" constant="30" id="Wln-do-7iB"/>
<constraint firstItem="YKC-8r-kzn" firstAttribute="centerY" secondItem="cyT-BB-1AD" secondAttribute="centerY" constant="1.5" id="YtM-ga-TqJ"/>
Expand All @@ -259,6 +277,7 @@
<constraint firstItem="cyT-BB-1AD" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="40" id="ncT-ZV-lhY"/>
<constraint firstItem="cyT-BB-1AD" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="34" id="oHh-t9-dHE"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="YKC-8r-kzn" secondAttribute="trailing" constant="33" id="oYR-cy-bjg"/>
<constraint firstItem="FMS-vV-ZwI" firstAttribute="trailing" secondItem="2Mj-J7-ksb" secondAttribute="trailing" id="quC-I6-RaK"/>
<constraint firstItem="rTH-Nc-7Dl" firstAttribute="centerX" secondItem="bp0-Ss-koQ" secondAttribute="centerX" id="yBP-Ef-Vwy"/>
</constraints>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
Expand All @@ -276,6 +295,7 @@
<outlet property="qrCodeButton" destination="YKC-8r-kzn" id="nDk-hl-Frp"/>
<outlet property="qrCodeViewPreview" destination="pR3-Sf-AVi" id="qop-Kq-984"/>
<outlet property="rendezVousInformation" destination="pcj-Jl-2Wz" id="P5x-8A-zpx"/>
<outlet property="serialNumber" destination="FMS-vV-ZwI" id="XBs-kO-3PM"/>
<outlet property="setupPayloadView" destination="bp0-Ss-koQ" id="gDL-dz-Neu"/>
<outlet property="setupPinCodeLabel" destination="CGg-gC-ek0" id="3jg-7C-I3f"/>
<outlet property="vendorID" destination="rNL-CF-kwb" id="01c-FS-zhC"/>
Expand All @@ -284,7 +304,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="41" y="-284"/>
<point key="canvasLocation" x="40.799999999999997" y="-284.48275862068965"/>
</scene>
<!--Echo-->
<scene sceneID="qLg-El-QgV">
Expand Down
1 change: 1 addition & 0 deletions src/darwin/CHIPTool/CHIPTool/UI/QRCodeViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@property (weak, nonatomic) IBOutlet UILabel * rendezVousInformation;
@property (weak, nonatomic) IBOutlet UILabel * vendorID;
@property (weak, nonatomic) IBOutlet UILabel * productID;
@property (weak, nonatomic) IBOutlet UILabel * serialNumber;

- (IBAction)startScanningQRCode:(id)sender;
- (IBAction)stopScanningQRCode:(id)sender;
Expand Down
8 changes: 6 additions & 2 deletions src/darwin/CHIPTool/CHIPTool/UI/QRCodeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ - (void)showPayload:(CHIPSetupPayload *)payload decimalString:(nullable NSString
self->_discriminatorLabel.text = [NSString stringWithFormat:@"%@", payload.discriminator];
self->_setupPinCodeLabel.text = [NSString stringWithFormat:@"%@", payload.setUpPINCode];
self->_rendezVousInformation.text = NOT_APPLICABLE_STRING;

self->_serialNumber.text = NOT_APPLICABLE_STRING;
// TODO: Only display vid and pid if present
self->_vendorID.text = [NSString stringWithFormat:@"%@", payload.vendorID];
self->_productID.text = [NSString stringWithFormat:@"%@", payload.productID];
Expand All @@ -149,7 +149,11 @@ - (void)showPayload:(CHIPSetupPayload *)payload decimalString:(nullable NSString
self->_discriminatorLabel.text = [NSString stringWithFormat:@"%@", payload.discriminator];
self->_setupPinCodeLabel.text = [NSString stringWithFormat:@"%@", payload.setUpPINCode];
self->_rendezVousInformation.text = [NSString stringWithFormat:@"%@", payload.rendezvousInformation];

if ([payload.serialNumber length] > 0) {
self->_serialNumber.text = payload.serialNumber;
} else {
self->_serialNumber.text = NOT_APPLICABLE_STRING;
}
// TODO: Only display vid and pid if present
self->_vendorID.text = [NSString stringWithFormat:@"%@", payload.vendorID];
self->_productID.text = [NSString stringWithFormat:@"%@", payload.productID];
Expand Down
3 changes: 2 additions & 1 deletion src/darwin/Framework/CHIP/CHIPError.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ typedef NS_ERROR_ENUM(CHIPErrorDomain, CHIPErrorCode) {
CHIPErrorCodeInvalidArgument = 3,
CHIPErrorCodeInvalidMessageLength = 4,
CHIPErrorCodeInvalidState = 5,
CHIPERRORCodeWrongAddressType = 6,
CHIPErrorCodeWrongAddressType = 6,
CHIPErrorCodeIntegrityCheckFailed = 7,
};

@interface CHIPError : NSObject
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/CHIPError.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ + (NSError *)errorForCHIPErrorCode:(CHIP_ERROR)errorCode
return [NSError errorWithDomain:CHIPErrorDomain
code:CHIPErrorCodeInvalidState
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"Invalid object state.", nil) }];
case CHIP_ERROR_INTEGRITY_CHECK_FAILED:
return [NSError errorWithDomain:CHIPErrorDomain
code:CHIPErrorCodeIntegrityCheckFailed
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"Integrity check failed.", nil) }];
default:
return [NSError errorWithDomain:CHIPErrorDomain
code:CHIPErrorCodeUndefinedError
Expand Down
14 changes: 14 additions & 0 deletions src/darwin/Framework/CHIP/CHIPSetupPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

#import "CHIPError.h"
#import <Foundation/Foundation.h>

#ifdef __cplusplus
Expand All @@ -23,6 +24,15 @@

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, OptionalQRCodeInfoType) { kOptionalQRCodeInfoTypeString, kOptionalQRCodeInfoTypeInt };

@interface CHIPOptionalQRCodeInfo : NSObject
@property (nonatomic, strong) NSNumber * infoType;
@property (nonatomic, strong) NSNumber * tag;
@property (nonatomic, strong) NSNumber * integerValue;
@property (nonatomic, strong) NSString * stringValue;
@end

@interface CHIPSetupPayload : NSObject

@property (nonatomic, strong) NSNumber * version;
Expand All @@ -33,6 +43,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) NSNumber * discriminator;
@property (nonatomic, strong) NSNumber * setUpPINCode;

@property (nonatomic, strong) NSString * serialNumber;
- (NSArray<CHIPOptionalQRCodeInfo *> *)getAllOptionalData:(NSError * __autoreleasing *)error;
+ (NSNumber *)vendorTag:(NSNumber *)tagNumber error:(NSError * __autoreleasing *)error;

#ifdef __cplusplus
- (id)initWithSetupPayload:(chip::SetupPayload)setupPayload;
#endif
Expand Down
Loading