1.集成准备
A.获得AppId;
进入 管理中心>开发配置 查看。
下载胎心监测开发SDK
2.导入SDK:
目前SDK只支持iOS 8.0以上真机运行的开发环境,集成方法如下:
2.1将下载的SDK中的Framework和bundle导入你的工程,
3.基本功能集成
3.1 配置AppDelegate.m
导入头文件#import
3.2 AppID的赋值填写
1. AngelDoctorFrameConfig 为SDK参数配置的实例类
2. AppID为开发者在天使医生后台申请的应用AppID ,然后在 AngelDoctorFrameConfig 方法中填上您的AppID;
3.3 UserId的赋值填写 (选填)
为了帮助开发者准确定位监测数据是属于自有平台中哪位用户,可通过为SDK设置监测用户UserId,为可选项。
UserId为开发者自有平台中正在监测的用户唯一标识,String类型。
实例代码:
- #import < AngelDoctorFrame / AngelDoctorFrameConfig.h >
- [ AngelDoctorFrameConfig setAppID : self.textField.text ];
- //填入您的AppID!
- [ AngelDoctorFrameConfig setUserID : @"UserID" ];
- // 选填!
- }
4.进入天使医生胎心开放平台
4.1 导入头文件#import < AngelDoctorFrame/ SearchBLEViewController.h >
4.2 初始化 SearchBLEViewController蓝牙搜索控制器
4.3 通过导航栏控制器push 进入SearchBLEViewController控制器
实例代码:
- -( IBAction ) pushFramework :( id ) sender {
- SearchBLENavViewController *vc = [[ SearchBLENavViewController alloc ] init ];
- [ self.navigationController pushViewController:vc animated:YES];
- }
5.自定义绘图坐标颜色与业务处理
5.1 导入头文件#import < AngelDoctorFrame/ ASCustomizeMethod.h >
5.2 自定义绘图坐标的颜色
实例代码:
- [[ ASCustomizeMethod shareInstance ] changeMainLineColor :[ UIColor blueColor ]
- auxlineColor :[ UIColor blueColor ] startPointColor :[ UIColor blueColor ]]
5.3 获取当前选择的设备的物理地址,设置控制器代理,实现selectMacAddress代理方法,处理业务场景后返回该设备否过期的BOOl值,并配置提示语
实例代码:
- -( BOOL ) selectMacAddress :( NSString *) macAddress {
- [[ ASCustomizeMethod shareInstance ] alertMessage :@"尊敬的用户您好,您的设备已过期~"];
- return YES; // 设备过期
- }
5.4 宫缩曲线移除。当设备无宫缩功能,可移除宫缩曲线
实例代码:
- [[ASCustomizeMethod shareInstance] lineViewRemoveToco:YES];
5.5埋点处理。SDK对6种事件类型进行埋点发通知处理,开发者可监听埋点事件,进行业务化处理,详情可参考demo;
实例代码:
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(setCollection:) name:kCollectionData object:nil];
- - (void)setCollection:(NSNotification *)noti{
- NSDictionary *info = noti.userInfo;
- NSLog(@"埋点事件 info %@",[info objectForKey:kCollectionTypeKey]);
- }
6.进入并使用开放平台
注意事项: archive打包时出现:file was built for archive which is not the architecture being linked (armv7) 报错时:
需要Build Settings- > Build Active Architecture Only,将其从NO 设为 YES
7.使用开发平台蓝牙功能
1、导入头文件
#import < AngelDoctorFrame / AngelDoctorBluetooth.h >
#import < AngelDoctorFrame / AngelDoctorDevice.h >
#import < AngelDoctorFrame / AngelDoctorBluetoothModel.h >
2、初始化天使医生SDK蓝牙类
示例代码:
- // 配置绘图坐标的颜色
- self.bluetooth = [[ AngelDoctorBluetooth alloc ] init ];
- // 设置代理
- self.bluetooth.delegate = self;
3、开始搜寻附近的蓝牙外围设备:
示例代码:
[self.bluetooth scanPeripheral];
4、findNewDevice: 获取所有已发现的蓝牙设备:
deviceArray 对象
为蓝牙设备信息数组,存放的为AngelDoctorDevice模型
参数 | 说明 |
---|---|
name | 蓝牙名称 |
macAddress | 蓝牙物理地址 |
peripheral | 外设 |
示例代码:
- -( void ) findNewDevice :( NSMutableArray * ) deviceArray {
- self.discoveryArray = deviceArray;
- }
5、connectDevice:withDeviceType:
连接选中的蓝牙设备:
参数 | 说明 |
---|---|
device | 选中的模型,类型 AngelDoctorDevice |
type | 设备类型,类型:AngelDoctorDeviceType |
示例代码:
- -( void ) tableView :( UITableView* ) tableView didSelectRowAtIndexPath :( NSIndexPath* ) indexPath {
- AngelDoctorDevice *device = self.deviceArr ] indexPath.row ];
- [ self.bluetooth connectDevice:device withDeviceType : AngelDoctorSpo2Type ];
- }
6、connectPeripheralState:
监听蓝牙的连接状态
参数 | 说明 |
---|---|
peripheralState | 蓝牙连接的状态 |
示例代码:
- -( void ) connectPeripheralState :( CBPeripheralState ) peripheralState {
- if ( peripheralState == CBPeripheralStateConnected ){
- NSLog ( @"连接成功" );
- { else if ( peripheralState == CBPeripheralStateConnecting ){
- NSLog ( @"连接中..." );
- { else if ( peripheralState == CBPeripheralStateDisconnected ){
- NSLog ( @"断开连接" );
- }
- }
7、getData: withDeviceType: withConnectType: withWeightProtocol:
监听蓝牙设备发出的数据(直连式和广播式蓝牙数据都是通过此方法获取):
示例代码:
- -( void ) getData:( id ) model withDeviceType:(NSInteger)type
- withConnectType :( NSInteger ) connectType
- withWeightProtocol :( NSInteger ) protocol {
- AngelDoctorBluetoothModel * bluetoothModel = [[ AngelDoctorBluetooth alloc ] init ];
- [ bluetoothModel analysisData:model withDeviceType:type withConnectType:connectType withWeightProtocol:protocol ];
- //血氧数据为例:
- self.SpoValueLabel.text = bluetoothModel.SPO;
- self.PlusValueLabel.text = bluetoothModel.Plus;
- self.PIValueLabel.text = bluetoothModel.PI;
- }
8、clearUpBluetooth 断开蓝牙连接,清除蓝牙信息:
示例代码:
[self.bluetooth clearUpBluetooth];