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;