|
|
@@ -78,7 +78,7 @@
|
|
|
[self requestIncludeDevice:YES];
|
|
|
} else if (_removableDevice) {
|
|
|
_lblDesc.text = [NSString stringWithFormat:@"%@의\n00 버튼을\n00 누르세요", _removableDevice.deviceName];
|
|
|
- [self requestExcludeDevice];
|
|
|
+ [self requestExcludeDevice:YES];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -94,6 +94,18 @@
|
|
|
[self sendDataToSocket:request modelClass:[CommandModel class]];
|
|
|
}
|
|
|
|
|
|
+- (void)requestExcludeDevice:(BOOL)isStart {
|
|
|
+ SocketRequestModel *request = [[SocketRequestModel alloc] initWithMsgType:MSG_TYPE_DEVICE_COMMAND];
|
|
|
+
|
|
|
+ NSDictionary *param = @{@"device_id": [[JDFacade facade].loginUser getHomeHubID],
|
|
|
+ @"command_type":isStart? CMD_TYPE_UNPAIRING_START:CMD_TYPE_UNPAIRING_STOP,
|
|
|
+ @"cust_id": [[JDFacade facade].loginUser custId],
|
|
|
+ @"ctrt_grp_id": [[JDFacade facade].loginUser ctrtGrpId]};
|
|
|
+ [request setRequestMsg:param];
|
|
|
+ [self sendDataToSocket:request modelClass:[CommandModel class]];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
-(void)startLoading:(BOOL)isStart {
|
|
|
_lblElapsedTime.hidden = !isStart;
|
|
|
_imgLoading.hidden = !isStart;
|
|
|
@@ -117,6 +129,7 @@
|
|
|
});
|
|
|
}
|
|
|
else {
|
|
|
+ _elapsedSeconds = 60;
|
|
|
if (_timer) {
|
|
|
[_timer invalidate];
|
|
|
_timer = nil;
|
|
|
@@ -141,82 +154,29 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-- (void)requestExcludeDevice {
|
|
|
- NSString *path = [NSString stringWithFormat:API_DELETE_DEVICE_EXCLUSION, [JDFacade facade].loginUser.homehubDeviceId];
|
|
|
+- (void)didFailExclusion {
|
|
|
+ [self startLoading:NO];
|
|
|
+ [self requestIncludeDevice:NO];
|
|
|
|
|
|
- [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[DeviceModel class] showLoadingView:YES completion:^(id responseObject) {
|
|
|
- if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- DeviceModel *device = (DeviceModel *)responseObject;
|
|
|
-
|
|
|
- if (device) {//API 성공 ,
|
|
|
- [self requestCheckInclustion:device.commandId];
|
|
|
- }
|
|
|
- } failure:^(id errorObject) {
|
|
|
- JDErrorModel *error = (JDErrorModel *)errorObject;
|
|
|
- [[JDFacade facade] alert:error.errorMessage];
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)requestCheckInclustion:(NSString *)commandId {
|
|
|
+ ThingsAddFailViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddFailViewController" storyboardName:@"Things"];
|
|
|
|
|
|
+ vc.addableDevice = _addableDevice;
|
|
|
|
|
|
+ vc.providesPresentationContextTransitionStyle = YES;
|
|
|
+ vc.definesPresentationContext = YES;
|
|
|
|
|
|
- //parameters
|
|
|
- NSDictionary *parameter = @{@"command_id": commandId};
|
|
|
- NSString *path = [NSString stringWithFormat:API_GET_DEVICE_COMMAND, [JDFacade facade].loginUser.homehubDeviceId];
|
|
|
+ [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
|
|
|
|
|
|
- [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestGET parameters:parameter
|
|
|
- modelClass:[DeviceModel class] showLoadingView:NO completion:^(id responseObject) {
|
|
|
- if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- DeviceModel *device = (DeviceModel *)responseObject;
|
|
|
-
|
|
|
- if (device) {//API 성공 ,
|
|
|
-
|
|
|
- if ([device.status isEqualToString:KNEET_DEVICE_WAITING]) {
|
|
|
- if (_elapsedSeconds > 2) {
|
|
|
- [self performSelector:@selector(requestCheckInclustion:) withObject:commandId afterDelay:3.0f];
|
|
|
- }
|
|
|
- //retry
|
|
|
- return;
|
|
|
-
|
|
|
- } else if ([device.status isEqualToString:KNEET_DEVICE_INCLUSION] || [device.status isEqualToString:KNEET_DEVICE_EXCLUSION]) {
|
|
|
- //success
|
|
|
- if (_timer) {
|
|
|
- [_timer invalidate];
|
|
|
- _timer = nil;
|
|
|
- }
|
|
|
- ThingsAddCompleteViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddCompleteViewController" storyboardName:@"Things"];
|
|
|
- vc.isDeleteMode = [device.status isEqualToString:KNEET_DEVICE_EXCLUSION];
|
|
|
-
|
|
|
- vc.providesPresentationContextTransitionStyle = YES;
|
|
|
- vc.definesPresentationContext = YES;
|
|
|
-
|
|
|
- [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
|
|
|
-
|
|
|
- [self presentViewController:vc animated:YES completion:^{
|
|
|
- _maskView.alpha = 0.0f;
|
|
|
- }];
|
|
|
- }
|
|
|
- }
|
|
|
- } failure:^(id errorObject) {
|
|
|
- JDErrorModel *error = (JDErrorModel *)errorObject;
|
|
|
- [[JDFacade facade] alert:error.errorMessage completionHander:^{
|
|
|
- [self didFailInclusion];
|
|
|
- }];
|
|
|
+ UIViewController *pvc = self.presentingViewController;
|
|
|
+ [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
|
|
|
+ [pvc presentViewController:vc animated:YES completion:nil];
|
|
|
}];
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
- (void)didFailInclusion {
|
|
|
[self startLoading:NO];
|
|
|
-// [self requestIncludeDevice:NO];
|
|
|
+ [self requestIncludeDevice:NO];
|
|
|
|
|
|
ThingsAddFailViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddFailViewController" storyboardName:@"Things"];
|
|
|
|
|
|
@@ -266,46 +226,19 @@
|
|
|
_startCommand = response;
|
|
|
}
|
|
|
else if ([response.commandType isEquestToIgnoreCase:CMD_TYPE_PAIRING_STOP]) {
|
|
|
+ _stopCommand = response;
|
|
|
+ }
|
|
|
+ else if ([response.commandType isEquestToIgnoreCase:CMD_TYPE_UNPAIRING_START]) {
|
|
|
_startCommand = response;
|
|
|
}
|
|
|
+ else if ([response.commandType isEquestToIgnoreCase:CMD_TYPE_UNPAIRING_STOP]) {
|
|
|
+ _stopCommand = response;
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
[self didFailInclusion];
|
|
|
}
|
|
|
}
|
|
|
-// else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_DEVICE_COMMAND_RES]) {
|
|
|
-// CommandModel *response = [[CommandModel alloc] initWithDictionary:message error:nil];
|
|
|
-// NSLog(@"Response : %@", response);
|
|
|
-// if (result.isSuccess) {
|
|
|
-// if ([response.commandType isEquestToIgnoreCase:CMD_TYPE_PAIRING_START]) {
|
|
|
-// if ([response.commandId isEqualToString:_startCommand.commandId]) {
|
|
|
-// [self startLoading:YES];
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else if ([response.commandType isEquestToIgnoreCase:CMD_TYPE_PAIRING_STOP]) {
|
|
|
-// [self startLoading:NO];
|
|
|
-//
|
|
|
-// ThingsAddCompleteViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddCompleteViewController" storyboardName:@"Things"];
|
|
|
-// vc.isDeleteMode = NO;
|
|
|
-//
|
|
|
-// vc.providesPresentationContextTransitionStyle = YES;
|
|
|
-// vc.definesPresentationContext = YES;
|
|
|
-//
|
|
|
-// [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
|
|
|
-//
|
|
|
-// [self presentViewController:vc animated:YES completion:^{
|
|
|
-// _maskView.alpha = 0.0f;
|
|
|
-// }];
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else {
|
|
|
-// [self didFailInclusion];
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_REGIST_RES]) {
|
|
|
-// [self requestIncludeDevice:NO];
|
|
|
-// }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- (void) socketDidFailWithError:(NSError *)error {
|
|
|
@@ -342,6 +275,27 @@
|
|
|
_maskView.alpha = 0.0f;
|
|
|
}];
|
|
|
}
|
|
|
+ if ([response.commandType isEquestToIgnoreCase:CMD_TYPE_UNPAIRING_START]) {
|
|
|
+ if ([response.commandId isEqualToString:_startCommand.commandId]) {
|
|
|
+ [self startLoading:YES];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if ([response.commandType isEquestToIgnoreCase:CMD_TYPE_UNPAIRING_STOP]) {
|
|
|
+ [self startLoading:NO];
|
|
|
+
|
|
|
+// ThingsAddCompleteViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddCompleteViewController" storyboardName:@"Things"];
|
|
|
+// vc.isDeleteMode = NO;
|
|
|
+//
|
|
|
+// vc.providesPresentationContextTransitionStyle = YES;
|
|
|
+// vc.definesPresentationContext = YES;
|
|
|
+//
|
|
|
+// [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
|
|
|
+//
|
|
|
+// [self presentViewController:vc animated:YES completion:^{
|
|
|
+// _maskView.alpha = 0.0f;
|
|
|
+// }];
|
|
|
+ // TODO : 장치 삭제 완료 페이지로 이동
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
[self didFailInclusion];
|