修复链接摄像头的相关问题V1

This commit is contained in:
wbzhan_macbook
2019-07-19 08:39:11 +08:00
parent 43bfceb262
commit aade501983
6 changed files with 70 additions and 96 deletions
@@ -47,7 +47,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
@property (strong,nonatomic) NSMutableDictionary *addresses;
//技威服务器 socket返回contactID 即cameraId
@property (nonatomic,copy) NSString *contactID;
//@property (nonatomic,copy) NSString *contactID;
@property (nonatomic,assign) NSInteger flag;
@property (nonatomic,assign) NSInteger type;
@property (nonatomic,copy) NSString *address;
@@ -393,68 +393,76 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
[self.view makeToast:@"声波配网成功"];
//如果智能联机,设备配网成功,就断开发送智能联机
[[GWP2PDeviceLinker shareInstance] p2pStopSmartLink];
NSString *deviceID = [deviceDict[@"deviceID"] stringValue];
NSString *deviceIP = deviceDict[@"deviceIP"];
NSString *devicePassword = deviceDict[@"devicePassword"];
weakSelf.contactID = [NSString stringWithFormat:@"%d",deviceID];
if (![deviceDict[@"isInitPassword"] boolValue]) { //设备没有初始化密码,设置密码
weakSelf.deviceID = deviceID;
[self resetPassWord];//初始化密码
//如果重置之后,则重新设置密码
if (IsEmptyStr(devicePassword)) { //设备没有初始化密码,设置密码
[[GWP2PClient sharedClient] setDeviceInitialPassword:@"123" withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
NSLog(@"success:%i %@",success,dataDictionary);
[weakSelf.view makeToast:[NSString stringWithFormat:@"未初始化过设备密码,初始化设备密码失败 result = %i",dataDictionary]];
[weakSelf resetPassWord];//初始化密码
if (success) {
[weakSelf initPwdResault:dataDictionary];
}else{
dispatch_async(dispatch_get_main_queue(), ^{
//只为做 dissPogress处理并非成功
weakSelf.lodviewMissStyle =lodingViewdissMissSuccsess;
[weakSelf connectNormalView];
_canDissMissController = YES;
[weakSelf bindCameraDevice];
// if (success) {
// [weakSelf initPwdResault:dataDictionary];
// }else{
// dispatch_async(dispatch_get_main_queue(), ^{
// //只为做 dissPogress处理并非成功
// weakSelf.lodviewMissStyle =lodingViewdissMissSuccsess;
// [weakSelf connectNormalView];
// _canDissMissController = YES;
// [weakSelf.view makeToast:NSLocalizedString(@"operator_failure", nil)];
});
}
// });
// }
}];
} else {
//设备已经初始化过密码,则直接获取设备信息
}else{
[[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:devicePassword completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
NSLog(@"success:%i %@",success,dataDictionary);
[weakSelf.view makeToast:[NSString stringWithFormat:@"获取设备信息失败 result = %i",dataDictionary]];
[weakSelf resetPassWord];//更新密码
if (success) {
dispatch_async(dispatch_get_main_queue(), ^{
//[self.view makeToast:NSLocalizedString(@"operator_success", nil)];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
usleep(800000);
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf ifishUserBindcameraIdBy:self.contactID];
});
});
});
}else{
dispatch_async(dispatch_get_main_queue(), ^{
self.lodviewMissStyle =lodingViewdissMissSuccsess;
[self connectNormalView];
_canDissMissController = YES;
// [self.view makeToast:NSLocalizedString(@"operator_failure", nil)];
});
}
[weakSelf bindCameraDevice];
}];
}
// else {
// //设备已经初始化过密码,则直接获取设备信息
// [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:devicePassword completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary<NSString *,id> *dataDictionary) {
// NSLog(@"success:%i %@",success,dataDictionary);
// [weakSelf resetPassWord];//更新密码
// if (success) {
// dispatch_async(dispatch_get_main_queue(), ^{
// //[self.view makeToast:NSLocalizedString(@"operator_success", nil)];
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// usleep(800000);
// dispatch_async(dispatch_get_main_queue(), ^{
//
// [weakSelf ifishUserBindcameraIdBy:self.contactID];
//
// });
// });
// });
// }else{
// dispatch_async(dispatch_get_main_queue(), ^{
//
// self.lodviewMissStyle =lodingViewdissMissSuccsess;
// [self connectNormalView];
// _canDissMissController = YES;
// [self.view makeToast:NSLocalizedString(@"operator_failure", nil)];
//
// });
// }
// }];
// }
}];
}
//初始化设备密码回调
-(void)initPwdResault:(NSDictionary *)parameter{
-(void)bindCameraDevice{
NSString * contactName = [NSString stringWithFormat:@"Cam%@", self.contactID];
NSString * contactName = [NSString stringWithFormat:@"Cam%@", self.deviceID];
ContactDAO *contactDAO = [[ContactDAO alloc] init];
Contact *contact = [contactDAO isContact:self.contactID];
Contact *contact = [contactDAO isContact:self.deviceID];
if(contact!=nil){
@@ -464,39 +472,18 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
[[FListManager sharedFList] updatee:contact];
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
usleep(800000);
dispatch_async(dispatch_get_main_queue(), ^{
//设置密码成功后爱鱼奇用户绑定摄像头
[self ifishUserBindcameraIdBy:self.contactID];
});
});
});
[self ifishUserBindcameraIdBy:self.deviceID];
}else{
Contact *contact = [[Contact alloc] init];
contact.contactId = self.contactID;
contact.contactId = self.deviceID;
contact.contactName = contactName;
contact.contactPassword = self.lastSetPassword;
contact.contactType = CONTACT_TYPE_UNKNOWN;
[[FListManager sharedFList] insert:contact];
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
usleep(800000);
dispatch_async(dispatch_get_main_queue(), ^{
//设置密码成功后爱鱼奇用户绑定摄像头
[self ifishUserBindcameraIdBy:self.contactID];
});
});
});
//设置密码成功后爱鱼奇用户绑定摄像头
[self ifishUserBindcameraIdBy:self.deviceID];
}
}
@@ -638,12 +625,11 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) {
-(void)ifishUserBindcameraIdBy:(NSString *)cameraId
{
NSLog(@"cameraId = %@",cameraId);
NSMutableArray *oldCameraArr= [[DataCenter defaultDtacenter]valueForKey:@"cameraArr"];
if (!oldCameraArr) {
//无设备
oldCameraArr = [[NSMutableArray alloc] init];
}
IfishCameraModel *camer=[[IfishCameraModel alloc] init];