Last Updated on : 2025-01-08 06:31:34download
Device logs can improve your efficiency in troubleshooting device issues. To swiftly pinpoint user issues, it is advisable for the devices to support this feature. The attribute extraAbility
of ThingSmartCameraType
offers interfaces related to device log upload.
The IPC embedded SDK v3.10.6 and above version supports sending device upload logs commands from App SDK. The lower version only supports sending commands from platform.
API description
@property (nonatomic, assign, readonly) BOOL hasRespondToUploadLogCmdAbility;
API description
- (void)deliverUploadLogCmdWithConfig:(id<ThingSmartCameraUploadLogConfig>)config success:(nullable ThingSuccessHandler)success failure:(nullable ThingFailureError)failure;
Parameter description
Parameter | Description |
---|---|
config |
The configuration. It can be set to the timeout, defaulting to 60 seconds. |
success |
The success callback. |
failure |
The failure callback. |
You can set the debugAbilityDelegate
of extraAbility
to check whether the log upload is completed.
API description
- (void)cameraDidUploadLogWithResult:(BOOL)result extInfo:(nullable NSDictionary *)extInfo;
Parameter description
Parameter | Description |
---|---|
result |
The completion result. YES means success. |
extInfo |
The extension information. |
Example
Objective-C:
@interface SampleModelUploadLogConfig : NSObject <ThingSmartCameraUploadLogConfig>
@end
@implementation SampleModelUploadLogConfig
@synthesize uploadTimeout;
@end
@interface SampleViewController : SampleViewController <ThingSmartCameraDelegate,ThingSmartCameraDebugAbilityDelegate>
@end
@implementation SampleViewController
- (void)deliverUploadLogCmd {
// deviceModel is the data model of the listed IPCs.
NSInteger p2pType = [deviceModel p2pType];
id<ThingSmartCameraType> camera = [ThingSmartCameraFactory cameraWithP2PType:@(p2pType) deviceId:deviceModel.devId delegate:self];
BOOL hasAbility = camera.extraAbility.hasRespondToUploadLogCmdAbility;
if (hasAbility == NO) {
return;
}
SampleModelUploadLogConfig *uploadLogConfig = [[SampleModelUploadLogConfig alloc] init];
uploadLogConfig.uploadTimeout = 60;
camera.extraAbility.debugAbilityDelegate = self;
[camera.extraAbility deliverUploadLogCmdWithConfig:uploadLogConfig success:^{
} failure:^(NSError * _Nonnull error) {
}];
}
#pragma mark - ThingSmartCameraDelegate
#pragma mark - ThingSmartCameraDebugAbilityDelegate
- (void)cameraDidUploadLogWithResult:(BOOL)result extInfo:(NSDictionary *)extInfo {
if (result == YES) {
NSLog(@"upload log success");
}
}
@end
Swift:
class SampleModelUploadLogConfig: NSObject, ThingSmartCameraUploadLogConfig {
var uploadTimeout: NSTimeInterval
init(uploadTimeout: NSTimeInterval) {
self.uploadTimeout = uploadTimeout
}
}
class SampleViewController: UIViewController {
var deviceModel: ThingSmartDeviceModel?
private func deliverUploadLogCmd {
let p2pType: NSNumber = NSNumber(value: deviceModel.p2pType())
let camera = ThingSmartCameraFactory.camera(withP2PType: p2pType, deviceId: deviceModel.devId, delegate: self)
let extraAbility ? ThingSmartCameraExtraAbility = camera.extraAbility
guard let hasAbility = extraAbility.hasRespondToUploadLogCmdAbility else {
print("the device has no debug ability")
return
}
extraAbility.debugAbilityDelegate = self
let uploadLogConfig = SampleModelUploadLogConfig(uploadTimeout: 60)
extraAbility.deliverUploadLogCmd(with: uploadLogConfig, success: {}, failure: {error in
print("deliver cmd failed")
})
}
}
extension SampleViewController: ThingSmartCameraDelegate,ThingSmartCameraDebugAbilityDelegate {
func cameraDidUploadLog(withResult result: Bool, extInfo: [AnyHashable : Any]?) {
if result == false {
return
}
print("upload log success")
}
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback