|
@@ -140,7 +140,7 @@ public class BLEHandler {
|
|
|
@Override
|
|
|
public void handleMessage( Message msg ) {
|
|
|
|
|
|
- if( characteristic == null )
|
|
|
+ if( characteristic == null || mBluetoothGatt == null )
|
|
|
return;
|
|
|
|
|
|
characteristic.setValue( ( byte[] ) msg.obj );
|
|
@@ -457,14 +457,8 @@ public class BLEHandler {
|
|
|
if( mBluetoothAdapter == null )
|
|
|
mBluetoothAdapter = btmanager.getAdapter();
|
|
|
|
|
|
- if( false ) {
|
|
|
-
|
|
|
|
|
|
|
|
|
-
|
|
|
- mBluetoothAdapter.startLeScan(new UUID[]{UUID.fromString("0000ffe0-0000-1000-8000-00805f9b34fb")}, mLeScanCallback);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
@@ -487,7 +481,16 @@ public class BLEHandler {
|
|
|
if( bluetoothLeScanner == null )
|
|
|
bluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
|
|
|
|
|
|
- bluetoothLeScanner.startScan( Collections.singletonList(scanFilter), scanSettings, new MyScanCallback() );
|
|
|
+ if( bluetoothLeScanner != null ) {
|
|
|
+
|
|
|
+ bluetoothLeScanner.startScan(Collections.singletonList(scanFilter), scanSettings, new MyScanCallback());
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ mBluetoothAdapter.startLeScan(new UUID[]{UUID.fromString("0000ffe0-0000-1000-8000-00805f9b34fb")}, mLeScanCallback);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
Log.i(TAG, "startScan()");
|
|
|
|