feature():1.修改连接的方式,增加连接速度

This commit is contained in:
lvwang2002 2024-05-15 23:35:38 +08:00
parent a7a77d34a9
commit e81b7b33e2
1 changed files with 6 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import android.bluetooth.BluetoothManager;
import android.bluetooth.le.BluetoothLeScanner; import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanCallback; import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanResult; import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -858,13 +859,15 @@ public class BleDeviceManager {
// @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) // @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private boolean/* _Mode */startNativeScan() { private boolean/* _Mode */startNativeScan() {
// RNLog.d(TAG,"start native scan:"); //RNLog.d(TAG,"start native scan:");
BluetoothLeScanner scanner = mBluetoothAdapter.getBluetoothLeScanner(); BluetoothLeScanner scanner = mBluetoothAdapter.getBluetoothLeScanner();
if(scanner == null){ if(scanner == null){
return false; return false;
} }
// RNLog.d(TAG,"start scan:"); //RNLog.d(TAG,"start scan:");
scanner.startScan(mDeviceListener.scanCallback); //scanner.startScan(mDeviceListener.scanCallback);
ScanSettings scannerSetting = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
scanner.startScan(null,scannerSetting,mDeviceListener.scanCallback);
return true; return true;
} }