优化设置连接和重置设备过程

This commit is contained in:
xuemh
2018-08-26 17:19:07 +08:00
parent 8c5623acdc
commit d59ca3bb80
2 changed files with 86 additions and 36 deletions
@@ -14,6 +14,7 @@
#import "ESPTouchResult.h"
#import "ESPTouchTask.h"
#import "IfishDataUnity.h"
#import "MBProgressHUD.h"
@interface ConnectHotpotViewController ()<UITextFieldDelegate, IFishHotpotUDPHelperDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@@ -26,6 +27,8 @@
@property (nonatomic, strong) NSMutableString *trackString;
@property (nonatomic, strong) MBProgressHUD *HUD;
/**
设备返回的mac地址
*/
@@ -155,11 +158,13 @@
- (void)udpHelperCommandExecutedSuccess:(IFishUDPHelperBackMsgModel *)backModel {
self.ssid = backModel.senderMacAddress;
[self.view makeToast:[NSString stringWithFormat:@"连接设置成功,切换当前热点连接到其他网络"]];
self.HUD.labelText = @"请切当前Ifish-xxxx到其他网络,以进行后续操作";
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;
@@ -188,7 +193,9 @@
}
- (void)udpHelperMessage:(NSString *)msg {
[self.view makeToast:msg];
self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
self.HUD.mode = MBProgressHUDModeIndeterminate;
self.HUD.labelText = msg;
}
#pragma mark - bind
@@ -196,7 +203,7 @@
NSLog(@"设备bssid_%@",bssid);
[self appendTrakContent:@"=================进入绑定函数================="];
NSString *userId = [dataContorl dataControlGetUserIdInfo];
[self.view makeToast:[NSString stringWithFormat:@"正在绑定设备,bssid:%@", bssid]];
self.HUD.labelText = @"开始绑定设备";
[self appendTrakContent:[NSString stringWithFormat:@"绑定参数 userID:%@", userId]];
[self appendTrakContent:[NSString stringWithFormat:@"绑定参数 macaddress:%@", bssid]];
[AFHttpTool bindDeviceWithUserId:userId macAddress:bssid success:^(id response) {
@@ -213,8 +220,7 @@
[self appendTrakContent:[NSString stringWithFormat:@"绑定返回状态码正确。设备信息为:%@", dataDic]];
if (!devicemodel.type){
[self.view makeToast:@"用户绑定设备成功,但设备初次入网失败请重新登陆"];
self.HUD.labelText = @"用户绑定设备成功,但设备初次入网失败请重新登陆";
}else{
NSMutableArray * _deviceArry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"];
@@ -226,10 +232,10 @@
if ([devicemodel.type isEqual:[NSNull null]]){
//进入此循环 可能因为设备所在服务器 不在 本程序所在 服务器
[self showTitle:@"" messsage:@"设备不在服务器"];
self.HUD.labelText = @"设备不在服务器";
}else{
[self.view makeToast:@"设备绑定成功"];
self.HUD.labelText = @"设备绑定成功";
[[IfishDataUnity shareDataInstance] initAppCenterVcWith:devicemodel addWithdissMisVc:nil];
//绑定成功 加 经验值
@@ -239,27 +245,28 @@
}else if ([resultDic[@"result"] isEqualToString:@"101"]){
[self appendTrakContent:@"绑定返回状态码错误。设备信息为:%@"];
[self.view makeToast:@"绑定失败"];
self.HUD.labelText = @"绑定失败";
self.bakbutton.userInteractionEnabled=YES;
}else if ([resultDic[@"result"] isEqualToString:@"301"]){
[self appendTrakContent:@"绑定返回状态码错误。设备信息为:%@"];
[self.view makeToast:@"请求验证失败,请重新登录"];
self.HUD.labelText = @"请求验证失败,请重新登录";
self.bakbutton.userInteractionEnabled=YES;
}else if ([resultDic[@"result"] isEqualToString:@"302"]){
// 请求被舍弃未执行
[self appendTrakContent:@"绑定返回状态码错误。设备信息为:%@"];
self.bakbutton.userInteractionEnabled=YES;
[self.view makeToast:@"绑定失败"];
self.HUD.labelText = @"绑定失败";
[self.HUD hide:YES afterDelay:2];
}
} failure:^(NSError *err) {
self.isBindingDevice = NO;
[self.view makeToast:@"网络异常"];
self.HUD.labelText = @"网络异常";
[self.HUD hide:YES afterDelay:2];
[self appendTrakContent:[NSString stringWithFormat:@"绑定网络请求错误:%@", err.localizedDescription]];
self.bakbutton.userInteractionEnabled=YES;