//
//  CYEcgKit.h
//  CYEcgKit
//
//  Created by ls on 2019/7/17.
//  Copyright © 2019 CY. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "CyEcgDeviceModel.h"
#import "CYResult.h"
#import "CYHeartLive.h"
#import "CYLastFileInfo.h"
#import "CYEcgPlayBackView.h"
#import "CYUserConfig.h"
NS_ASSUME_NONNULL_BEGIN


//代理方法
@protocol CYEcgDelegate <NSObject>

/**
 获取蓝牙原始数据
 @param data 蓝牙原始数据
 */
- (void)fetchCyOriginalData:(NSData *)data;

/**
 获取计算结果
 @param result 计算结果
 */
- (void)fetchCyCalResult:(CYResult *)result;

@end

/**
 @param error 搜索错误码
 */
typedef  void(^ScanResultBlock)(CyEcgDeviceModel* cyPeripheral, NSError* _Nullable error);
//连接成功，断开连接，连接失败回调
typedef void(^ConnectSuccssBlock)(void);
typedef void(^DisConnectBlock)(void);
typedef void(^FailConnectBlock)(void);


@interface CYEcgKit : NSObject

/**
 获取最新一次文件信息
 */
@property (nonatomic,strong,readonly) CYLastFileInfo* lastFileInfo;

//单例方法
+ (CYEcgKit*)sharedInstance;

/**
 初始化SDK
 @param appID 平台申请的appid
 @param userName 用户姓名
 @param config 用户信息配置
 */
+ (void)initWithAppID:(NSString *)appID userName:(NSString*)userName userConfig:(nullable CYUserConfig*)config;

/**
 设置代理
 */
@property (nonatomic, weak) id<CYEcgDelegate> delegate;



/**
 扫描设备
 */
- (void)scanForPeripherals:(ScanResultBlock)block;

/**
 停止扫描
 */
-(void)stopScan;

/**
 连接外设
 @param peripheral 外设描述
 */

-(void)connectPeripheral:(CBPeripheral *)peripheral success:(ConnectSuccssBlock)success disConnect:(DisConnectBlock)disConnect failConnect:(FailConnectBlock)failConnect;



/**
 取消连接
 */
- (void)cancelPeripheral;

/**
 开始记录文件

 @param fileName 设置文件名
 */
-(void)startRecordWithFileName:(NSString* _Nullable )fileName;

/**
 停止记录文件
 */
-(void)endRedcord;


@end



NS_ASSUME_NONNULL_END
