79 lines
2.3 KiB
Objective-C
79 lines
2.3 KiB
Objective-C
//
|
|
// SettingResetViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by Minghao Xue on 2018/7/24.
|
|
// Copyright © 2018年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "SettingResetViewController.h"
|
|
#import "IFishHotpotUDPHelper.h"
|
|
#import "ConnectHotspotTipViewController.h"
|
|
#import "DeviceCameraModel.h"
|
|
#import "DeviceModel.h"
|
|
#import "MBProgressHUD.h"
|
|
#import<SystemConfiguration/CaptiveNetwork.h>
|
|
|
|
@interface SettingResetViewController ()<IFishHotpotUDPHelperDelegate>
|
|
|
|
@property (nonatomic, strong) DeviceModel *currentDevice;
|
|
@property (nonatomic, strong) MBProgressHUD *HUD;
|
|
|
|
@end
|
|
|
|
@implementation SettingResetViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
self.title = @"恢复出厂设置";
|
|
|
|
}
|
|
|
|
- (IBAction)reset:(id)sender {
|
|
if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
|
|
[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];
|
|
}
|
|
|
|
- (IBAction)tipBtnClicked:(id)sender {
|
|
ConnectHotspotTipViewController *vc = [[ConnectHotspotTipViewController alloc] initWithNibName:nil bundle:nil];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
|
|
#pragma mark - IFishHotpotUDPHelperDelegate
|
|
|
|
- (void)udpHelperCommandExecutedSuccess:(IFishUDPHelperBackMsgModel *)backModel {
|
|
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 {
|
|
// [self.view makeToast:msg];
|
|
}
|
|
|
|
#pragma mark - 删除设备
|
|
|
|
- (NSString *)currentWifiSSID {
|
|
NSString *ssid = @"Not Found";
|
|
CFArrayRef myArray = CNCopySupportedInterfaces();
|
|
if (myArray != nil) {
|
|
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
|
|
if (myDict != nil) {
|
|
NSDictionary *dict = (NSDictionary *)CFBridgingRelease(myDict);
|
|
ssid = [dict valueForKey:@"SSID"];
|
|
}
|
|
}
|
|
return ssid;
|
|
}
|
|
|
|
@end
|