//
//  ENNativeDevice.m
//  ENBLEProject
//
//  Created by lvwang2002 on 16/4/7.
//  Copyright © 2016年 Facebook. All rights reserved.
//

#import "ENNativeDevice.h"
#import "ENGlucoDevice.h"
#import "ENGGlucoDevice.h"
#import "ENHMDGlucoDevice.h"
#import "ENCholesterolDevice.h"
#import "ENBPDevice.h"
#import "ENPangaoBPDevice.h"
#import "ENDynamicGlucoseDevice.h"
#import "ENSanDyGlucoseDevice.h"

@implementation ENNativeDevice



-(instancetype)initWithPeripheral:(CBPeripheral *)peripheral WithCentralManager:(CBCentralManager *)centerManager WithDevice:(BLEDevice *)device{
	self = [super init];
	if(self){
		_peripheral = peripheral;
		_centralManager = centerManager;
		_device = device;
	}
	return self;
}

+(ENNativeDevice *)getNativeDeviceWithDevice:(BLEDevice *)device
															WithPeripheral:(CBPeripheral *)peripheral
															CentralManager:(CBCentralManager *)centerManager;{
	@synchronized (self) {
			NSString *deviceName = [device getDeviceName];
			if([deviceName hasPrefix:@"BLE-"]){
				return [[ENGlucoDevice alloc] initWithPeripheral:peripheral WithCentralManager:centerManager WithDevice:device];
            }else if([deviceName hasPrefix:@"ENUO-G"]){
                return [[ENGGlucoDevice alloc] initWithPeripheral:peripheral WithCentralManager:centerManager WithDevice:device];
            }else if ([deviceName hasPrefix:@"Glucose"]){
				return [[ENHMDGlucoDevice alloc] initWithPeripheral:peripheral WithCentralManager:centerManager WithDevice:device];
			}else if([deviceName hasPrefix:@"iGate"]){
				return [[ENCholesterolDevice alloc] initWithPeripheral:peripheral WithCentralManager:centerManager WithDevice:device];
			}else if([deviceName hasPrefix:@"RBP"]){
				return  [[ENBPDevice alloc] initWithPeripheral:peripheral WithCentralManager:centerManager WithDevice:device];
			}else if([deviceName hasPrefix:@"ClinkBlood"]){
				return [[ENPangaoBPDevice alloc] initWithPeripheral:peripheral WithCentralManager:centerManager WithDevice:device];
            }else if([deviceName hasPrefix:@"O"]){
                return [[ENDynamicGlucoseDevice alloc] initWithPeripheral:peripheral WithCentralManager:centerManager WithDevice:device];
            }else if([deviceName hasPrefix:@"TH-"]){
                return [[ENSanDyGlucoseDevice alloc] initWithPeripheral:peripheral WithCentralManager:centerManager WithDevice:device];
            }
			return [[ENHMDGlucoDevice alloc] initWithPeripheral:peripheral WithCentralManager:centerManager WithDevice:device];
	}
}

/** 得到设备显示名字 */
-(NSString *)getDeviceDisplayName{
    return @"医疗设备";
}

-(NSString *)getConnectedStatus{
    return @"PREPARE";
}



@end
