<commit_before>/*
 *   Copyright (c) 2022 Project CHIP Authors
 *   All rights reserved.
 *
 *   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.
 *
 */

#include "PairingDelegateBridge.h"
#import <Matter/Matter.h>

@interface CHIPToolPairingDelegate ()
@end

@implementation CHIPToolPairingDelegate
- (void)onStatusUpdate:(MTRPairingStatus)status
{
    NSLog(@"Pairing Status Update: %lu", status);
    switch (status) {
    case MTRPairingStatusSuccess:
        ChipLogProgress(chipTool, "Secure Pairing Success");
        ChipLogProgress(chipTool, "CASE establishment successful");
        break;
    case MTRPairingStatusFailed:
        ChipLogError(chipTool, "Secure Pairing Failed");
        break;
    case MTRPairingStatusUnknown:
        ChipLogError(chipTool, "Uknown Pairing Status");
        break;
    }
}

- (void)onPairingComplete:(NSError *)error
{
    if (error != nil) {
        ChipLogProgress(chipTool, "PASE establishment failed");
        _commandBridge->SetCommandExitStatus(error);
        return;
    }
    ChipLogProgress(chipTool, "Pairing Success");
    ChipLogProgress(chipTool, "PASE establishment successful");
    NSError * commissionError;
    [_commissioner commissionDevice:_deviceID commissioningParams:_params error:&commissionError];
    if (commissionError != nil) {<commit_msg>Fail darwin-framework-tool pairing commands once the SDK says it's failed. (#20639)<commit_after>/*
 *   Copyright (c) 2022 Project CHIP Authors
 *   All rights reserved.
 *
 *   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.
 *
 */

#include "PairingDelegateBridge.h"
#import <Matter/Matter.h>

@interface CHIPToolPairingDelegate ()
@end

@implementation CHIPToolPairingDelegate
- (void)onStatusUpdate:(MTRPairingStatus)status
{
    NSLog(@"Pairing Status Update: %lu", status);
    switch (status) {
    case MTRPairingStatusSuccess:
        ChipLogProgress(chipTool, "Secure Pairing Success");
        ChipLogProgress(chipTool, "CASE establishment successful");
        break;
    case MTRPairingStatusFailed:
        ChipLogError(chipTool, "Secure Pairing Failed");
        _commandBridge->SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE);
        break;
    case MTRPairingStatusUnknown:
        ChipLogError(chipTool, "Uknown Pairing Status");
        break;
    }
}

- (void)onPairingComplete:(NSError *)error
{
    if (error != nil) {
        ChipLogProgress(chipTool, "PASE establishment failed");
        _commandBridge->SetCommandExitStatus(error);
        return;
    }
    ChipLogProgress(chipTool, "Pairing Success");
    ChipLogProgress(chipTool, "PASE establishment successful");
    NSError * commissionError;
    [_commissioner commissionDevice:_deviceID commissioningParams:_params error:&commissionError];
    if (commissionError != nil) {
{'fraction_non_alphanumeric': 0.09014675052410902, 'fraction_numerical': 0.00550314465408805, 'mean_word_length': 3.8073047858942064, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3752488', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1051, 'n_words': 325}