From 13ab8a3a3b112a887e843c1fe255c4eed7802220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9D=E5=8F=91=E5=86=AC?= Date: Mon, 21 Aug 2023 00:13:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=91=84=E5=83=8F=E5=A4=B4=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IfishYooseeHelper/Constants.h | 2 +- .../ConfigWifiViewController.m | 599 +++++++++++++++--- 2 files changed, 527 insertions(+), 74 deletions(-) diff --git a/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Constants.h b/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Constants.h index 83d92cf..4460650 100644 --- a/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Constants.h +++ b/Ifish/controllers/IfishYooseeFile/IfishYooseeHelper/Constants.h @@ -206,7 +206,7 @@ typedef NS_ENUM(NSUInteger, ConnectType) { ConnectTypeAirKiss = 1, /// 智能配网 - ConnectTypeSmartESPTouch , + ConnectTypeSmartConfig , /// 热点配网 ConnectTypeAP diff --git a/Ifish/controllers/leftcontrollers/ConfigWifiViewController.m b/Ifish/controllers/leftcontrollers/ConfigWifiViewController.m index 0ec20fa..dcfa2c9 100644 --- a/Ifish/controllers/leftcontrollers/ConfigWifiViewController.m +++ b/Ifish/controllers/leftcontrollers/ConfigWifiViewController.m @@ -43,13 +43,36 @@ #import "IfishDataUnity.h" #import "MyMD5.h" #import +#import "UIView+Toast.h" +#import "ContactDAO.h" +#import "AppDelegate.h" +#import "UDManager.h" +#import "LoginResult.h" +#import "Utils.h" +#import "RightViewController.h" +#import "LeftViewController.h" +#import "IfishCameraModel.h" +#import "FListManager.h" +#define GIWEI_INITPASS @"123" +#import "IfishP2PMonitorController.h" +#import "LXWaveProgressView.h" +#import "IfishConnectingView.h" +#import "PushMasssageWebViewController.h" +#import "IfishUserObsever.h" +#import +#import "MyMD5.h" +#import "IfishUserDataUnity.h" +#import "DeviceCameraModel.h" +#import "ConAquarChooseWiFiVC.h" +#import "InfoByImageViewController.h" + typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { lodingViewdissMissSuccsess=0,// default is 0 lodingViewdissMissfail, lodingViewdissMissAlreadyBinded }; -@interface ConfigWifiViewController () +@interface ConfigWifiViewController () @property (nonatomic, strong) NSCondition *_condition; @property (atomic, strong) ESPTouchTask *_esptouchTask; @property (nonatomic, strong) EspTouchDelegateImpl *_esptouchDelegate; @@ -65,8 +88,13 @@ typedef NS_ENUM(NSInteger,lodingViewdissMissStyle) { @property(nonatomic,strong) UILabel *maclabel; @property (nonatomic, assign) BOOL isGoChangeWiFi; -@property (nonatomic, strong) JMAirKissConnection *airKissConnection; ; - +@property (nonatomic, strong) JMAirKissConnection *airKissConnection; +//摄像头变量 +@property (strong, nonatomic) NSString *lastSetPassword; +@property (strong,nonatomic) NSMutableDictionary *addresses; +@property (strong,nonatomic) NSMutableDictionary *linkDict; +@property (copy, nonatomic) NSString *deviceID;//摄像头设备id +@property (assign, nonatomic) BOOL isDeviceLinkIn;//是否已经连接智能设备 Strong CLLocationManager *locationManager;//iOS13,获取WiFi名称必须开启定位权限 Strong NSMutableString *trackString; @@ -103,7 +131,22 @@ extern BOOL isfromCameraView; // Do any additional setup after loading the view from its nib. [self addTitleViewWithTitle:self.titleString]; self.view.backgroundColor=[UIColor whiteColor]; - self.connectType = ConnectTypeAirKiss; + if(self.deviceType == DEVICECAMERA) + { + self.connectType = ConnectTypeSmartConfig; + self.connectTypeTitle.text=@"智能配网"; + } + else + { + self.connectType = ConnectTypeAirKiss; + } + + //摄像头 + self.isDeviceLinkIn = NO; + [GWP2PDeviceLinker shareInstance].delegate=self; + self.deviceID=nil; + self.addresses = [[NSMutableDictionary alloc] initWithCapacity:1]; + self.linkDict = [[NSMutableDictionary alloc] initWithCapacity:1]; _deviceArry =[[NSMutableArray alloc]init]; @@ -194,7 +237,7 @@ extern BOOL isfromCameraView; SPAlertAction*smart =[SPAlertAction actionWithTitle:smartTitle style:SPAlertActionStyleDefault handler:^(SPAlertAction * _Nonnull action) { [weakSelf connectNormalView]; - weakSelf.connectType = ConnectTypeSmartESPTouch; + weakSelf.connectType = ConnectTypeSmartConfig; weakSelf.connectTypeTitle.text = smartTitle; weakSelf.connectTipLbl.text = smartTips; [weakSelf.connectBtn setTitle:@"确定" forState:UIControlStateNormal]; @@ -211,7 +254,11 @@ extern BOOL isfromCameraView; }]; - [alert addAction:airkiss]; + if(self.deviceType!=DEVICECAMERA) + { + [alert addAction:airkiss]; + } + [alert addAction:smart]; [alert addAction:ap]; [alert addAction:cancel]; @@ -462,17 +509,11 @@ extern BOOL isfromCameraView; } [self savePassw]; - if(self.connectType == ConnectTypeAP) - { - [self goSettingClick:nil]; - } - else - { - [self configWifiForDevice]; + [self configWifiForDevice]; - // [self initMMProgressHUD]; - [self connectNotNormalView]; - } + // [self initMMProgressHUD]; + [self connectNotNormalView]; + if (_maclabel) { @@ -648,78 +689,89 @@ extern BOOL isfromCameraView; [self.airKissConnection connectAirKissWithSSID:apSsid password:apPwd]; } - else if(type==ConnectTypeSmartESPTouch) + else if(type==ConnectTypeSmartConfig) { - dispatch_async(queue, ^{ - NSLog(@"ViewController do the execute work..."); - // execute the task - NSArray *esptouchResultArray = [self executeForResults]; - // show the result to the user in UI Main Thread - dispatch_async(dispatch_get_main_queue(), ^{ - // [self._spinner stopAnimating]; - // [self enableConfirmBtn]; - - ESPTouchResult *firstResult = [esptouchResultArray objectAtIndex:0]; - // check whether the task is cancelled and no results received - if (!firstResult.isCancelled) - { - NSMutableString *mutableStr = [[NSMutableString alloc]init]; - NSUInteger count = 0; - // max results to be displayed, if it is more than maxDisplayCount, - // just show the count of redundant ones - const int maxDisplayCount = 100000; - if ([firstResult isSuc]) + if(self.deviceType == DEVICECAMERA) + { + UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"提示" message:@"即将使用声波连接,请调大手机音量,并靠近设备,确认设备已经重置(按复位小孔,听到“等待连接“或者“滴”)后再点击确认" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil]; + alert.tag = ALERT_TAG_B_SURE; + + [alert show]; + } + else + { + dispatch_async(queue, ^{ + NSLog(@"ViewController do the execute work..."); + // execute the task + NSArray *esptouchResultArray = [self executeForResults]; + // show the result to the user in UI Main Thread + dispatch_async(dispatch_get_main_queue(), ^{ + // [self._spinner stopAnimating]; + // [self enableConfirmBtn]; + + ESPTouchResult *firstResult = [esptouchResultArray objectAtIndex:0]; + // check whether the task is cancelled and no results received + if (!firstResult.isCancelled) { - success(firstResult.bssid); - - for (int i = 0; i < [esptouchResultArray count]; ++i) + NSMutableString *mutableStr = [[NSMutableString alloc]init]; + NSUInteger count = 0; + // max results to be displayed, if it is more than maxDisplayCount, + // just show the count of redundant ones + const int maxDisplayCount = 100000; + if ([firstResult isSuc]) { - ESPTouchResult *resultInArray = [esptouchResultArray objectAtIndex:i]; - [mutableStr appendString:[resultInArray description]]; - [mutableStr appendString:@"\n"]; - count++; - if (count >= maxDisplayCount) + success(firstResult.bssid); + + for (int i = 0; i < [esptouchResultArray count]; ++i) { - break; + ESPTouchResult *resultInArray = [esptouchResultArray objectAtIndex:i]; + [mutableStr appendString:[resultInArray description]]; + [mutableStr appendString:@"\n"]; + count++; + if (count >= maxDisplayCount) + { + break; + } } + + if (count < [esptouchResultArray count]) + { + [mutableStr appendString:[NSString stringWithFormat:@"\nthere's %lu more result(s) without showing\n",(unsigned long)([esptouchResultArray count] - count)]]; + } + } - if (count < [esptouchResultArray count]) + else { - [mutableStr appendString:[NSString stringWithFormat:@"\nthere's %lu more result(s) without showing\n",(unsigned long)([esptouchResultArray count] - count)]]; + failure(nil,@"未获取到设备mac"); + + + } - } - - else + else if(firstResult.isCancelled) { - failure(nil,@"未获取到设备mac"); - + failure(nil,@"连接被取消"); } - } - else if(firstResult.isCancelled) - { - failure(nil,@"连接被取消"); - - - } - else if(!esptouchResultArray.count) - { - failure(nil,@"未有设备响应"); - [self.view makeToast:@"未有设备响应"]; + else if(!esptouchResultArray.count) + { + failure(nil,@"未有设备响应"); + [self.view makeToast:@"未有设备响应"]; + + } - } - - + + }); }); - }); + } + } else if (type == ConnectTypeAP) { - + [self goSettingClick:nil]; } @@ -745,7 +797,16 @@ extern BOOL isfromCameraView; } [self.timer invalidate]; self.timer = nil; - [self sendToDeviceWithSSIDName:self.ssid andSSIDPWD:self.wifiPass]; + if (self.connectType==ConnectTypeAP&&self.ssid.length&&self.wifiPass.length&&self.deviceType==DEVICECAMERA) + { + [self connectNotNormalView]; + [self apLinkConnect]; + } + else + { + [self sendToDeviceWithSSIDName:self.ssid andSSIDPWD:self.wifiPass]; + } + }]; @@ -919,6 +980,401 @@ extern BOOL isfromCameraView; [self.view addSubview:self.storeNameView]; } +#pragma mark 摄像头 +//密码 +-(void)resetPassWord{ + + NSString *newPassword = GIWEI_INITPASS; + self.lastSetPassword = [Utils GetTreatedPassword:newPassword]; +} + +#pragma mark - 搜索到设备,弹出添加设备提示 暂不用 +/** + 局域网里面有设备联网成功后,都会回调此方法。UDP使用 + + @param deviceDict 设备信息 + */ +- (void)p2pDeviceLinker:(GWP2PDeviceLinker *)linker deviceLinkSuccess:(NSDictionary *)deviceDict +{ + NSLog(@"扫描到设备"); + [self deviceLinkin:deviceDict linkType:self.connectType == ConnectTypeAP?conectType_ap:conectType_Intelligent ]; +} + + +-(void)deviceLinkin:(NSDictionary*)deviceDict linkType:(NSInteger)type +{ + NSLog(@"声波配网成功,返回数据:%@",deviceDict); + NSString *deviceID = [deviceDict[@"deviceID"] stringValue]; + NSString *deviceIP = deviceDict[@"deviceIP"]; + if ([self.linkDict[deviceID] boolValue]) { + return; + } + + //AP配网时有值 smart没有值 + if ([self.deviceID isEqualToString:deviceID]||self.deviceID==nil) + { + + if (type==conectType_Intelligent) + { + [self.view makeToast:@"声波配网成功"]; + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + } + else + { + [self.view makeToast:@"AP配网成功"]; + [[GWP2PDeviceLinker shareInstance] p2pStopAPLink]; + + } + + + // NSString *devicePassword = deviceDict[@"devicePassword"]; + self.deviceID = deviceID; + self.linkDict[deviceID]=@(YES); + [self resetPassWord];//初始化密码 + if (![deviceDict[@"isInitPassword"] boolValue]){ //设备没有初始化密码,设置密码 + [[GWP2PClient sharedClient] setDeviceInitialPassword:self.lastSetPassword withDeviceID:deviceIP completionBlock:^(GWP2PClient *client, BOOL success, NSDictionary *dataDictionary) { + NSLog(@"success:%i %@",success,dataDictionary); + [self resetPassWord];//初始化密码 + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self bindCameraDevice]; + + }); + }]; + }else{//如果已经设置过初始密码,则直接使用 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self bindCameraDevice]; + + }); + } + + } + +} +-(void)deviceLinkinTimeout:(NSInteger)type +{ + // + if (self.deviceID.length&&![self.linkDict[self.deviceID] boolValue]) {//90秒之后还未连接上,连接超时 + [CommonUtils getNetworkTypeComplete:^(NSString *netconnType, NSString *BSSID, NSString *SSID) { + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + [[GWP2PDeviceLinker shareInstance] p2pStopAPLink]; + + if ([SSID isEqualToString:self.ssid]) + { + [self.view makeToast:@"请确保Wifi密码正确,重置设备后再试!"]; + } + else + { + [self.view makeToast:[NSString stringWithFormat:@"WiFi连接失败,请确保手机连接到%@",self.ssid]]; + } + [self showFailResultViewWithMsg:@"连接超时"]; + }]; + + } + else if(!self.deviceID.length) + { + [self.view makeToast:@"获取设备ID失败"]; + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + [[GWP2PDeviceLinker shareInstance] p2pStopAPLink]; + [self connectNormalView]; + } +} +-(void)apLinkConnect +{ + WEAK_SELF; + [[GWP2PDeviceLinker shareInstance] p2pStopAPLink]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(90 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + + [self deviceLinkinTimeout:self.connectType == ConnectTypeAP?conectType_ap:conectType_Intelligent]; + }); + + [self resetPassWord];//初始化密码 + [[GWP2PDeviceLinker shareInstance] p2pAPLinkDeviceWithWiFiSSID:weakSelf.ssid wifiPassword:weakSelf.wifiPass devicePassword:weakSelf.lastSetPassword deviceReceive:^(NSString *deviceId, BOOL isSupport) { + + + + if (isSupport) + { + + weakSelf.deviceID=deviceId; + [weakSelf.view makeToast:[NSString stringWithFormat:@"设备即将连接网络,请将手机自动重新连接到%@",weakSelf.ssid]]; + + + } + else + { + [weakSelf.view makeToast:@"该设备不支持AP配网"]; + } + + + } deviceLinkIn:^(NSDictionary *deviceDict) { + + [weakSelf deviceLinkin:deviceDict linkType:weakSelf.connectType == ConnectTypeAP?conectType_ap:conectType_Intelligent]; + }]; + + +} +//智能联机 +-(void)smartLinkConnect{ + + + //拿到AVAudioSession的单例对象 + AVAudioSession *audioSession = [AVAudioSession sharedInstance]; + + //设置为听筒模式 + //[audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:nil]; + + //设置为公放模式 + [audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil]; + + //让我的App占用听筒或扬声器 + [audioSession setActive:YES error:nil]; + WEAK_SELF; + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(100 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + [self deviceLinkinTimeout:self.connectType == ConnectTypeAP?conectType_ap:conectType_Intelligent]; + }); + [[GWP2PDeviceLinker shareInstance] p2pSmartLinkDeviceWithWiFiSSID:weakSelf.ssid password:weakSelf.wifiPass useSimpleConfig:YES deviceLinkIn:^(NSDictionary *deviceDict) { + [weakSelf deviceLinkin:deviceDict linkType:weakSelf.connectType == ConnectTypeAP?conectType_ap:conectType_Intelligent]; + }]; +} +-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ + + + if (alertView.tag==ALERT_TAG_B_SURE){ + + if (buttonIndex ==1) { + + + + + //显示连接中效果 + [self connectNotNormalView]; + + //声波智能联机 + if (self.connectType==ConnectTypeSmartConfig) + { + [self smartLinkConnect]; + } + else + { + [self apLinkConnect]; + } + + } + }//重试wifi + } +//初始化设备密码回调 +-(void)bindCameraDevice{ + + + NSString * contactName = [NSString stringWithFormat:@"Cam%@", self.deviceID]; + + ContactDAO *contactDAO = [[ContactDAO alloc] init]; + Contact *contact = [contactDAO isContact:self.deviceID]; + + if(contact!=nil){ + + contact.contactName = contactName; + + contact.contactPassword = self.lastSetPassword;//updatepwd + + [[FListManager sharedFList] updatee:contact]; + + [self ifishUserBindcameraIdBy:self.deviceID]; + + }else{ + Contact *contact = [[Contact alloc] init]; + contact.contactId = self.deviceID; + contact.contactName = contactName; + + contact.contactPassword = self.lastSetPassword; + contact.contactType = CONTACT_TYPE_UNKNOWN; + [[FListManager sharedFList] insert:contact]; + //设置密码成功后爱鱼奇用户绑定摄像头 + + [self ifishUserBindcameraIdBy:self.deviceID]; + } + +} + +-(void)dealloc{ + [[GWP2PDeviceLinker shareInstance] p2pStopSmartLink]; + [[GWP2PDeviceLinker shareInstance] p2pStopAPLink]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:Noti_WillEnterForeground object:nil]; + +} +#pragma mark - 绑定摄像头 +//让爱鱼奇用户 与摄像头建立关系 + +-(void)ifishUserBindcameraIdBy:(NSString *)cameraId +{ + NSLog(@"cameraId = %@",cameraId); + NSMutableArray *oldCameraArr= [[DataCenter defaultDtacenter]valueForKey:@"cameraArr"]; + if (!oldCameraArr) { + //无设备 + oldCameraArr = [[NSMutableArray alloc] init]; + } + + IfishCameraModel *camer=[[IfishCameraModel alloc] init]; + NSMutableArray *idArr=[[NSMutableArray alloc] init]; + for (IfishCameraModel *model in oldCameraArr ) { + + [idArr addObject:model.cameraId]; + + if (model.cameraId == cameraId) { + + camer = model; + [self connectNormalView]; + [self.view makeToast:@"已经绑定过了"]; + return; + } + } + UserModel*model=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"]; + [AFNOHeaderHttpTool bindCameraWith:cameraId userId:model.userId success:^(id response) { + NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; + NSLog(@"%@",resultDic[@"result"]); + + if ([resultDic[@"result"] isEqualToString:@"100"]) { + self.lodviewMissStyle =lodingViewdissMissSuccsess; + + //绑定成功之后,直接跳转详情页面 + /** + 存储摄像头设备信息 + */ + NSMutableArray *newCamerArr = [[NSMutableArray alloc] initWithArray:oldCameraArr]; + NSDictionary * cameraDic=resultDic[@"data"]; + + NSString *newPassword = GIWEI_INITPASS; + NSString *cameraPass = [Utils GetTreatedPassword:newPassword]; + IfishCameraModel *camera=[[IfishCameraModel alloc] init]; + + camera.cameraId = cameraDic[@"cameraId"]; + camera.isMaster = cameraDic[@"isMaster"]; + camera.showName = cameraDic[@"showName"]; + camera.cameraPass = cameraPass; + camera.isActive = cameraDic[@"isActive"]; + camera.isLook = cameraDic[@"isLook"]; + camera.isLive = cameraDic[@"isLive"]; + [newCamerArr insertObject:camera atIndex:0]; + //存储摄像头数组 + [[DataCenter defaultDtacenter]setValue: newCamerArr forKey:@"cameraArr"]; + + NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults]; + NSInteger index=0; + + [userdefult setObject:nil forKey:@"lastIndex"]; + + [userdefult setInteger:index forKey:@"cameralastIndex"]; + [userdefult synchronize]; + + [self setWindowRootWith:camera]; + + }else{ + //lodingViewdissMissSuccsess 只做移除loding效果 + self.lodviewMissStyle =lodingViewdissMissSuccsess; + [self showFailResultViewWithMsg:@"绑定失败错误码101"]; + + [self.view makeToast:@"绑定失败错误码101"]; + + } + + } failure:^(NSError *err) { + + [self showFailResultViewWithMsg:err.description]; + [self.view makeToast:@"绑定失败未知错误"]; + + }]; + +} +//绑定成功之后,重新获取用户信息 +-(void)setWindowRootWith:(IfishCameraModel *)cameraMdel{ + [self.view makeToast:@"添加成功"]; + [self getMoreUserData:cameraMdel]; + +} +//获取个人信息 +-(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"]; + //添加设备之后,先断开device连接,之后进入摄像头页面再重新添加链接 + [[GWP2PClient sharedClient] disconnect]; + 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) { + }]; +} + #pragma mark 绑定设备 -(void)bindDeviceWithSsid:(NSString*)bssid{ NSLog(@"设备bssid_%@",bssid); @@ -1171,9 +1627,6 @@ extern BOOL isfromCameraView; self.navigationController.navigationBarHidden=NO; } -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self name:Noti_WillEnterForeground object:nil]; -} + @end