|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TPMSBleSDK使用说明 |
|
|
|
|
|
|
|
|
|
|
|
[English](README.md) |
|
|
|
|
|
|
|
|
|
|
|
|版本号 |更新时间 |作者 |更新信息| |
|
|
|
|
|
|-------|------- | | | |
|
|
|
|
|
|v1.0 |2019/07/08 |JosonXiong| 初步版本| |
|
|
|
|
|
|V1.1.0 |2020/04/10 |JosonXiong| 增加key和secret加密验证功能| |
|
|
|
|
|
|
|
|
|
|
|
## 一、使用条件 |
|
|
|
|
|
> * 最低版本iOS 8.0 |
|
|
|
|
|
> * 设备所使用的蓝牙版本需要4.0及以上 |
|
|
|
|
|
## 二、开始使用 |
|
|
|
|
|
1.申请sdk的key 和secret ,申请地址:http://sdk.aicare.net.cn; |
|
|
|
|
|
2.在info.plist文件中加入“Privacy - Bluetooth Always Usage Description”; |
|
|
|
|
|
3.将TPMSBleSDK.framework导入Xcode工程。 |
|
|
|
|
|
4.在AppDelegate中入如下代码: |
|
|
|
|
|
``` |
|
|
|
|
|
#import <TPMSBleSDK/ELTPMSBleManager.h> |
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { |
|
|
|
|
|
// Override point for customization after application launch. |
|
|
|
|
|
[ELTPMSBleManager setAppKey:@"key" appSecret:@"secret"]; |
|
|
|
|
|
return YES; |
|
|
|
|
|
} |
|
|
|
|
|
``` |
|
|
|
|
|
5.设置build setting 的bitcode为NO |
|
|
|
|
|
6.在需要使用的控制器.m中导入#import <TPMSBleSDK/ELTPMSBleManager.h>,并遵守< ELTPMSBleManagerDelegate>协议, |
|
|
|
|
|
7.设置代理 |
|
|
|
|
|
``` |
|
|
|
|
|
[ELTPMSBleManager shareManager].delegate = self; |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
8.实现代理方法 |
|
|
|
|
|
``` |
|
|
|
|
|
-(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(头文件) |
|
|
|
|
|
提供胎压单位,温度单位,以及单位之间的转换方法和对应单位的名称符号。 |