//
//  HomeHubUpdateCompleteViewController.m
//  OneCable
//
//  Created by nComz on 2017. 5. 11..
//  Copyright © 2017년 ntels. All rights reserved.
//

#import "HomeHubUpdateCompleteViewController.h"
#import "MultiHomeHubViewController.h"
#import "HomeHubUpdateGuideViewController.h"
#import "RequestHandler.h"

@interface HomeHubUpdateCompleteViewController ()

@property (weak, nonatomic) IBOutlet UILabel *lbContent;

@end

@implementation HomeHubUpdateCompleteViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self initUI];
    [self prepareViewDidLoad];
}

- (void)initUI {
    
    if (!_isUpdate) {
        
       BLEServiceHandler *bleService = [BLEServiceHandler sharedManager];
        
        if ( [bleService isConnected] &&
            bleService.conDevice != nil &&
            !EQUALS([bleService getValueFromCharacteristic:kBLEChrRdSSID], @"-") ) {

            _lbContent.text = [NSString stringWithFormat:@"홈허브가 %@에 연결되었습니다.", [bleService getValueFromCharacteristic:kBLEChrRdSSID]];
        }
    }
}

- (void)prepareViewDidLoad {
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

- (IBAction)btnConfirmTouched:(id)sender {

//    UIViewController *vc = vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubViewController" storyboardName:@"Main"];
//    
//    //멀티 홈허브일때
//    if ([[JDFacade facade].loginUser isMultiHomeHub]) {
//        
//        vc = [CommonUtil instantiateViewControllerWithIdentifier:@"MultiHomeHubViewController" storyboardName:@"Main"];
//    }
//
    
    NSArray *vcs = self.navigationController.viewControllers;
    MultiHomeHubViewController *vc = (MultiHomeHubViewController*)[vcs objectAtIndex:0];
    
    NSLog(@"update Complite vc 0 : %@", vc);
    
    [self.navigationController popToRootViewControllerAnimated:YES completion:^{

        if (_isUpdate && ([vc isKindOfClass:MultiHomeHubViewController.class] || [vc isKindOfClass:HomeHubUpdateGuideViewController.class])) {
            
            
            [vc operationComplite];
        }

    }];
}






@end
