1
1
package com .clj .fastble ;
2
2
3
+ import android .annotation .SuppressLint ;
3
4
import android .annotation .TargetApi ;
4
5
import android .app .Application ;
5
6
import android .bluetooth .BluetoothAdapter ;
@@ -381,8 +382,8 @@ public BluetoothGatt connect(String mac, BleGattCallback bleGattCallback) {
381
382
/**
382
383
* Cancel scan
383
384
*/
384
- public void cancelScan () {
385
- BleScanner .getInstance ().stopLeScan ();
385
+ public void cancelScan (boolean isCallbackScanFinish ) {
386
+ BleScanner .getInstance ().stopLeScan (isCallbackScanFinish );
386
387
}
387
388
388
389
/**
@@ -746,13 +747,13 @@ public boolean requestConnectionPriority(BleDevice bleDevice, int connectionPrio
746
747
* @return
747
748
*/
748
749
public boolean isSupportBle () {
749
- return Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN_MR2
750
- && context .getApplicationContext ().getPackageManager ().hasSystemFeature (PackageManager .FEATURE_BLUETOOTH_LE );
750
+ return context .getApplicationContext ().getPackageManager ().hasSystemFeature (PackageManager .FEATURE_BLUETOOTH_LE );
751
751
}
752
752
753
753
/**
754
754
* Open bluetooth
755
755
*/
756
+ @ SuppressLint ("MissingPermission" )
756
757
public void enableBluetooth () {
757
758
if (bluetoothAdapter != null ) {
758
759
bluetoothAdapter .enable ();
@@ -848,6 +849,13 @@ public void removeNotifyCallback(BleDevice bleDevice, String uuid_notify) {
848
849
bleBluetooth .removeNotifyCallback (uuid_notify );
849
850
}
850
851
852
+ public boolean isHasNotifyCallback (BleDevice bleDevice , String uuid_notify ) {
853
+ BleBluetooth bleBluetooth = getBleBluetooth (bleDevice );
854
+ if (bleBluetooth != null )
855
+ return bleBluetooth .isHasNotifyCallback (uuid_notify );
856
+ return false ;
857
+ }
858
+
851
859
public void removeIndicateCallback (BleDevice bleDevice , String uuid_indicate ) {
852
860
BleBluetooth bleBluetooth = getBleBluetooth (bleDevice );
853
861
if (bleBluetooth != null )
@@ -914,6 +922,14 @@ public boolean isConnected(String mac) {
914
922
return false ;
915
923
}
916
924
925
+ public boolean isConnected () {
926
+ List <BleDevice > list = getAllConnectedDevice ();
927
+ if (list != null && list .size () > 0 ) {
928
+ return true ;
929
+ }
930
+ return false ;
931
+ }
932
+
917
933
public void disconnect (BleDevice bleDevice ) {
918
934
if (multipleBluetoothController != null ) {
919
935
multipleBluetoothController .disconnect (bleDevice );
@@ -926,9 +942,9 @@ public void disconnectAllDevice() {
926
942
}
927
943
}
928
944
929
- public void destroy () {
945
+ public void destroy (String mac ) {
930
946
if (multipleBluetoothController != null ) {
931
- multipleBluetoothController .destroy ();
947
+ multipleBluetoothController .destroy (mac );
932
948
}
933
949
}
934
950
0 commit comments