|
31 | 31 | #import "MTRDeviceControllerStartupParams.h"
|
32 | 32 | #import "MTRDeviceControllerStartupParams_Internal.h"
|
33 | 33 | #import "MTRDeviceController_Internal.h"
|
| 34 | +#import "MTRDiagnosticLogsDownloader.h" |
34 | 35 | #import "MTRError_Internal.h"
|
35 | 36 | #import "MTRFabricInfo_Internal.h"
|
36 | 37 | #import "MTRFramework.h"
|
@@ -133,6 +134,8 @@ @interface MTRDeviceControllerFactory ()
|
133 | 134 | @property (nonatomic, readonly, nullable) id<MTROTAProviderDelegate> otaProviderDelegate;
|
134 | 135 | @property (nonatomic, readonly, nullable) dispatch_queue_t otaProviderDelegateQueue;
|
135 | 136 |
|
| 137 | +@property (nonatomic, readonly) MTRDiagnosticLogsDownloader * diagnosticLogsDownloader; |
| 138 | + |
136 | 139 | - (BOOL)findMatchingFabric:(FabricTable &)fabricTable
|
137 | 140 | params:(MTRDeviceControllerStartupParams *)params
|
138 | 141 | fabric:(const FabricInfo * _Nullable * _Nonnull)fabric;
|
@@ -332,6 +335,8 @@ - (void)cleanupStartupObjects
|
332 | 335 | delete _persistentStorageDelegate;
|
333 | 336 | _persistentStorageDelegate = nullptr;
|
334 | 337 | }
|
| 338 | + |
| 339 | + _diagnosticLogsDownloader = nil; |
335 | 340 | }
|
336 | 341 |
|
337 | 342 | - (CHIP_ERROR)_initFabricTable:(FabricTable &)fabricTable
|
@@ -1066,6 +1071,33 @@ - (nullable MTRDeviceController *)runningControllerForFabricIndex:(chip::FabricI
|
1066 | 1071 | return [self runningControllerForFabricIndex:fabricIndex includeControllerStartingUp:YES includeControllerShuttingDown:YES];
|
1067 | 1072 | }
|
1068 | 1073 |
|
| 1074 | +- (void)downloadLogFromNodeWithID:(NSNumber *)nodeID |
| 1075 | + controller:(MTRDeviceController *)controller |
| 1076 | + type:(MTRDiagnosticLogType)type |
| 1077 | + timeout:(NSTimeInterval)timeout |
| 1078 | + queue:(dispatch_queue_t)queue |
| 1079 | + completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion |
| 1080 | +{ |
| 1081 | + dispatch_sync(_chipWorkQueue, ^{ |
| 1082 | + if (![self isRunning]) { |
| 1083 | + return; |
| 1084 | + } |
| 1085 | + |
| 1086 | + if (_diagnosticLogsDownloader == nil) { |
| 1087 | + _diagnosticLogsDownloader = [[MTRDiagnosticLogsDownloader alloc] init]; |
| 1088 | + auto systemState = _controllerFactory->GetSystemState(); |
| 1089 | + systemState->BDXTransferServer()->SetDelegate([_diagnosticLogsDownloader getBridge]); |
| 1090 | + } |
| 1091 | + |
| 1092 | + [_diagnosticLogsDownloader downloadLogFromNodeWithID:nodeID |
| 1093 | + controller:controller |
| 1094 | + type:type |
| 1095 | + timeout:timeout |
| 1096 | + queue:queue |
| 1097 | + completion:completion]; |
| 1098 | + }); |
| 1099 | +} |
| 1100 | + |
1069 | 1101 | - (void)operationalInstanceAdded:(chip::PeerId &)operationalID
|
1070 | 1102 | {
|
1071 | 1103 | assertChipStackLockedByCurrentThread();
|
|
0 commit comments