From 0b7755866e68dbcbca11a9a2dd7db7881e87597d Mon Sep 17 00:00:00 2001 From: wbzhan Date: Mon, 22 Jul 2019 15:15:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E7=89=88=E6=9C=ACV9.9.8?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ifish/Info.plist | 2 +- .../maincontroller/RightViewController.m | 1 - .../lookafterServer/MineKanHuViewController.m | 2 - .../ShopKanHuP2PViewController.m | 59 ++++++++++++----- .../IfishP2PMonitorController.m | 64 +++++++++++++------ .../YooseeNextConnectViewController.mm | 44 ++++++------- 6 files changed, 107 insertions(+), 65 deletions(-) diff --git a/Ifish/Info.plist b/Ifish/Info.plist index 1444226..c8d4caa 100644 --- a/Ifish/Info.plist +++ b/Ifish/Info.plist @@ -70,7 +70,7 @@ CFBundleVersion - 9.9.6 + 9.9.8 ITSAppUsesNonExemptEncryption LSApplicationCategoryType diff --git a/Ifish/controllers/FishTinkController/maincontroller/RightViewController.m b/Ifish/controllers/FishTinkController/maincontroller/RightViewController.m index 64879af..47003b2 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/RightViewController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/RightViewController.m @@ -37,7 +37,6 @@ #define DESCREPTION_CAMERANAME3_TAG 3013 #define DESCREPTION_CAMERANAME4_TAG 3014 -#import "YooseConnectFirstViewController.h" #import "DeviceCameraModel.h" #import "IfishP2PMonitorController.h" diff --git a/Ifish/controllers/IfishTabControllers/探索/lookafterServer/MineKanHuViewController.m b/Ifish/controllers/IfishTabControllers/探索/lookafterServer/MineKanHuViewController.m index ec0800d..60cfa37 100644 --- a/Ifish/controllers/IfishTabControllers/探索/lookafterServer/MineKanHuViewController.m +++ b/Ifish/controllers/IfishTabControllers/探索/lookafterServer/MineKanHuViewController.m @@ -11,8 +11,6 @@ #import "MineKanHuNotBindSecondViewCell.h" #import "MineKanHuNormalViewCell.h" #import "PushMasssageWebViewController.h" -#import "YooseConnectFirstViewController.h" -//#import "IfishSelectCardViewController.h" #import "IfishBindDeviceSelectViewController.h" #import "IfishCameraModel.h" #define CELL_KANHURAG1 555 diff --git a/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopKanHuP2PViewController.m b/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopKanHuP2PViewController.m index f20e8a4..006a467 100644 --- a/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopKanHuP2PViewController.m +++ b/Ifish/controllers/IfishTabControllers/探索/lookafterWorkbech/ShopKanHuP2PViewController.m @@ -23,9 +23,11 @@ BOOL _isCanAutoOrientation;//限制屏幕什么时候可以旋转 - BOOL _connectDevice; //是否连接设备 BOOL _isStop;//是否暂停 用于区分是 暂停按钮 还是 连接失败按钮 - + BOOL _connectDevice; //是否连接到了P2P + BOOL _isConnectCamera;//是否连接到设备 + BOOL _isconnecting;//是否正在连接摄像头 + int _OnLine; } @end @@ -38,6 +40,7 @@ self.isVideoModeHD = NO; _isReject=YES; _isStop = NO; + _isconnecting = NO; [self addTitleViewWithTitle:@"看护"]; [self connectDevice]; //监控竖屏时,各控件初始化(先) @@ -74,23 +77,45 @@ UserModel *model=[dataContorl getUserInfo]; NSString *userIDName=[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff]; //初始化设备 - if (!_connectDevice) { - NSLog(@"正在初始化设备"); + if ([GWP2PClient sharedClient].linkStatus != P2PLinkStatusOK) { + NSLog(@"正在检查P2P连接状态"); _connectDevice = [[GWP2PClient sharedClient] connectWithAccount:userIDName codeStr1:model.P2PVerifyCode1 codeStr2:model.P2PVerifyCode2 sessionID1:model.sessionID sessionID2:model.sessionID2 customerIDs:nil]; + + if (_connectDevice) { + [self connectCamera]; + }else{ + NSLog(@"p2pConnect failure.失败,不能操作设备"); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.view makeToast:@"连接失败"]; + [self hiddenMonitoringUI:NO callWithErrorType:GWP2PCallErrorNone isReCall:NO]; + }); + } + } +} +//连接到摄像头 +-(void)connectCamera{ + if (!_isconnecting) { + _isconnecting = YES;//正在连接中 NSString *newPassword = GIWEI_INITPASS; NSString *cameraPass = [Utils GetTreatedPassword:newPassword]; [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:self.kanHuCamera.cameraId password:cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { - // [self outputLog:dataDictionary success:success]; + _isconnecting = NO; //获取成功,打印设备信息,之后连接设备 if (success) { - NSLog(@"观看直播连接设备信息:%@",dataDictionary); + _isConnectCamera = YES; + [self monitorP2PCall]; + NSLog(@"当前连接设备信息:%@",dataDictionary); + }else{ + _isConnectCamera = NO; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.view makeToast:@"连接失败"]; + [self hiddenMonitoringUI:NO callWithErrorType:100 isReCall:NO]; + }); + return; } }]; - } - if(!_connectDevice){//p2p连接失败 - NSLog(@"p2pConnect failure.失败,不能操作设备"); - [self hiddenMonitoringUI:YES callWithErrorType:GWP2PCallErrorTimeout isReCall:NO]; - return; + }else{ + //设备连接中 } } #pragma mark --尝试连接摄像头 @@ -99,12 +124,14 @@ return; } //p2p未连接 - if (!_connectDevice) { + if ([GWP2PClient sharedClient].linkStatus != P2PLinkStatusOK) { [self connectDevice]; - if(_connectDevice){ - // 连接摄像头 - [self monitorP2PCall]; - } + return; + } + //未连接到设备 + if (!_isConnectCamera) { + [self connectCamera]; + return; } WEAK_SELF; NSString *newPassword = GIWEI_INITPASS; diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m index 87738ef..8a62f5d 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/IfishP2PMonitorController.m @@ -73,11 +73,13 @@ UIButton* _btnDefence; BOOL _isCanAutoOrientation;//限制屏幕什么时候可以旋转 - BOOL _connectDevice; //是否连接设备 + BOOL _connectDevice; //是否连接P2P + BOOL _isConnectCamera;//是否连接到设备 BOOL _isStop;//是否暂停 用于区分是 暂停按钮 还是 连接失败按钮 dispatch_queue_t _xutoMainQueue; BOOL _isPushNextView; //是否push下级界面 BOOL _isNewXuanduo; //是新绚多设备 + BOOL _isconnecting;//是否正在连接摄像头 } @property(nonatomic,strong) SetTimeController*SetTimeVC; @@ -236,6 +238,7 @@ Strong UIImage *screenShotImage;//截图 _isReject=YES; _isStop = NO; _isPushNextView = NO; + _isConnectCamera = NO; if ([self.contact.isActive isEqualToString:@"1"]) { [self connectDevice]; } @@ -276,26 +279,44 @@ Strong UIImage *screenShotImage;//截图 UserModel *model=[dataContorl getUserInfo]; NSString *userIDName=[NSString stringWithFormat:@"%d",(int)[model.gwellUserID integerValue]&0x7fffffff]; //初始化设备 - if (!_connectDevice) { + if ([GWP2PClient sharedClient].linkStatus != P2PLinkStatusOK) { 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) { - [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:self.contact.cameraId password:self.contact.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { - //获取成功,打印设备信息,之后连接设备 - if (success) { - NSLog(@"当前连接设备信息:%@",dataDictionary); - } - }]; + [self connectCamera]; + }else{ + NSLog(@"p2pConnect failure.失败,不能操作设备"); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.view makeToast:@"连接失败"]; + [self hiddenMonitoringUI:NO callWithErrorType:GWP2PCallErrorNone isReCall:NO]; + }); } } - if(!_connectDevice){//p2p连接失败 - NSLog(@"p2pConnect failure.失败,不能操作设备"); - [self hiddenMonitoringUI:YES callWithErrorType:100 isReCall:NO]; - return; + +} +//连接到摄像头 +-(void)connectCamera{ + if (!_isconnecting) { + _isconnecting = YES;//正在连接中 + [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:self.contact.cameraId password:self.contact.cameraPass completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { + _isconnecting = NO; + //获取成功,打印设备信息,之后连接设备 + if (success) { + _isConnectCamera = YES; + [self monitorP2PCall]; + NSLog(@"当前连接设备信息:%@",dataDictionary); + }else{ + _isConnectCamera = NO; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.view makeToast:@"连接设备失败"]; + [self hiddenMonitoringUI:NO callWithErrorType:100 isReCall:NO]; + }); + return; + } + }]; + }else{ + //设备连接中 } } #pragma mark --尝试连接摄像头 @@ -304,12 +325,14 @@ Strong UIImage *screenShotImage;//截图 return; } //p2p未连接 - if (!_connectDevice) { + if ([GWP2PClient sharedClient].linkStatus != P2PLinkStatusOK) { [self connectDevice]; - if(_connectDevice){ - // 连接摄像头 - [self monitorP2PCall]; - } + return; + } + //未连接到设备 + if (!_isConnectCamera) { + [self connectCamera]; + return; } WEAK_SELF; dispatch_async(dispatch_get_global_queue(0, 0), ^{ @@ -2750,7 +2773,6 @@ Strong UIImage *screenShotImage;//截图 -(void)hiddenMonitoringUI:(BOOL)isHidden callWithErrorType:(GWP2PCallError)errorType isReCall:(BOOL)isReCall{ if (isHidden) { [self.yProgressView stop]; -// self.yProgressView.angle = 0.0f; [self.yProgressView setHidden:YES]; [self.promptButton setEnabled:NO]; [self.promptButton setHidden:YES]; diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm index f4741cf..30b07ac 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/YooseeNextConnectViewController.mm @@ -387,8 +387,15 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { //智能联机 -(void)smartLinkConnect{ WEAK_SELF; - [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; - + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(90 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + // + if (!self.isDeviceLinkIn) {//90秒之后还未连接上,连接超时 + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + [self connectNormalView]; + [self.view makeToast:@"WiFi连接失败"]; + } + }); [[GWP2PDeviceLinker shareInstance] p2pSmartLinkDeviceWithWiFiSSID:weakSelf.wifiName password:weakSelf.wifiPwd useSimpleConfig:YES deviceLinkIn:^(NSDictionary *deviceDict) { NSLog(@"声波配网成功,返回数据:%@",deviceDict); if (weakSelf.isDeviceLinkIn) { @@ -399,30 +406,20 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { //如果智能联机,设备配网成功,就断开发送智能联机 [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; NSString *deviceID = [deviceDict[@"deviceID"] stringValue]; -// NSString *deviceIP = deviceDict[@"deviceIP"]; + NSString *deviceIP = deviceDict[@"deviceIP"]; // NSString *devicePassword = deviceDict[@"devicePassword"]; weakSelf.deviceID = deviceID; [self 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{ -// dispatch_async(dispatch_get_main_queue(), ^{ -// //只为做 dissPogress处理并非成功 -// weakSelf.lodviewMissStyle =lodingViewdissMissSuccsess; -// [weakSelf connectNormalView]; -// _canDissMissController = YES; -// [weakSelf.view makeToast:NSLocalizedString(@"operator_failure", nil)]; -// }); -// } -// }]; -// }else{ + if (![deviceDict[@"isInitPassword"] boolValue]){ //设备没有初始化密码,设置密码 + [[GWP2PClient sharedClient] setDeviceInitialPassword:self.lastSetPassword withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { + NSLog(@"success:%i %@",success,dataDictionary); + [weakSelf resetPassWord];//初始化密码 + [weakSelf bindCameraDevice]; + }]; + }else{//如果已经设置过初始密码,则直接使用 + [weakSelf bindCameraDevice]; + } +// else{ // [[GWP2PClient sharedClient] getMultipleDeviceStatusWithDeviceID:deviceIP password:@"123" completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { // NSLog(@"success:%i %@",success,dataDictionary); // [weakSelf resetPassWord];//更新密码 @@ -718,7 +715,6 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { } //绑定成功之后,重新获取用户信息 -(void)setWindowRootWith:(IfishCameraModel *)cameraMdel{ - [[GWP2PClient sharedClient] disconnect]; [self.view makeToast:@"添加成功"]; [self getMoreUserData:cameraMdel];