From 24bb267f97dc4acbf3115443149726880b7cefe7 Mon Sep 17 00:00:00 2001 From: wbzhan_macbook Date: Sat, 20 Jul 2019 08:33:44 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ifish/Info.plist | 2 +- .../IfishBindDeviceSelectViewController.m | 2 + .../IfishP2PMonitorController.m | 47 ++++--- .../YooseeNextConnectViewController.mm | 132 ++++++++++++++---- 4 files changed, 136 insertions(+), 47 deletions(-) diff --git a/Ifish/Info.plist b/Ifish/Info.plist index 2e9fc2c..1444226 100644 --- a/Ifish/Info.plist +++ b/Ifish/Info.plist @@ -70,7 +70,7 @@ CFBundleVersion - 9.9.4 + 9.9.6 ITSAppUsesNonExemptEncryption LSApplicationCategoryType diff --git a/Ifish/controllers/IfishTabControllers/设备/IfishDeviceSelectList/IfishBindDeviceSelectViewController.m b/Ifish/controllers/IfishTabControllers/设备/IfishDeviceSelectList/IfishBindDeviceSelectViewController.m index 1c2e91c..36f40a9 100644 --- a/Ifish/controllers/IfishTabControllers/设备/IfishDeviceSelectList/IfishBindDeviceSelectViewController.m +++ b/Ifish/controllers/IfishTabControllers/设备/IfishDeviceSelectList/IfishBindDeviceSelectViewController.m @@ -19,6 +19,7 @@ @interface IfishBindDeviceSelectViewController () @property (nonatomic,strong) UITableView *tableView; +Assign BOOL isConnectP2P; @end extern BOOL isfromCameraView; @implementation IfishBindDeviceSelectViewController @@ -26,6 +27,7 @@ extern BOOL isfromCameraView; - (void)viewDidLoad { [super viewDidLoad]; isfromCameraView = NO; + _isConnectP2P = NO; // Do any additional setup after loading the view. [self addTitleViewWithTitle:@"选择设备"]; [self creatTab]; diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m index 920c224..7df0315 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m @@ -151,17 +151,16 @@ Strong UIImage *screenShotImage;//截图 return; } - if ([self.contact.isActive isEqualToString:@"1"]) { +// if ([self.contact.isActive isEqualToString:@"1"]) { - [self monitorP2PCall]; - [self hiddenMonitoringUI:NO callWithErrorType:100 isReCall:YES]; - }else if ([self.contact.isActive isEqualToString:@"0"]){ + [self cameraConnectSeting]; +// }else if ([self.contact.isActive isEqualToString:@"0"]){ - UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"" message:@"请扫描产品外包装上的激活码来激活摄像头" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"前往扫描", nil]; - alert.tag = WEIJIHUO_ALERT; - [alert show]; - - } +// UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"" message:@"请扫描产品外包装上的激活码来激活摄像头" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"前往扫描", nil]; +// alert.tag = WEIJIHUO_ALERT; +// [alert show]; +// +// } } //环境校验 -(void)checkNetStatus{ @@ -237,19 +236,19 @@ Strong UIImage *screenShotImage;//截图 _isReject=YES; _isStop = NO; _isPushNextView = NO; - if ([self.contact.isActive isEqualToString:@"1"]) { +// if ([self.contact.isActive isEqualToString:@"1"]) { [self connectDevice]; - } +// } //监控竖屏时,各控件初始化(先) [self initComponentForPortrait]; //监控横屏时,各控件初始化(后) [self initComponentForHorizontalScreen]; - if ([self.contact.isActive isEqualToString:@"1"]) { - - }else{ +// if ([self.contact.isActive isEqualToString:@"1"]) { +// +// }else{ [self.yProgressView stop]; - } +// } } #pragma mark --LoadBaseUI -(UIView *)canvasView{ @@ -263,15 +262,25 @@ Strong UIImage *screenShotImage;//截图 return _canvasView; } #pragma mark - 初始化设备 p2pConnect --(void)connectDevice{ - if ([GWP2PClient sharedClient].linkStatus==P2PLinkStatusOK) { - _connectDevice = YES; +-(void)cameraConnectSeting{ + //rtsp监控界面弹出修改 + [self monitorP2PCall]; + if (_isPushNextView) { + return; } + [self hiddenMonitoringUI:NO callWithErrorType:100 isReCall:YES]; + +} +-(void)connectDevice{ + UserModel *model=[dataContorl getUserInfo]; NSString *userIDName=[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff]; //初始化设备 if (!_connectDevice) { NSLog(@"正在检查P2P连接状态"); + if ([GWP2PClient sharedClient].linkStatus == P2PLinkStatusOK) { + [[GWP2PClient sharedClient] disconnect]; + } _connectDevice = [[GWP2PClient sharedClient] connectWithAccount:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2 sessionID1:model.sessionID sessionID2:model.sessionID2 customerIDs:nil]; if (_connectDevice) { @@ -295,7 +304,7 @@ Strong UIImage *screenShotImage;//截图 return; } //p2p未连接 - if ([GWP2PClient sharedClient].linkStatus != P2PLinkStatusOK) { + if (!_connectDevice) { [self connectDevice]; if(_connectDevice){ // 连接摄像头 diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm index b94b296..f4741cf 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm @@ -28,6 +28,9 @@ #import "PushMasssageWebViewController.h" #import "IfishUserObsever.h" #import +#import "MyMD5.h" +#import "IfishUserDataUnity.h" +#import "DeviceCameraModel.h" typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { lodingViewdissMissSuccsess=0,// default is 0 lodingViewdissMissfail, @@ -326,7 +329,7 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { //密码 -(void)resetPassWord{ - NSString *newPassword = @"123"; + NSString *newPassword = GIWEI_INITPASS; self.lastSetPassword = [Utils GetTreatedPassword:newPassword]; } @@ -384,6 +387,8 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { //智能联机 -(void)smartLinkConnect{ WEAK_SELF; + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + [[GWP2PDeviceLinker shareInstance] p2pSmartLinkDeviceWithWiFiSSID:weakSelf.wifiName password:weakSelf.wifiPwd useSimpleConfig:YES deviceLinkIn:^(NSDictionary *deviceDict) { NSLog(@"声波配网成功,返回数据:%@",deviceDict); if (weakSelf.isDeviceLinkIn) { @@ -394,16 +399,17 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { //如果智能联机,设备配网成功,就断开发送智能联机 [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; NSString *deviceID = [deviceDict[@"deviceID"] stringValue]; - NSString *deviceIP = deviceDict[@"deviceIP"]; - NSString *devicePassword = deviceDict[@"devicePassword"]; +// NSString *deviceIP = deviceDict[@"deviceIP"]; +// NSString *devicePassword = deviceDict[@"devicePassword"]; weakSelf.deviceID = deviceID; [self resetPassWord];//初始化密码 + [weakSelf bindCameraDevice]; //如果重置之后,则重新设置密码 - if (IsEmptyStr(devicePassword)) { //设备没有初始化密码,设置密码 - [[GWP2PClient sharedClient] setDeviceInitialPassword:@"123" withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { - NSLog(@"success:%i %@",success,dataDictionary); - [weakSelf resetPassWord];//初始化密码 - [weakSelf bindCameraDevice]; +// if (IsEmptyStr(devicePassword)) { //设备没有初始化密码,设置密码 +// [[GWP2PClient sharedClient] setDeviceInitialPassword:GIWEI_INITPASS withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { +// NSLog(@"success:%i %@",success,dataDictionary); +// [weakSelf resetPassWord];//初始化密码 +// [weakSelf bindCameraDevice]; // if (success) { // [weakSelf initPwdResault:dataDictionary]; // }else{ @@ -415,15 +421,15 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { // [weakSelf.view makeToast:NSLocalizedString(@"operator_failure", nil)]; // }); // } - }]; - }else{ - [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:devicePassword completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { - NSLog(@"success:%i %@",success,dataDictionary); - [weakSelf resetPassWord];//更新密码 - [weakSelf bindCameraDevice]; - - }]; - } +// }]; +// }else{ +// [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:@"123" completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { +// NSLog(@"success:%i %@",success,dataDictionary); +// [weakSelf resetPassWord];//更新密码 +// [weakSelf bindCameraDevice]; +// +// }]; +// } // else { // //设备已经初始化过密码,则直接获取设备信息 // [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:devicePassword completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { @@ -710,19 +716,91 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { }]; } -//绑定成功之后设置 +//绑定成功之后,重新获取用户信息 -(void)setWindowRootWith:(IfishCameraModel *)cameraMdel{ + [[GWP2PClient sharedClient] disconnect]; + [self.view makeToast:@"添加成功"]; + [self getMoreUserData:cameraMdel]; - IfishP2PMonitorController *monitorVC=[[IfishP2PMonitorController alloc] init]; - monitorVC.contact = cameraMdel; - UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:monitorVC]; - - UIApplication*app=[UIApplication sharedApplication]; - AppDelegate*app1=(AppDelegate*)app.delegate; - app1.window.rootViewController=nav; - //绑定成功 加 经验值 - [[IfishUserObsever sharedInstance] xinZengJingYanZhi:IFISHADDEXP_BIDCAMERA addType:IFISHADDEXPTYPE1]; +} +//获取个人信息 +-(void)getMoreUserData:(IfishCameraModel *)cameraMdel{ + NSString *userId = [dataContorl dataControlGetUserIdInfo]; + [AFHttpTool getMoreUserDataWith:userId success:^(id response) { + NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; + NSString *result=reDic[@"result"]; + if ([result isEqualToString:@"100"]) { + NSDictionary *dataDic = reDic[@"data"]; + //设备信息 + NSArray*deviceArray=dataDic[@"device"]; + NSArray*cameraA=dataDic[@"camera"]; + NSMutableArray *deviceArr = [[NSMutableArray alloc] init]; + if ([deviceArray count]!=0) { + + for (NSDictionary*deviceDic in deviceArray) { + DeviceModel*devicemodel=[[DeviceModel alloc] initWithDict:deviceDic]; + + [deviceArr insertObject:devicemodel atIndex:0]; + + } + } + [[DataCenter defaultDtacenter]setValue:deviceArr forKey:@"deviceInfo"]; + + //存储摄像头设备信息 + NSMutableArray *camras = [[NSMutableArray alloc] init]; + if (cameraA .count !=0) { + + if ([cameraA count]!=0) { + + for (NSDictionary * cameraDic in cameraA) { + + IfishCameraModel *camera=[[IfishCameraModel alloc] initWithDict:cameraDic]; + [camras insertObject:camera atIndex:0]; + + } + } + } + //存储摄像头数组 + [[DataCenter defaultDtacenter]setValue:camras forKey:@"cameraArr"]; + + /** + * 设备摄像头关系数组 + */ + NSArray*deviceCamera=dataDic[@"deviceCamera"]; + NSMutableArray *devicamerArr=[[NSMutableArray alloc] init]; + if (deviceCamera) { + + for (NSDictionary * deviceCameraDic in deviceCamera) { + DeviceCameraModel *dcmodel=[[DeviceCameraModel alloc] init]; + + dcmodel.deviceId = deviceCameraDic[@"deviceId"]; + dcmodel.cameraId = deviceCameraDic[@"cameraId"]; + + [devicamerArr addObject:dcmodel]; + } + + + } + //存储摄像头设备关系数组 + [[DataCenter defaultDtacenter]setValue:devicamerArr forKey:@"devicamerArr"]; + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + IfishP2PMonitorController *monitorVC=[[IfishP2PMonitorController alloc] init]; + monitorVC.contact = cameraMdel; + UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:monitorVC]; + + UIApplication*app=[UIApplication sharedApplication]; + AppDelegate*app1=(AppDelegate*)app.delegate; + app1.window.rootViewController=nav; + //绑定成功 加 经验值 + [[IfishUserObsever sharedInstance] xinZengJingYanZhi:IFISHADDEXP_BIDCAMERA addType:IFISHADDEXPTYPE1]; + }); + + } + + } failure:^(NSError *err) { + }]; } @end