优化连接过程

This commit is contained in:
xuemh
2018-08-26 23:39:52 +08:00
parent ff26073344
commit d0e290bea6
3 changed files with 67 additions and 101 deletions
@@ -158,20 +158,20 @@
- (void)udpHelperCommandExecutedSuccess:(IFishUDPHelperBackMsgModel *)backModel {
self.ssid = backModel.senderMacAddress;
self.HUD.labelText = @"切当前Ifish-xxxx到其他网络,以进行后续操作";
[self.view resignFirstResponder];
self.HUD.labelText = @"稍后";
self.trackString = [NSMutableString string];
[self appendTrakContent:@"=================收到设备答复==================="];
[self appendTrakContent:[NSString stringWithFormat:@"答复状态码:%@", backModel.result]];
[self appendTrakContent:[NSString stringWithFormat:@"答复Mac地址:%@", backModel.senderMacAddress]];
[IFishHotpotUDPHelper sharedInstance].delegate = nil;
[[IFishHotpotUDPHelper sharedInstance] broadCastRestartCommand];
self.macAddress = backModel.senderMacAddress;
__weak typeof(self) weakSelf = self;
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
__strong typeof(weakSelf) strongSelf = weakSelf;
BOOL networkOk = NO;
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
if (![[strongSelf currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
networkOk = YES;
}
} else if (status == AFNetworkReachabilityStatusReachableViaWWAN) {
@@ -180,16 +180,19 @@
if (!networkOk) {
return;
}
if (self.isBindingDevice) {
if (strongSelf.isBindingDevice) {
return;
}
if (self.macAddress.length == 0) {
if (strongSelf.macAddress.length == 0) {
return;
}
self.isBindingDevice = YES;
[self bindDeviceWithSsid:self.macAddress];
strongSelf.isBindingDevice = YES;
[strongSelf bindDeviceWithSsid:self.macAddress];
}];
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[IFishHotpotUDPHelper sharedInstance].delegate = nil;
[[IFishHotpotUDPHelper sharedInstance] broadCastRestartCommand];
}
- (void)udpHelperMessage:(NSString *)msg {
@@ -203,7 +206,7 @@
NSLog(@"设备bssid_%@",bssid);
[self appendTrakContent:@"=================进入绑定函数================="];
NSString *userId = [dataContorl dataControlGetUserIdInfo];
self.HUD.labelText = @"开始绑定设备";
self.HUD.labelText = @"正在绑定设备";
[self appendTrakContent:[NSString stringWithFormat:@"绑定参数 userID:%@", userId]];
[self appendTrakContent:[NSString stringWithFormat:@"绑定参数 macaddress:%@", bssid]];
[AFHttpTool bindDeviceWithUserId:userId macAddress:bssid success:^(id response) {