From 9b0019c72d9d6c7c8445203b3edd79816effdda1 Mon Sep 17 00:00:00 2001 From: xuemh Date: Thu, 23 Aug 2018 20:40:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=88=B0=E8=AE=BE=E5=A4=87ma?= =?UTF-8?q?c=E5=9C=B0=E5=9D=80=E5=90=8E=EF=BC=8C=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E8=BF=9E=E6=8E=A5=E5=8F=98=E5=8C=96=E6=97=B6?= =?UTF-8?q?=E5=86=8D=E5=8F=91=E9=80=81=E8=AE=BE=E5=A4=87=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SettingResetViewController.m | 13 ------ .../ConnectHotpotViewController.m | 40 ++++++++++++++++++- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/Ifish/controllers/IfishTabControllers/我的/mineControllers/SettingResetViewController.m b/Ifish/controllers/IfishTabControllers/我的/mineControllers/SettingResetViewController.m index c237bb4..2d1530e 100644 --- a/Ifish/controllers/IfishTabControllers/我的/mineControllers/SettingResetViewController.m +++ b/Ifish/controllers/IfishTabControllers/我的/mineControllers/SettingResetViewController.m @@ -99,19 +99,6 @@ } } [[DataCenter defaultDtacenter] setValue: newArr forKey:@"deviceInfo"]; - - if ([newArr count]==0) { - - NSArray *cameraArr= [[DataCenter defaultDtacenter] valueForKey:@"cameraArr"]; - if ([cameraArr count]!=0) { - [[Socketsingleton sharedInstance] cutOffSocket]; - }else{ - //两种设备都 - [[Socketsingleton sharedInstance] cutOffSocket]; - - } - - } }else if ([resultDic[@"result"] isEqualToString:@"101"]){ [self showTitle:@"" messsage:@"删除失败"]; diff --git a/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m b/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m index 575f98c..d63b6c9 100644 --- a/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m +++ b/Ifish/controllers/leftcontrollers/ConnectHotpotViewController.m @@ -26,6 +26,16 @@ @property (nonatomic, strong) NSMutableString *trackString; +/** + 设备返回的mac地址 + */ +@property (nonatomic, copy) NSString *macAddress; + +/** + 是否正在绑定设备 + */ +@property (nonatomic, assign) BOOL isBindingDevice; + @end @implementation ConnectHotpotViewController @@ -145,13 +155,36 @@ - (void)udpHelperCommandExecutedSuccess:(IFishUDPHelperBackMsgModel *)backModel { self.ssid = backModel.senderMacAddress; - [self.view makeToast:[NSString stringWithFormat:@"连接设置成功,mac 地址:%@",backModel.senderMacAddress]]; + [self.view makeToast:[NSString stringWithFormat:@"连接设置成功,切换当前热点连接到其他网络"]]; self.trackString = [NSMutableString string]; [self appendTrakContent:@"=================收到设备答复==================="]; [self appendTrakContent:[NSString stringWithFormat:@"答复状态码:%@", backModel.result]]; [self appendTrakContent:[NSString stringWithFormat:@"答复Mac地址:%@", backModel.senderMacAddress]]; [[IFishHotpotUDPHelper sharedInstance] broadCastRestartCommand]; - [self bindDeviceWithSsid:backModel.senderMacAddress]; + self.macAddress = backModel.senderMacAddress; + + [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + BOOL networkOk = NO; + if (status == AFNetworkReachabilityStatusReachableViaWiFi) { + if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) { + networkOk = YES; + } + } else if (status == AFNetworkReachabilityStatusReachableViaWWAN) { + networkOk = YES; + } + if (!networkOk) { + return; + } + if (self.isBindingDevice) { + return; + } + if (self.macAddress.length == 0) { + return; + } + self.isBindingDevice = YES; + [self bindDeviceWithSsid:self.macAddress]; + }]; + [[AFNetworkReachabilityManager sharedManager] startMonitoring]; } - (void)udpHelperMessage:(NSString *)msg { @@ -167,6 +200,8 @@ [self appendTrakContent:[NSString stringWithFormat:@"绑定参数 userID:%@", userId]]; [self appendTrakContent:[NSString stringWithFormat:@"绑定参数 macaddress:%@", bssid]]; [AFHttpTool bindDeviceWithUserId:userId macAddress:bssid success:^(id response) { + self.isBindingDevice = NO; + self.macAddress = nil; NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; NSLog(@"data:%@",resultDic[@"data"]); [self appendTrakContent:[NSString stringWithFormat:@"绑定请求成功。返回数据为:%@", resultDic]]; @@ -223,6 +258,7 @@ } failure:^(NSError *err) { + self.isBindingDevice = NO; [self.view makeToast:@"网络异常"]; [self appendTrakContent:[NSString stringWithFormat:@"绑定网络请求错误:%@", err.localizedDescription]]; self.bakbutton.userInteractionEnabled=YES;