Skip to content

Commit

Permalink
[Matter.framework] Add MTRDiagnosticLogsDelegate to darwin-framework-…
Browse files Browse the repository at this point in the history
…tool
  • Loading branch information
vivien-apple committed Dec 28, 2023
1 parent 3156925 commit 8b0eef6
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ executable("darwin-framework-tool") {
"${chip_root}/examples/chip-tool/commands/common/Commands.h",
"${chip_root}/examples/chip-tool/commands/common/HexConversion.h",
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp",
"commands/bdx/DiagnosticLogsDelegate.mm",
"commands/clusters/ClusterCommandBridge.h",
"commands/clusters/ModelCommandBridge.mm",
"commands/clusters/ReportCommandBridge.h",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
*
* Copyright (c) 2023 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.
*/
#pragma once
#import <Matter/Matter.h>

@interface DiagnosticLogsDelegate : NSObject <MTRDiagnosticLogsDelegate>
- (void)handleBDXTransferSessionBeginForNodeID:(NSNumber * _Nonnull)nodeID
controller:(MTRDeviceController * _Nonnull)controller
fileDesignator:(NSString * _Nonnull)fileDesignator
completion:(MTRStatusCompletion _Nonnull)completion;

- (void)handleBDXTransferSessionDataForNodeID:(NSNumber * _Nonnull)nodeID
controller:(MTRDeviceController * _Nonnull)controller
fileDesignator:(NSString * _Nonnull)fileDesignator
data:(NSData * _Nonnull)data
completion:(MTRStatusCompletion _Nonnull)completion;

- (void)handleBDXTransferSessionEndForNodeID:(NSNumber * _Nonnull)nodeID
controller:(MTRDeviceController * _Nonnull)controller
fileDesignator:(NSString * _Nonnull)fileDesignator
error:(NSError * _Nullable)error;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
*
* Copyright (c) 2023 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.
*/

#include "DiagnosticLogsDelegate.h"

@interface DiagnosticLogsDelegate ()
@end

@implementation DiagnosticLogsDelegate

- (instancetype)init
{
if (self = [super init]) {
}
return self;
}

- (void)handleBDXTransferSessionBeginForNodeID:(NSNumber * _Nonnull)nodeID
controller:(MTRDeviceController * _Nonnull)controller
fileDesignator:(NSString * _Nonnull)fileDesignator
completion:(MTRStatusCompletion _Nonnull)completion
{
NSLog(@"BDX Transfer Session Begin: %@", fileDesignator);
completion(nil);
}

- (void)handleBDXTransferSessionDataForNodeID:(NSNumber * _Nonnull)nodeID
controller:(MTRDeviceController * _Nonnull)controller
fileDesignator:(NSString * _Nonnull)fileDesignator
data:(NSData * _Nonnull)data
completion:(MTRStatusCompletion _Nonnull)completion
{
NSLog(@"BDX Transfer Session Data: %@: %@", fileDesignator, data);
completion(nil);
}

- (void)handleBDXTransferSessionEndForNodeID:(NSNumber * _Nonnull)nodeID
controller:(MTRDeviceController * _Nonnull)controller
fileDesignator:(NSString * _Nonnull)fileDesignator
error:(NSError * _Nullable)error
{
NSLog(@"BDX Transfer Session End: %@: %@", fileDesignator, error);
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <set>
#include <string>

#include "../bdx/DiagnosticLogsDelegate.h"
#include "../provider/OTAProviderDelegate.h"

#pragma once
Expand Down Expand Up @@ -66,6 +67,7 @@ class CHIPCommandBridge : public Command {
StopWaiting();
}

static DiagnosticLogsDelegate * mDiagnosticLogsDelegate;
static OTAProviderDelegate * mOTADelegate;

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
std::map<std::string, MTRDeviceController *> CHIPCommandBridge::mControllers;
dispatch_queue_t CHIPCommandBridge::mOTAProviderCallbackQueue;
OTAProviderDelegate * CHIPCommandBridge::mOTADelegate;
DiagnosticLogsDelegate * CHIPCommandBridge::mDiagnosticLogsDelegate;
constexpr char kTrustStorePathVariable[] = "PAA_TRUST_STORE_PATH";

CHIPToolKeypair * gNocSigner = [[CHIPToolKeypair alloc] init];
Expand Down Expand Up @@ -116,6 +117,7 @@
storage = [[CHIPToolPersistentStorageDelegate alloc] init];

mOTADelegate = [[OTAProviderDelegate alloc] init];
mDiagnosticLogsDelegate = [[DiagnosticLogsDelegate alloc] init];

auto factory = [MTRDeviceControllerFactory sharedInstance];
if (factory == nil) {
Expand All @@ -126,6 +128,7 @@
auto params = [[MTRDeviceControllerFactoryParams alloc] initWithStorage:storage];
params.shouldStartServer = YES;
params.otaProviderDelegate = mOTADelegate;
params.diagnosticLogsDelegate = mDiagnosticLogsDelegate;
NSArray<NSData *> * paaCertResults;
ReturnLogErrorOnFailure(GetPAACertsFromFolder(&paaCertResults));
if ([paaCertResults count] > 0) {
Expand Down
16 changes: 16 additions & 0 deletions src/darwin/Framework/Matter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@
B4E262172AA0CF2000DBA5BC /* RemoteDataModelLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = B4E262132AA0C7A300DBA5BC /* RemoteDataModelLogger.h */; };
B4E2621B2AA0D02000DBA5BC /* SleepCommand.mm in Sources */ = {isa = PBXBuildFile; fileRef = B4E262192AA0D01D00DBA5BC /* SleepCommand.mm */; };
B4E2621E2AA0D02D00DBA5BC /* WaitForCommissioneeCommand.mm in Sources */ = {isa = PBXBuildFile; fileRef = B4E2621C2AA0D02A00DBA5BC /* WaitForCommissioneeCommand.mm */; };
B4ECD4842B3B3E2E0022E16B /* DiagnosticLogsDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = B4ECD4822B3B3E2E0022E16B /* DiagnosticLogsDelegate.mm */; };
B4ECD4852B3B3E2E0022E16B /* DiagnosticLogsDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = B4ECD4832B3B3E2E0022E16B /* DiagnosticLogsDelegate.h */; };
BA09EB43247477BA00605257 /* libCHIP.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BA09EB3F2474762900605257 /* libCHIP.a */; };
D4772A46285AE98400383630 /* MTRClusterConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = D4772A45285AE98300383630 /* MTRClusterConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -679,6 +681,8 @@
B4E262132AA0C7A300DBA5BC /* RemoteDataModelLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteDataModelLogger.h; sourceTree = "<group>"; };
B4E262192AA0D01D00DBA5BC /* SleepCommand.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SleepCommand.mm; sourceTree = "<group>"; };
B4E2621C2AA0D02A00DBA5BC /* WaitForCommissioneeCommand.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WaitForCommissioneeCommand.mm; sourceTree = "<group>"; };
B4ECD4822B3B3E2E0022E16B /* DiagnosticLogsDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DiagnosticLogsDelegate.mm; sourceTree = "<group>"; };
B4ECD4832B3B3E2E0022E16B /* DiagnosticLogsDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLogsDelegate.h; sourceTree = "<group>"; };
BA09EB3F2474762900605257 /* libCHIP.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libCHIP.a; path = lib/libCHIP.a; sourceTree = BUILT_PRODUCTS_DIR; };
BA107AEE2470CFBB004287EB /* chip_xcode_build_connector.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = chip_xcode_build_connector.sh; sourceTree = "<group>"; };
D437613E285BDC0D0051FEA2 /* MTRErrorTestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRErrorTestUtils.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -747,6 +751,7 @@
037C3D7B2991BD4F00B7EEE2 /* commands */ = {
isa = PBXGroup;
children = (
B4ECD4812B3B3E2E0022E16B /* bdx */,
B4E262182AA0CFFE00DBA5BC /* delay */,
03FB93DA2A46200A0048CB35 /* discover */,
037C3D7C2991BD4F00B7EEE2 /* pairing */,
Expand Down Expand Up @@ -1348,6 +1353,15 @@
path = delay;
sourceTree = "<group>";
};
B4ECD4812B3B3E2E0022E16B /* bdx */ = {
isa = PBXGroup;
children = (
B4ECD4822B3B3E2E0022E16B /* DiagnosticLogsDelegate.mm */,
B4ECD4832B3B3E2E0022E16B /* DiagnosticLogsDelegate.h */,
);
path = bdx;
sourceTree = "<group>";
};
BA09EB3E2474762900605257 /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand All @@ -1374,6 +1388,7 @@
039546A02991DFC5006D42A8 /* json_tool.h in Headers */,
037C3DB12991BD5000B7EEE2 /* OpenCommissioningWindowCommand.h in Headers */,
039145E92993179300257B3E /* GetCommissionerNodeIdCommand.h in Headers */,
B4ECD4852B3B3E2E0022E16B /* DiagnosticLogsDelegate.h in Headers */,
037C3DCE2991BD5100B7EEE2 /* CHIPCommandBridge.h in Headers */,
037C3DD22991BD5200B7EEE2 /* InteractiveCommands.h in Headers */,
037C3DAF2991BD4F00B7EEE2 /* DeviceControllerDelegateBridge.h in Headers */,
Expand Down Expand Up @@ -1664,6 +1679,7 @@
B45373D72A9FEB0C00807602 /* lws_dll2.c in Sources */,
B45373FE2A9FEC4F00807602 /* unix-fds.c in Sources */,
B45373C72A9FEA9100807602 /* pollfd.c in Sources */,
B4ECD4842B3B3E2E0022E16B /* DiagnosticLogsDelegate.mm in Sources */,
B45373BE2A9FEA9100807602 /* network.c in Sources */,
B45373BD2A9FEA9100807602 /* service.c in Sources */,
0395469E2991DFC5006D42A8 /* json_writer.cpp in Sources */,
Expand Down

0 comments on commit 8b0eef6

Please sign in to comment.