IDO 智能手环iOS SDK

1.1功能概述

IDOBluetooth、IDOBlueProtocol、IDOBlueUpdate适用于iOS设备并支持IDO公司的手环,实现蓝牙连接控制框架库。基于iOS系统的蓝牙框架,扩展了蓝牙扫描、连接、绑定、控制、设置、获取、监听、传输等功能。利用c编写的协议库实现结构体数据的转换和健康数据同步过程中逻辑处理,减少了蓝牙通信数据的错误,提高了蓝牙通信的速度和准确性。这个特性丰富的API易于使用。

1.2快速集成

1.2.1 使用 Cocoapods 集成

在Podfile文件中添加以下内容:

source 'https://github.com/idoosmart/IDOSmartSpec.git'
platform :ios, '8.0'
target 'your_target_name' do
   pod 'IDOBluetooth'
   pod 'IDOBlueProtocol'
   pod 'IDOBlueUpdate'
end

然后在项目根目录下执行 pod update 命令,集成第三方库。 CocoaPods的使用请参考:CocoaPods Guides

1.3初始化 SDK

  1. 打开项目设置,Target => Build Settings,修改 Other Linker Flags 添加 -Objc
  2. Objective-C工程需要添加一个空的Swift文件,生成Objective-C Bridging Header
  3. 依赖系统库CoreBluetooth.framework``libc++.tbd``libsqlite3.0.tbd
  4. 在项目的PrefixHeader.pch文件添加以下内容:
#import <IDOBluetooth/IDOBluetooth.h>
#import <IDOBlueProtocol/IDOBlueProtocol.h>
#import <IDOBlueUpdate/IDOBlueUpdate.h>

Swift 项目添加以下内容

import IDOBlueUpdate
import IDOBluetooth
import IDOBlueProtocol

1.3.1 注册SDK

  1. 打开AppDelegate.m文件,在[AppDelegate application:didFinishLaunchingWithOptions:]方法中注册SDK: 接口说明
IDOBluetoothServices * _Nonnull registrationServices(NSString * _Nullable password)

@property (nonatomic,copy,nullable) IDOBluetoothServices *_Nonnull(^outputSdkLog)(BOOL isOutput);

@property (nonatomic,copy,nullable) IDOBluetoothServices *_Nonnull(^outputProtocolLog)(BOOL isOutput,BOOL isRecord);

@property (nonatomic,copy,nullable) IDOBluetoothServices *_Nonnull(^rawDataLog)(BOOL isRecord);

@property (nonatomic,copy,nullable) void(^startScanBule)(void(^ _Nullable getDeviceInfoBlock)(IDOGetDeviceInfoBluetoothModel * _Nullable model));

参数说明

参数

说明

备注 </tr> </thead>

registrationServices

注册服务初始化

SDK数据库密码,传nil数据库不加密 </tr>

startConnectDevice

开始启动时告诉SDK需要连接的设备

Mac地址 </tr>

outputSdkLog

输出sdk日志

debug模式下为YES </tr>

outputProtocolLog

输出和记录协议日志

debug模式下为YES </tr>

rawDataLog

记录原始日志

根据项目需要添加 </tr> </tbody> </table> Objc:

#ifdef DEBUG
registrationServices().outputSdkLog(YES).outputProtocolLog(YES,YES).rawDataLog(YES).startScanBule(^(IDOGetDeviceInfoBluetoothModel * _Nullable model) {
        //根据绑定状态执行自动扫描连接,初始化蓝牙管理中心
       if(__IDO_BIND__)[IDOBluetoothManager startScan];
       else [IDOBluetoothManager refreshDelegate];
    });
#else
registrationServices().outputSdkLog(NO).outputProtocolLog(NO,YES).rawDataLog(YES).startScanBule(^(IDOGetDeviceInfoBluetoothModel * _Nullable model) {
         //根据绑定状态执行自动扫描连接,初始化蓝牙管理中心
       if(__IDO_BIND__)[IDOBluetoothManager startScan];
       else [IDOBluetoothManager refreshDelegate];  
});
#endif

Swift

#if DEBUG
registrationServices().outputSdkLog!(true).outputProtocolLog!(true,true).rawDataLog!(true).startScanBule!{
            (model) in
            //根据绑定状态执行自动扫描连接,初始化蓝牙管理中心
if IDOBluetoothEngine.shareInstance()?.peripheralEngine.isBind
 == true  {
    IDOBluetoothManager.startScan()
 }else {
    IDOBluetoothManager.refreshDelegate()
 }
}
#else
registrationServices().outputSdkLog!(false).outputProtocolLog!(false,true).rawDataLog!(true).startScanBule!{
            (model) in
            //根据绑定状态执行自动扫描连接,初始化蓝牙管理中心
 if IDOBluetoothEngine.shareInstance()?.peripheralEngine.isBind 
 == true       {
    IDOBluetoothManager.startScan()
 }else {
    IDOBluetoothManager.refreshDelegate()
 }
}
#endif

1.3.2 SDK通知服务名称

// 蓝牙扫描、连接状态通知监听名字 | Bluetooth scan, connection status notification listener name
extern NSString * _Nonnull IDOBluetoothConnectStateNotifyName;

// 蓝牙扫描、连接过程错误通知监听名字 | Bluetooth scan, connection process error notification listener name
extern NSString * _Nonnull IDOBluetoothConnectErrorNotifyName;

// 设备绑定状态通知名字 | device bind status notification name
extern NSString * _Nonnull IDOBluetoothDeviceBindNotifyName;

// 同步配置获取设备信息通知名字 | get device info notification name
extern NSString * _Nonnull IDOBluetoothGetDeviceInfoNotifyName;

// 同步配置完成通知名字 | sync config complete notification name
extern NSString * _Nonnull IDOBluetoothSyncConfigNotifyName;

// 同步健康数据完成通知名字 | sync health data complete notification name
extern NSString * _Nonnull IDOBluetoothSyncHealthNotifyName;

// 刚连接时快速配置完成通知名字 | fast sync complete notification name
extern NSString * _Nonnull IDOBluetoothFastSyncNotifyName;
Copyright © 2015-2020 IDO. All rights reserved. all right reserved,powered by Gitbook修订时间: 2023-12-18 10:04:13

results matching ""

    No results matching ""