Skip to content

Commit

Permalink
repair BleScanRuleConfig NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasonchenlijian committed Nov 30, 2017
1 parent 6c1a8cf commit 5daf4b9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion FastBleLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "2.1.2"
versionName "2.1.3"
}
buildTypes {
release {
Expand Down
1 change: 1 addition & 0 deletions FastBleLib/src/main/java/com/clj/fastble/BleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void init(Application app) {
bluetoothAdapter = bluetoothManager.getAdapter();
bleExceptionHandler = new DefaultBleExceptionHandler();
multipleBluetoothController = new MultipleBluetoothController();
bleScanRuleConfig = new BleScanRuleConfig();
bleScanner = BleScanner.getInstance();
}
}
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ Android Bluetooth Low Energy 蓝牙快速开发框架。
<dependency>
<groupId>com.clj.fastble</groupId>
<artifactId>FastBleLib</artifactId>
<version>2.1.2</version>
<version>2.1.3</version>
<type>pom</type>
</dependency>

### Gradle

compile 'com.clj.fastble:FastBleLib:2.1.2'
compile 'com.clj.fastble:FastBleLib:2.1.3'


## 其他说明
Expand Down Expand Up @@ -89,14 +89,17 @@ FastBle 所有代码均可以加入混淆。

BleScanRuleConfig scanRuleConfig = new BleScanRuleConfig.Builder()
.setServiceUuids(serviceUuids) // 只扫描指定的服务的设备,可选
.setDeviceName(true, names) // 只扫描指定广播名的设备,可选
.setDeviceName(true, names) // 只扫描指定广播名的设备,可选
.setDeviceMac(mac) // 只扫描指定mac的设备,可选
.setAutoConnect(isAutoConnect) // 连接时的autoConnect参数,可选,默认false
.setScanTimeOut(10000) // 扫描超时时间,可选,默认10秒
.build();
BleManager.getInstance().initScanRule(scanRuleConfig);

在扫描设备之前,建议配置扫描规则,筛选出与程序匹配的设备;不配置的话均为默认参数。
需要注意的是:
- 在扫描设备之前,可以配置扫描规则,筛选出与程序匹配的设备
- 不配置的话均为默认参数
- 在2.1.2版本及之前,必须先配置过滤规则再扫描;在2.1.3版本之后可以无需配置,开启默认过滤规则的扫描。


- #### (方法说明)扫描设备
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "2.1.2"
versionName "2.1.3"
}
buildTypes {
release {
Expand Down

0 comments on commit 5daf4b9

Please sign in to comment.