| | |
| | | - (void)viewDidLoad |
| | | { |
| | | [super viewDidLoad]; |
| | | |
| | | |
| | | self.title = NSLocalizedString(@"wifi_ap_add_device_title", @"添加设备"); |
| | | |
| | | [self initSubviews]; |
| | |
| | | [self stopTimer]; |
| | | |
| | | self.addCount = 0; |
| | | |
| | | |
| | | self.timer = [NSTimer scheduledTimerWithTimeInterval:5.0 |
| | | target:self |
| | | selector:@selector(timerCallback) |
| | |
| | | [EZOPENSDK probeDeviceInfo:[GlobalKit shareKit].deviceSerialNo |
| | | deviceType:[GlobalKit shareKit].deviceModel |
| | | completion:^(EZProbeDeviceInfo *deviceInfo, NSError *error) { |
| | | if (error) |
| | | { |
| | | [self probeErrorProcessWithError:error]; |
| | | } |
| | | else |
| | | { |
| | | [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo |
| | | verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | completion:^(NSError *error) { |
| | | if (error) |
| | | { |
| | | [self addErrorProcessWithError:error]; |
| | | } |
| | | else |
| | | { |
| | | [self successProcess]; |
| | | } |
| | | }]; |
| | | } |
| | | }]; |
| | | if (error) |
| | | { |
| | | [self probeErrorProcessWithError:error]; |
| | | } |
| | | else |
| | | { |
| | | // [EZOpenSDK addDevice:[GlobalKit shareKit].deviceSerialNo |
| | | // verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | // completion:^(NSError *error) { |
| | | // if (error) |
| | | // { |
| | | // [self addErrorProcessWithError:error]; |
| | | // } |
| | | // else |
| | | // { |
| | | // [self successProcess]; |
| | | // } |
| | | // }]; |
| | | [EZHttpUtil.sharedManager addDeviceByHDL:[GlobalKit shareKit].deviceSerialNo |
| | | verifyCode:[GlobalKit shareKit].deviceVerifyCode |
| | | completion:^(ResponseData *responseData) { |
| | | |
| | | if (!responseData.success) |
| | | { |
| | | [self addErrorProcessWithError:responseData]; |
| | | } |
| | | else |
| | | { |
| | | [self successProcess]; |
| | | } |
| | | |
| | | }]; |
| | | |
| | | } |
| | | }]; |
| | | } |
| | | |
| | | - (void) probeErrorProcessWithError:(NSError *) error |
| | |
| | | [self.view makeToast:msg duration:2.0 position:@"center"]; |
| | | } |
| | | |
| | | - (void) addErrorProcessWithError:(NSError *) error |
| | | //- (void) addErrorProcessWithError:(NSError *) error |
| | | //{ |
| | | // NSString *msg = nil; |
| | | // if (error.code == 120010) |
| | | // { |
| | | // msg = NSLocalizedString(@"device_verify_code_wrong", @"验证码错误"); |
| | | // } |
| | | // else if (error.code == 120020) |
| | | // { |
| | | // msg = NSLocalizedString(@"ad_already_added", @"您已添加过此设备"); |
| | | // } |
| | | // else if (error.code == 120022) |
| | | // { |
| | | // msg = NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加"); |
| | | // } |
| | | // else |
| | | // { |
| | | // msg = NSLocalizedString(@"wifi_add_fail", @"添加失败"); |
| | | // } |
| | | // |
| | | // [self.view makeToast:msg duration:2.0 position:@"center"]; |
| | | // self.msgLabel.hidden = YES; |
| | | //} |
| | | |
| | | - (void) addErrorProcessWithError:(ResponseData *)responseData |
| | | { |
| | | NSString *msg = nil; |
| | | if (error.code == 120010) |
| | | if ([responseData.code isEqual: @"20010"]) |
| | | { |
| | | msg = NSLocalizedString(@"device_verify_code_wrong", @"验证码错误"); |
| | | } |
| | | else if (error.code == 120020) |
| | | else if ([responseData.code isEqual: @"20017"]) |
| | | { |
| | | msg = NSLocalizedString(@"ad_already_added", @"您已添加过此设备"); |
| | | } |
| | | else if (error.code == 120022) |
| | | else if ([responseData.code isEqual: @"20013"]) |
| | | { |
| | | msg = NSLocalizedString(@"ad_added_by_others", @"此设备已被别人添加"); |
| | | } |