Closed kkpyqt closed 6 years ago
我是参考教程写的: 初始化后开如扫描: ViseBle.getInstance().startScan(periodScanCallbackbyall);
private ScanCallback periodScanCallbackbyall = new ScanCallback(new IScanCallback() { @Override public void onDeviceFound(final BluetoothLeDevice bluetoothLeDevice) { ViseLog.i("Founded Scan Device:" + bluetoothLeDevice); onFilter(bluetoothLeDevice); //检查是否有合法设备
} @Override public void onScanFinish(BluetoothLeDeviceStore bluetoothLeDeviceStore) { ViseLog.i("scan finish " + bluetoothLeDeviceStore); } @Override public void onScanTimeout() { ViseLog.i("scan timeout"); } });
在这个方法下停上不了扫描 private void onFilter(BluetoothLeDevice bluetoothLeDevice) { String[] blename; blename = new String[]{"Glucose"}; for(int i=0;i<blename.length;i++) { if (bluetoothLeDevice.getDevice().getName().trim().equals(blename[i])) { mac = bluetoothLeDevice.getDevice().getAddress(); connectbymac();
ViseLog.i("Founded Scan Device:" + mac); if (periodScanCallbackbyall != null && periodScanCallbackbyall.isScanning()) { ViseBle.getInstance().stopScan(periodScanCallbackbyall);//找到就停止扫描 }
//
} } }
@kkpyqt 看下超时时间设置是不是为-1,demo默认是一直扫描的
非常感谢,我把-1 改为30000 即可,问题已经解决
我是参考教程写的: 初始化后开如扫描: ViseBle.getInstance().startScan(periodScanCallbackbyall);
private ScanCallback periodScanCallbackbyall = new ScanCallback(new IScanCallback() { @Override public void onDeviceFound(final BluetoothLeDevice bluetoothLeDevice) { ViseLog.i("Founded Scan Device:" + bluetoothLeDevice); onFilter(bluetoothLeDevice); //检查是否有合法设备
在这个方法下停上不了扫描 private void onFilter(BluetoothLeDevice bluetoothLeDevice) { String[] blename; blename = new String[]{"Glucose"}; for(int i=0;i<blename.length;i++) { if (bluetoothLeDevice.getDevice().getName().trim().equals(blename[i])) { mac = bluetoothLeDevice.getDevice().getAddress(); connectbymac();
//