forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First implementation of iOS CHIP.framework and iOS code parser app (p…
…roject-chip#537) * First implementation of iOS CHP.framework and iOS code parser app * Readded workspace and fixed copyright * Rename to CHIP.framework and move to correct folder hierarchy * Restyled by clang-format * Restyled by prettier-json * Rename folder * Changed CHP to CHIP Co-authored-by: Restyled.io <commits@restyled.io>
- Loading branch information
1 parent
0f1b502
commit 9ffc90f
Showing
31 changed files
with
2,588 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
504 changes: 504 additions & 0 deletions
504
src/CHIP_Framework_iOS/CHIP/CHIP.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// CHIP.h | ||
// CHIP | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "CHIPSetupPayload.h" | ||
#import "CHIPQRCodeSetupPayloadParser.h" | ||
#import "CHIPManualSetupPayloadParser.h" | ||
#import "CHIPError.h" | ||
//! Project version number for CHIP. | ||
FOUNDATION_EXPORT double CHIPVersionNumber; | ||
|
||
//! Project version string for CHIP. | ||
FOUNDATION_EXPORT const unsigned char CHIPVersionString[]; | ||
|
||
// In this header, you should import all the public headers of your framework using statements like #import <CHIP/PublicHeader.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// CHIPError.h | ||
// CHIPQRCodeReader | ||
// | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
FOUNDATION_EXPORT NSErrorDomain const CHIPErrorDomain; | ||
|
||
typedef NS_ERROR_ENUM(CHIPErrorDomain, CHIPErrorCode) { | ||
CHIPErrorCodeUndefinedError = 0, | ||
CHIPErrorCodeInvalidStringLength = 1, | ||
CHIPErrorCodeInvalidIntegerValue = 2, | ||
CHIPErrorCodeInvalidArgument = 3, | ||
CHIPErrorCodeInvalidMessageLength = 4, | ||
}; | ||
|
||
@interface CHIPError : NSObject | ||
+ (nullable NSError *)errorForCHIPErrorCode:(int32_t)errorCode; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// CHIPError.m | ||
// CHIPQRCodeReader | ||
// | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "CHIPError.h" | ||
|
||
NSString * const CHIPErrorDomain = @"CHIPErrorDomain"; | ||
|
||
@implementation CHIPError | ||
|
||
+ (NSError *)errorForCHIPErrorCode:(int32_t)errorCode | ||
{ | ||
switch (errorCode) { | ||
case 4030: | ||
return [NSError errorWithDomain:CHIPErrorDomain | ||
code:CHIPErrorCodeInvalidStringLength | ||
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"A list length is invalid.", nil) }]; | ||
case 4145: | ||
return [NSError errorWithDomain:CHIPErrorDomain | ||
code:CHIPErrorCodeInvalidIntegerValue | ||
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"Unexpected integer value.", nil) }]; | ||
case 4046: | ||
return [NSError errorWithDomain:CHIPErrorDomain | ||
code:CHIPErrorCodeInvalidArgument | ||
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"An argument is invalid.", nil) }]; | ||
case 4023: | ||
return [NSError errorWithDomain:CHIPErrorDomain | ||
code:CHIPErrorCodeInvalidMessageLength | ||
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"A message length is invalid.", nil) }]; | ||
default: | ||
return [NSError errorWithDomain:CHIPErrorDomain | ||
code:CHIPErrorCodeUndefinedError | ||
userInfo:@{ NSLocalizedDescriptionKey : NSLocalizedString(@"Undefined error.", nil) }]; | ||
; | ||
} | ||
} | ||
@end |
32 changes: 32 additions & 0 deletions
32
src/CHIP_Framework_iOS/CHIP/CHIP/CHIPManualSetupPayloadParser.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// CHIPManualSetupPayloadParser.h | ||
// CHIPQRCodeReader | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "CHIPSetupPayload.h" | ||
#import "CHIPError.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface CHIPManualSetupPayloadParser : NSObject | ||
- (id)initWithDecimalStringRepresentation:(NSString *)decimalStringRepresentation; | ||
- (CHIPSetupPayload *)populatePayload:(NSError * __autoreleasing *)error; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
55 changes: 55 additions & 0 deletions
55
src/CHIP_Framework_iOS/CHIP/CHIP/CHIPManualSetupPayloadParser.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// CHIPManualSetupPayloadParser.m | ||
// CHIPQRCodeReader | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "CHIPManualSetupPayloadParser.h" | ||
|
||
#import <setup_payload/ManualSetupPayloadParser.h> | ||
#import <setup_payload/SetupPayload.h> | ||
|
||
@implementation CHIPManualSetupPayloadParser { | ||
NSString *_decimalStringRepresentation; | ||
chip::ManualSetupPayloadParser *_chipManualSetupPayloadParser; | ||
} | ||
|
||
- (id)initWithDecimalStringRepresentation:(NSString *)decimalStringRepresentation | ||
{ | ||
if(self = [super init]) { | ||
_decimalStringRepresentation = decimalStringRepresentation; | ||
_chipManualSetupPayloadParser = new chip::ManualSetupPayloadParser(std::string([decimalStringRepresentation UTF8String])); | ||
} | ||
return self; | ||
} | ||
|
||
- (CHIPSetupPayload *)populatePayload:(NSError *__autoreleasing *)error | ||
{ | ||
chip::SetupPayload cPlusPluspayload; | ||
CHIP_ERROR chipError = _chipManualSetupPayloadParser->populatePayload(cPlusPluspayload); | ||
|
||
CHIPSetupPayload *payload; | ||
if (chipError == 0) { | ||
payload = [[CHIPSetupPayload alloc] initWithSetupPayload:cPlusPluspayload]; | ||
} else if (error) { | ||
*error = [CHIPError errorForCHIPErrorCode:chipError]; | ||
} | ||
|
||
return payload; | ||
} | ||
|
||
@end |
31 changes: 31 additions & 0 deletions
31
src/CHIP_Framework_iOS/CHIP/CHIP/CHIPQRCodeSetupPayloadParser.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// CHIPQRCodeSetupPayloadParser.h | ||
// CHIPQRCodeReader | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#import <Foundation/Foundation.h> | ||
#import "CHIPSetupPayload.h" | ||
#import "CHIPError.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface CHIPQRCodeSetupPayloadParser : NSObject | ||
- (id)initWithBase45Representation:(NSString *)base45Representation; | ||
- (CHIPSetupPayload *)populatePayload:(NSError * __autoreleasing *)error; | ||
@end | ||
; | ||
NS_ASSUME_NONNULL_END |
54 changes: 54 additions & 0 deletions
54
src/CHIP_Framework_iOS/CHIP/CHIP/CHIPQRCodeSetupPayloadParser.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// CHIPQRCodeSetupPayloadParser.m | ||
// CHIPQRCodeReader | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "CHIPQRCodeSetupPayloadParser.h" | ||
#import "CHIPError.h" | ||
|
||
#import <setup_payload/QRCodeSetupPayloadParser.h> | ||
#import <setup_payload/SetupPayload.h> | ||
|
||
@implementation CHIPQRCodeSetupPayloadParser { | ||
NSString *_base45Representation; | ||
chip::QRCodeSetupPayloadParser *_chipQRCodeSetupPayloadParser; | ||
} | ||
|
||
- (id)initWithBase45Representation:(NSString *)base45Representation | ||
{ | ||
if(self = [super init]) { | ||
_base45Representation = base45Representation; | ||
_chipQRCodeSetupPayloadParser = new chip::QRCodeSetupPayloadParser(std::string([base45Representation UTF8String])); | ||
} | ||
return self; | ||
} | ||
|
||
- (CHIPSetupPayload *)populatePayload:(NSError *__autoreleasing *)error | ||
{ | ||
chip::SetupPayload cPlusPluspayload; | ||
CHIP_ERROR chipError = _chipQRCodeSetupPayloadParser->populatePayload(cPlusPluspayload); | ||
|
||
CHIPSetupPayload *payload; | ||
if (chipError == 0) { | ||
payload = [[CHIPSetupPayload alloc] initWithSetupPayload:cPlusPluspayload]; | ||
} else if (error) { | ||
*error = [CHIPError errorForCHIPErrorCode:chipError]; | ||
} | ||
return payload; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// CHIPSetupPayload.h | ||
// CHIPQRCodeReader | ||
/** | ||
* | ||
* Copyright (c) 2020 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#ifdef __cplusplus | ||
#import <setup_payload/SetupPayload.h> | ||
#endif | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface CHIPSetupPayload : NSObject | ||
|
||
@property (nonatomic, strong) NSNumber * version; | ||
@property (nonatomic, strong) NSNumber * vendorID; | ||
@property (nonatomic, strong) NSNumber * productID; | ||
@property (nonatomic, assign) BOOL requiresCustomFlow; | ||
@property (nonatomic, strong) NSNumber * rendezvousInformation; | ||
@property (nonatomic, strong) NSNumber * discriminator; | ||
@property (nonatomic, strong) NSNumber * setUpPINCode; | ||
|
||
#ifdef __cplusplus | ||
- (id)initWithSetupPayload:(chip::SetupPayload)setupPayload; | ||
#endif | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
Oops, something went wrong.