//
//  BLEDevice.h
//  ENBLEProject
//
//  Created by lvwang2002 on 16/4/4.
//  Copyright © 2016年 Facebook. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "ENNativeDevice.h"
//#import "ENGlucoDevice.h"
#import "ENBLEDeviceManager.h"
@class BLEDevice,ENNativeDevice,ENBLEDeviceManager;
@protocol BLEDeviceProtocol <NSObject>

/** 设备连接 */
@optional
-(void)connectedDevice:(BLEDevice *)device;


/** 设备断开 */
@optional
-(void)didDisconnectDevice:(BLEDevice *)device;

@optional
-(void)didOverTimeForConnectDevice:(BLEDevice *)device;
@end

typedef NS_ENUM(NSUInteger, ConnectStatus) {
  DeviceSearchedStatus=0,
	DeviceConnectingStatus,
	DeviceConnectedStatus,
	DeviceDisconnectingStatus,
	DeviceDisconnectedStatus
};
@interface BLEDevice : NSObject<CBPeripheralDelegate>

-(id)initWithPeripheral:(CBPeripheral *)peripheral CentralManager:(CBCentralManager *)centerManager DeviceManager:(ENBLEDeviceManager *)deviceManager;
-(NSUUID *)getUUID;
@property(nonatomic,strong)NSDate *searchDate; // 被找到的时间
@property(nonatomic,weak)id<BLEDeviceProtocol>deviceDelegate;
@property(nonatomic,strong)ENNativeDevice *nativeDevice;
@property(nonatomic,strong)NSDictionary *advertisementData;


@property ConnectStatus connectStatus;

/** 设置已经连接成功 */
-(void)setConnectedDevice;

/** 得到管理器 */
-(ENBLEDeviceManager *)getDeviceManager;

/** 得到设备显示名字 */
-(NSString *)getDeviceDisplayName;

/**  断开连接 */
-(void)disconnect;

/** 尝试去连接 */
-(void)connect;

/** 获取名字 */
-(NSString *)getDeviceName;

/** 获取设备UUID */
-(NSUUID *)getDeviceUUID;

/** 获取附件 */
-(CBPeripheral *)getPeripheral;

/** 返回对应的原生设备 */
-(ENNativeDevice *)getNativeDevice;

/** 获取DataID */
+(NSString *)getDataIDWithUserID:(NSString *)userID
														Type:(NSString *)type
												TimeFlag:(NSNumber *)timeFlag
													 Value:(NSString *)value;

@end
