react-native-bt-device/ios/RNBTDevice/Device/ENNativeDevice.m

71 lines
2.6 KiB
Mathematica
Raw Permalink Normal View History

2024-03-24 09:45:44 +00:00
//
// 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