//
//  ViewController.m
//  LCOnDemo
//
//  Created by 陈嘉乐 on 2021/4/26.
//

#import "ViewController.h"
#import "LCOnIntercomViewController.h"
#import "LCOnMonitorViewController.h"
#import "LCUtlis.h"
#import "LCCallDelegate.h"
#import "LCApiKit.h"

@interface ViewController ()<LCCallDelegate>

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
  
}

-(void)initLCSDK{
    //初始化LCOpenSDK_Api
    [[LCApiKit sharedInstance] initSDKOpenApi:@"St_0000070a12e995ed44628eeea75a19fc"];
    [[LCApiKit sharedInstance] setCurrentDevicePlayToken:@"5a9cbb4ab2454454ba4995addf3760cc"];
    [[LCApiKit sharedInstance] setCurrentDeviceId:@"6K056CFAAJ8FFA1"];
    [[LCApiKit sharedInstance] setCurrentDeviceName:@"大华可视对讲"];
    [[LCApiKit sharedInstance] setCurrentPsk:@"6K056CFAAJ8FFA1"];
}

///监控
- (IBAction)monitoringAction:(id)sender {
    [self initLCSDK];
    
    LCOnMonitorViewController *mVc = [[LCOnMonitorViewController alloc] init];
    
    

    [self.navigationController.navigationBar setHidden: YES];
    [self.navigationController pushViewController:mVc animated:YES];
}

///来电接听
- (IBAction)callAction:(id)sender {
    [self initLCSDK];
    
    LCOnIntercomViewController *mVc = [[LCOnIntercomViewController alloc] init];
    mVc.mLCCallDelegate = self;
    [self.navigationController.navigationBar setHidden: YES];
    [self.navigationController pushViewController:mVc animated:YES];
}



- (void)onAnswerAction {
    
}

- (void)onHangUpAction:(int)callDuration {
    
}

- (void)onRejectCallAction {
    
}

- (void)onScreenshotSuccessfulAction:(nonnull UIImage *)image {
    
}

- (void)onUnlockAction {
    NSLog(@"onUnlockAction:准备开锁");
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        NSLog(@"onUnlockAction:通知开锁成功");
        [[NSNotificationCenter defaultCenter] postNotificationName:LCCallDelegateOpenDoorSuccess
                                                            object:self];
    });
 
}


@end