Skip to content

Commit

Permalink
Fixing style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pgregorr-amazon committed Jun 18, 2024
1 parent 9c65744 commit 0ed7d51
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ - (NSError *)verifyOrEstablishConnectionWithCallbacks:(MCConnectionCallbacks * _
}

void (^connectCallback)(CHIP_ERROR, matter::casting::core::CastingPlayer *) = ^(CHIP_ERROR err, matter::casting::core::CastingPlayer * castingPlayer) {
ChipLogProgress(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() connectCallback() called");
dispatch_queue_t clientQueue = [[MCCastingApp getSharedInstance] getClientQueue];
dispatch_async(clientQueue, ^{
if (connectionCallbacks.connectionCompleteCallback) {
connectionCallbacks.connectionCompleteCallback(err == CHIP_NO_ERROR ? nil : [MCErrorUtils NSErrorFromChipError:err]);
} else {
ChipLogError(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() connectCallback(), client failed to set the connectionCompleteCallback() callback");
}
});
};
ChipLogProgress(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() connectCallback() called");
dispatch_queue_t clientQueue = [[MCCastingApp getSharedInstance] getClientQueue];
dispatch_async(clientQueue, ^{
if (connectionCallbacks.connectionCompleteCallback) {
connectionCallbacks.connectionCompleteCallback(err == CHIP_NO_ERROR ? nil : [MCErrorUtils NSErrorFromChipError:err]);
} else {
ChipLogError(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() connectCallback(), client failed to set the connectionCompleteCallback() callback");
}
});
};
void (^commissionerDeclarationCallback)(const chip::Transport::PeerAddress & source, const chip::Protocols::UserDirectedCommissioning::CommissionerDeclaration cppCommissionerDeclaration) = ^(const chip::Transport::PeerAddress & source, const chip::Protocols::UserDirectedCommissioning::CommissionerDeclaration cppCommissionerDeclaration) {
ChipLogProgress(AppServer, "MCCastingPlayer.verifyOrEstablishConnectionWithCallbacks() commissionerDeclarationCallback() called with cpp CommissionerDeclaration");
dispatch_queue_t clientQueue = [[MCCastingApp getSharedInstance] getClientQueue];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ typedef NS_ENUM(NSInteger, CdError) {
};

- (instancetype)initWithOptions:(NSInteger)errorCode
needsPasscode:(BOOL)needsPasscode
noAppsFound:(BOOL)noAppsFound
passcodeDialogDisplayed:(BOOL)passcodeDialogDisplayed
commissionerPasscode:(BOOL)commissionerPasscode
qRCodeDisplayed:(BOOL)qRCodeDisplayed;
needsPasscode:(BOOL)needsPasscode
noAppsFound:(BOOL)noAppsFound
passcodeDialogDisplayed:(BOOL)passcodeDialogDisplayed
commissionerPasscode:(BOOL)commissionerPasscode
qRCodeDisplayed:(BOOL)qRCodeDisplayed;

- (CdError)getErrorCode;
- (BOOL)getNeedsPasscode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@ @interface MCCommissionerDeclaration ()

/** Feature: All - Indicates errors incurred during commissioning. */
@property (nonatomic) CdError errorCode;
/**
* Feature: Coordinate PIN Dialogs - When NoPasscode field set to true, and the Commissioner
* determines that a Passcode code will be needed for commissioning.
*/
/**
* Feature: Coordinate PIN Dialogs - When NoPasscode field set to true, and the Commissioner
* determines that a Passcode code will be needed for commissioning.
*/
@property (nonatomic) BOOL needsPasscode;
/**
* Feature: Target Content Application - No apps with AccountLogin cluster implementation were
* found for the last IdentificationDeclaration request. Only apps which provide access to the
* vendor id of the Commissionee will be considered.
*/
/**
* Feature: Target Content Application - No apps with AccountLogin cluster implementation were
* found for the last IdentificationDeclaration request. Only apps which provide access to the
* vendor id of the Commissionee will be considered.
*/
@property (nonatomic) BOOL noAppsFound;
/**
* Feature: Coordinate PIN Dialogs - A Passcode input dialog is now displayed for the user on the
* Commissioner.
*/
/**
* Feature: Coordinate PIN Dialogs - A Passcode input dialog is now displayed for the user on the
* Commissioner.
*/
@property (nonatomic) BOOL passcodeDialogDisplayed;
/**
* Feature: Commissioner-Generated Passcode - A Passcode is now displayed for the user by the
* CastingPlayer/Commissioner.
*/
/**
* Feature: Commissioner-Generated Passcode - A Passcode is now displayed for the user by the
* CastingPlayer/Commissioner.
*/
@property (nonatomic) BOOL commissionerPasscode;
/**
* Feature: Commissioner-Generated Passcode - The user experience conveying a Passcode to the user
* also displays a QR code.
*/
/**
* Feature: Commissioner-Generated Passcode - The user experience conveying a Passcode to the user
* also displays a QR code.
*/
@property (nonatomic) BOOL qRCodeDisplayed;

@property (nonatomic, readwrite) matter::casting::memory::Strong<chip::Protocols::UserDirectedCommissioning::CommissionerDeclaration> cppCommissionerDeclaration;
Expand All @@ -70,14 +70,15 @@ - (instancetype _Nonnull)initWithCppCommissionerDeclaration:(std::shared_ptr<chi
}

- (instancetype)initWithOptions:(NSInteger)errorCode
needsPasscode:(BOOL)needsPasscode
noAppsFound:(BOOL)noAppsFound
passcodeDialogDisplayed:(BOOL)passcodeDialogDisplayed
commissionerPasscode:(BOOL)commissionerPasscode
qRCodeDisplayed:(BOOL)qRCodeDisplayed {
needsPasscode:(BOOL)needsPasscode
noAppsFound:(BOOL)noAppsFound
passcodeDialogDisplayed:(BOOL)passcodeDialogDisplayed
commissionerPasscode:(BOOL)commissionerPasscode
qRCodeDisplayed:(BOOL)qRCodeDisplayed
{
self = [super init];
if (self) {
_errorCode = (CdError)errorCode;
_errorCode = (CdError) errorCode;
_needsPasscode = needsPasscode;
_noAppsFound = noAppsFound;
_passcodeDialogDisplayed = passcodeDialogDisplayed;
Expand All @@ -87,86 +88,95 @@ - (instancetype)initWithOptions:(NSInteger)errorCode
return self;
}

- (CdError)getErrorCode {
- (CdError)getErrorCode
{
return _errorCode;
}

- (BOOL)getNeedsPasscode {
- (BOOL)getNeedsPasscode
{
return _needsPasscode;
}

- (BOOL)getNoAppsFound {
- (BOOL)getNoAppsFound
{
return _noAppsFound;
}

- (BOOL)getPasscodeDialogDisplayed {
- (BOOL)getPasscodeDialogDisplayed
{
return _passcodeDialogDisplayed;
}

- (BOOL)getCommissionerPasscode {
- (BOOL)getCommissionerPasscode
{
return _commissionerPasscode;
}

- (BOOL)getQRCodeDisplayed {
- (BOOL)getQRCodeDisplayed
{
return _qRCodeDisplayed;
}

- (NSString *)description {
- (NSString *)description
{
return [NSString stringWithFormat:@"MCCommissionerDeclaration::errorCode: %@\nMCCommissionerDeclaration::needsPasscode: %d\nMCCommissionerDeclaration::noAppsFound: %d\nMCCommissionerDeclaration::passcodeDialogDisplayed: %d\nMCCommissionerDeclaration::commissionerPasscode: %d\nMCCommissionerDeclaration::qRCodeDisplayed: %d",
[self stringForErrorCode:self.errorCode],
self.needsPasscode,
self.noAppsFound,
self.passcodeDialogDisplayed,
self.commissionerPasscode,
self.qRCodeDisplayed];
[self stringForErrorCode:self.errorCode],
self.needsPasscode,
self.noAppsFound,
self.passcodeDialogDisplayed,
self.commissionerPasscode,
self.qRCodeDisplayed];
}

- (NSString *)stringForErrorCode:(CdError)errorCode {
- (NSString *)stringForErrorCode:(CdError)errorCode
{
switch (errorCode) {
case kNoError:
return @"kNoError";
case kCommissionableDiscoveryFailed:
return @"kCommissionableDiscoveryFailed";
case kPaseConnectionFailed:
return @"kPaseConnectionFailed";
case kPaseAuthFailed:
return @"kPaseAuthFailed";
case kDacValidationFailed:
return @"kDacValidationFailed";
case kAlreadyOnFabric:
return @"kAlreadyOnFabric";
case kOperationalDiscoveryFailed:
return @"kOperationalDiscoveryFailed";
case kCaseConnectionFailed:
return @"kCaseConnectionFailed";
case kCaseAuthFailed:
return @"kCaseAuthFailed";
case kConfigurationFailed:
return @"kConfigurationFailed";
case kBindingConfigurationFailed:
return @"kBindingConfigurationFailed";
case kCommissionerPasscodeNotSupported:
return @"kCommissionerPasscodeNotSupported";
case kInvalidIdentificationDeclarationParams:
return @"kInvalidIdentificationDeclarationParams";
case kAppInstallConsentPending:
return @"kAppInstallConsentPending";
case kAppInstalling:
return @"kAppInstalling";
case kAppInstallFailed:
return @"kAppInstallFailed";
case kAppInstalledRetryNeeded:
return @"kAppInstalledRetryNeeded";
case kCommissionerPasscodeDisabled:
return @"kCommissionerPasscodeDisabled";
case kUnexpectedCommissionerPasscodeReady:
return @"kUnexpectedCommissionerPasscodeReady";
default:
return @"Unknown Error";
case kNoError:
return @"kNoError";
case kCommissionableDiscoveryFailed:
return @"kCommissionableDiscoveryFailed";
case kPaseConnectionFailed:
return @"kPaseConnectionFailed";
case kPaseAuthFailed:
return @"kPaseAuthFailed";
case kDacValidationFailed:
return @"kDacValidationFailed";
case kAlreadyOnFabric:
return @"kAlreadyOnFabric";
case kOperationalDiscoveryFailed:
return @"kOperationalDiscoveryFailed";
case kCaseConnectionFailed:
return @"kCaseConnectionFailed";
case kCaseAuthFailed:
return @"kCaseAuthFailed";
case kConfigurationFailed:
return @"kConfigurationFailed";
case kBindingConfigurationFailed:
return @"kBindingConfigurationFailed";
case kCommissionerPasscodeNotSupported:
return @"kCommissionerPasscodeNotSupported";
case kInvalidIdentificationDeclarationParams:
return @"kInvalidIdentificationDeclarationParams";
case kAppInstallConsentPending:
return @"kAppInstallConsentPending";
case kAppInstalling:
return @"kAppInstalling";
case kAppInstallFailed:
return @"kAppInstallFailed";
case kAppInstalledRetryNeeded:
return @"kAppInstalledRetryNeeded";
case kCommissionerPasscodeDisabled:
return @"kCommissionerPasscodeDisabled";
case kUnexpectedCommissionerPasscodeReady:
return @"kUnexpectedCommissionerPasscodeReady";
default:
return @"Unknown Error";
}
}

- (void)logDetail {
- (void)logDetail
{
ChipLogDetail(AppServer, "MCCommissionerDeclaration::logDetail()\n%@", [self description]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

#import <Foundation/Foundation.h>

#ifndef MCCommissionerDeclaration_Internal_h
#define MCCommissionerDeclaration_Internal_h
#ifndef MCCommissionerDeclaration_Internal_h
#define MCCommissionerDeclaration_Internal_h

@interface MCCommissionerDeclaration ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,28 @@
/** @brief A container class for User Directed Commissioning (UDC) callbacks. */
@interface MCConnectionCallbacks : NSObject


/**
* @param connectionCompleteCallback is required.
* @param commissionerDeclarationCallback is optional.
*
* @return A new instance of MCConnectionCallbacks.
* @param connectionCompleteCallback is required.
* @param commissionerDeclarationCallback is optional.
*
* @return A new instance of MCConnectionCallbacks.
*/
- (instancetype _Nonnull)initWithCallbacks:(void (^_Nonnull)(NSError * _Nonnull))connectionCompleteCallback
commissionerDeclarationCallback:(void (^_Nullable)(MCCommissionerDeclaration * _Nonnull))commissionerDeclarationCallback;

/**
* (Required) The callback called when the connection process has ended, regardless of whether it was successful or not.
*/
* (Required) The callback called when the connection process has ended, regardless of whether it was successful or not.
*/
@property void (^_Nullable connectionCompleteCallback)(NSError * _Nonnull);


/**
* (Optional) The callback called when the Client/Commissionee receives a CommissionerDeclaration
* message from the CastingPlayer/Commissioner. This callback is needed to support UDC features
* where a reply from the Commissioner is expected. It provides information indicating the
* Commissioner’s pre-commissioning state.
*/
/**
* (Optional) The callback called when the Client/Commissionee receives a CommissionerDeclaration
* message from the CastingPlayer/Commissioner. This callback is needed to support UDC features
* where a reply from the Commissioner is expected. It provides information indicating the
* Commissioner’s pre-commissioning state.
*/
@property void (^_Nullable commissionerDeclarationCallback)(MCCommissionerDeclaration * _Nonnull);


@end

#endif /* MCConnectionCallbacks_h */
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
@implementation MCConnectionCallbacks

- (instancetype _Nonnull)initWithCallbacks:(void (^_Nonnull)(NSError * _Nonnull))connectionCompleteCallback
commissionerDeclarationCallback:(void (^_Nullable)(MCCommissionerDeclaration * _Nonnull))commissionerDeclarationCallback {
commissionerDeclarationCallback:(void (^_Nullable)(MCCommissionerDeclaration * _Nonnull))commissionerDeclarationCallback
{
self = [super init];
if (self) {
self.connectionCompleteCallback = connectionCompleteCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
#import "MCTargetAppInfo.h"
#import <Foundation/Foundation.h>

#ifndef MCIdentificationDeclarationOptions_h
#define MCIdentificationDeclarationOptions_h
Expand All @@ -38,10 +38,10 @@
- (BOOL)getCommissionerPasscodeReady;
- (BOOL)getCancelPasscode;

/**
* @brief Adds a TargetAppInfo to the IdentificationDeclarationOptions.java TargetAppInfos list,
* up to a maximum of CHIP_DEVICE_CONFIG_UDC_MAX_TARGET_APPS.
*/
/**
* @brief Adds a TargetAppInfo to the IdentificationDeclarationOptions.java TargetAppInfos list,
* up to a maximum of CHIP_DEVICE_CONFIG_UDC_MAX_TARGET_APPS.
*/
- (BOOL)addTargetAppInfo:(MCTargetAppInfo *)targetAppInfo NS_SWIFT_NAME(addTargetAppInfo(_:));
- (NSArray<MCTargetAppInfo *> *)getTargetAppInfoList;

Expand Down
Loading

0 comments on commit 0ed7d51

Please sign in to comment.