# TPMSBleSDK使用说明 [English](README.md) |版本号 |更新时间 |作者 |更新信息| |-------| ------- | ------ | ------ | |v1.0 |2019/07/08 |JosonXiong| 初步版本| |v1.1.1 |2023/06/26 |Larry| 文档整理 | ## 一、使用条件 > * 最低版本iOS 8.0 > * 设备所使用的蓝牙版本需要4.0及以上 ## 二、开始使用 1.将 TPMSBleSDK.framework 导入Xcode工程; 2.在info.plist文件中加入“Privacy - Bluetooth Always Usage Description”; 3.在需要使用的 控制器.m 中导入 #import ,并遵守 < ELTPMSBleManagerDelegate> 协议; 4.设置代理 ``` [ELTPMSBleManager shareManager].delegate = self; ``` 5.实现代理方法 ``` -(void)TPMSBleManagerUpdateBleState:(TPMSBluetoothState)state; -(void)TPMSBleManagerReceiveData:(ELTPMSDataModel *_Nonnull)model; ``` ## 三、获取广播数据 ### 1.判断手机蓝牙是否可用 可通过代理方法: ``` -(void)TPMSBleManagerUpdateBleState:(TPMSBluetoothState)state; ``` 获取当前蓝牙的状态, 也可通过 ``` [ELTPMSBleManager shareManager].isOn; ``` 获取当前蓝牙是否打开可用; ### 2.开始扫描 ``` [[ELTPMSBleManager shareManager] startScan]; ``` ### 3.停止扫描 ``` [[ELTPMSBleManager shareManager] stopScan]; ``` ### 4.代理方法说明 ``` -(void)TPMSBleManagerUpdateBleState:(TPMSBluetoothState)state; ``` 此方法用于获取蓝牙当前状态,其中参数”state”是一个枚举TPMSBluetoothState 枚举的元素包括:TPMSBluetoothStateAvailable(蓝牙打开可TPMSBluetoothStateUnavailable(蓝牙不可用),TPMSBluetoothStateBroadcasting(蓝牙正在广播数据),TPMSBluetoothStateStopBroadcasting(停止广播) ``` -(void)TPMSBleManagerReceiveData:(ELTPMSDataModel *_Nonnull)model; ``` 此方法用于回调TPMS蓝牙模块广播数据,model是一个ELTPMSDataModel 数据模型,关于ELTPMSDataModel 类的详细请查看“备注” ## 四、备注 ELTPMSDataModel(广播数据模型) |类型|参数名|说明| | ----| ---- | --- | |ELTPMSDataType|type|数据类型| |int|classID|产品型号| |double|v|电压系数(单位:V)| |double |p|压力系数(单位:kPa)| |int |t|温度系数(单位:°C)| |ELTPMSDeviceState|state|胎压状态| |int |mcuVersion|MCU版本号| |int |startCount|启动次数| |int |stopCount|潜停次数| |NSString|bleVersion|蓝牙版本号| |NSString |macAddress|MAC地址| |NSString |name|蓝牙名称| |NSInteger|createTime|接收到数据的时间| ELTPMSHeader.h(头文件) 提供胎压单位,温度单位,以及单位之间的转换方法和对应单位的名称符号。