build 511
This commit is contained in:
parent
3b633f7355
commit
e3c7e47779
|
|
@ -70,7 +70,7 @@
|
|||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>510</string>
|
||||
<string>511</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
|
|
|
|||
|
|
@ -18,11 +18,6 @@
|
|||
|
||||
@property (nonatomic, strong) DeviceModel *currentDevice;
|
||||
@property (nonatomic, strong) MBProgressHUD *HUD;
|
||||
@property (nonatomic, assign) BOOL isDeleteingDevice;
|
||||
|
||||
@property (nonatomic, strong) NSTimer *deleteTimer;
|
||||
|
||||
@property (nonatomic, assign) NSInteger retryTimes;
|
||||
|
||||
@end
|
||||
|
||||
|
|
@ -39,34 +34,13 @@
|
|||
[self.view makeToast:@"请先将手机连接到wifi:ifish-xxxx"];
|
||||
return;
|
||||
}
|
||||
self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
||||
self.HUD.mode = MBProgressHUDModeIndeterminate;
|
||||
self.HUD.labelText = @"重置指令已发出";
|
||||
[IFishHotpotUDPHelper sharedInstance].delegate = self;
|
||||
[[IFishHotpotUDPHelper sharedInstance] broadCastRestCommand];
|
||||
}
|
||||
|
||||
- (void)deleteNow {
|
||||
BOOL networkOk = NO;
|
||||
AFNetworkReachabilityStatus status = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus;
|
||||
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
|
||||
if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
|
||||
networkOk = YES;
|
||||
}
|
||||
} else if (status == AFNetworkReachabilityStatusReachableViaWWAN) {
|
||||
networkOk = YES;
|
||||
}
|
||||
if (!networkOk) {
|
||||
return;
|
||||
}
|
||||
if (self.isDeleteingDevice) {
|
||||
return;
|
||||
}
|
||||
if (self.deleteTimer) {
|
||||
[self.deleteTimer invalidate];
|
||||
self.deleteTimer = nil;
|
||||
}
|
||||
self.isDeleteingDevice = YES;
|
||||
[self deletDevice];
|
||||
}
|
||||
|
||||
- (IBAction)tipBtnClicked:(id)sender {
|
||||
ConnectHotspotTipViewController *vc = [[ConnectHotspotTipViewController alloc] initWithNibName:nil bundle:nil];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
|
|
@ -75,17 +49,11 @@
|
|||
#pragma mark - IFishHotpotUDPHelperDelegate
|
||||
|
||||
- (void)udpHelperCommandExecutedSuccess:(IFishUDPHelperBackMsgModel *)backModel {
|
||||
[self.view makeToast:@"设备已重置"];
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
// self.HUD.labelText = @"设备正在恢复出厂设置";
|
||||
// NSArray*deviceArry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"];
|
||||
// [deviceArry enumerateObjectsUsingBlock:^(DeviceModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
// if ([obj.macAddress isEqualToString:backModel.senderMacAddress]) {
|
||||
// self.currentDevice = obj;
|
||||
// self.deleteTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(deleteNow) userInfo:nil repeats:YES];
|
||||
// *stop = YES;
|
||||
// }
|
||||
// }];
|
||||
self.HUD.mode = MBProgressHUDModeText;
|
||||
self.HUD.labelText = @"设备已重置";
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[MBProgressHUD hideHUDForView:self.view animated:YES];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)udpHelperMessage:(NSString *)msg {
|
||||
|
|
@ -107,71 +75,4 @@
|
|||
return ssid;
|
||||
}
|
||||
|
||||
-(void)deletDevice{
|
||||
self.HUD.labelText = @"正在删除设备";
|
||||
//先判断此设备是否有关联 摄像头
|
||||
//DeviceModel*deviceModel=[_deviceArr objectAtIndex:indexpath.row];
|
||||
//要删除的设设备id
|
||||
NSMutableArray *guanxiiArr= [[DataCenter defaultDtacenter] valueForKey:@"devicamerArr"];
|
||||
for (DeviceCameraModel *model in guanxiiArr) {
|
||||
if (self.currentDevice.deviceId == model.deviceId ) {
|
||||
[guanxiiArr removeObject:model];
|
||||
//保存新关系数组
|
||||
[[DataCenter defaultDtacenter] setValue:guanxiiArr forKey:@"devicamerArr"];
|
||||
}
|
||||
}
|
||||
self.retryTimes = 0;
|
||||
[self deleteDeviceRequset];
|
||||
}
|
||||
|
||||
-(void)deleteDeviceRequset{
|
||||
AFHTTPRequestOperationManager*mannager=[AFHTTPRequestOperationManager manager];
|
||||
mannager.responseSerializer=[AFHTTPResponseSerializer serializer];
|
||||
NSMutableDictionary * para = [NSMutableDictionary dictionary];
|
||||
NSString *priId=self.currentDevice.deviceId;
|
||||
NSString*userId=self.currentDevice.userId;
|
||||
[para setValue:priId forKey:@"priId.deviceId"];
|
||||
[para setValue:userId forKey:@"priId.userId"];
|
||||
// __weak typeof (self)weakSelf=self;
|
||||
[mannager POST:kDeleteDeviceUser parameters:para success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||
if (responseObject) {
|
||||
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
|
||||
NSLog(@"result:%@",resultDic[@"result"]);
|
||||
if ([resultDic[@"result"] isEqualToString:@"100"]) {
|
||||
self.HUD.labelText = @"设备删除成功";
|
||||
//重置数据库
|
||||
NSArray*deviceArry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"];
|
||||
NSMutableArray *newArr = [NSMutableArray arrayWithArray:deviceArry];
|
||||
|
||||
for (DeviceModel *model in deviceArry) {
|
||||
if ([model.deviceId isEqual:self.currentDevice.deviceId]) {
|
||||
[newArr removeObject:model];
|
||||
}
|
||||
}
|
||||
[[DataCenter defaultDtacenter] setValue: newArr forKey:@"deviceInfo"];
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}else if ([resultDic[@"result"] isEqualToString:@"101"]){
|
||||
self.HUD.labelText = @"设备删除失败";
|
||||
}else if ([resultDic[@"result"] isEqualToString:@"301"]){
|
||||
self.HUD.labelText = @"请求验证失败,请重新登陆";
|
||||
}else if ([resultDic[@"result"] isEqualToString:@"302"]){
|
||||
self.HUD.labelText = @"请求被舍弃,未执行";
|
||||
}
|
||||
[self.HUD hide:YES afterDelay:2];
|
||||
} else {
|
||||
self.HUD.labelText = @"删除失败";
|
||||
[self.HUD hide:YES afterDelay:2];
|
||||
}
|
||||
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
if (self.retryTimes < 3) {
|
||||
[self deleteDeviceRequset];
|
||||
self.retryTimes += 1;
|
||||
} else {
|
||||
self.HUD.labelText = @"请求异常";
|
||||
[self.HUD hide:YES afterDelay:2];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Reference in New Issue