public void stop() { stopScan("Scan stop"); }
public void stop() { stopScan("Scan stop"); }
public void stop() { stopScan("Scan stop"); }
private void stopScanWithTimeoutCallback() { stopScan("Stop with Timeout"); processCallBacks(address, SCAN_TIMEOUT_CALLBACK); }
private void stopScanWithTimeoutCallback() { stopScan("Stop with Timeout"); processCallBacks(address, SCAN_TIMEOUT_CALLBACK); }
private void stopScanWithTimeoutCallback() { stopScan("Stop with Timeout"); processCallBacks(address, SCAN_TIMEOUT_CALLBACK); }
public synchronized void scan() { extendWakeLock((scanSeconds + 1) * Constants.SECOND_IN_MS); stopScan("Scan start"); UserError.Log.d(TAG, "startScan called: hunting: " + address + " " + name); scanSubscription = rxBleClient.scanBleDevices( new ScanSettings.Builder() .setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES) .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY) .build()//, //new ScanFilter.Builder() // // add custom filters if needed // .build() ) .timeout(scanSeconds, TimeUnit.SECONDS) // is unreliable .subscribeOn(Schedulers.io()) .subscribe(this::onScanResult, this::onScanFailure); Inevitable.task(STOP_SCAN_TASK_ID, scanSeconds * Constants.SECOND_IN_MS, this::stopScanWithTimeoutCallback); }
public synchronized void scan() { extendWakeLock((scanSeconds + 1) * Constants.SECOND_IN_MS); stopScan("Scan start"); UserError.Log.d(TAG, "startScan called: hunting: " + address + " " + name); scanSubscription = rxBleClient.scanBleDevices( new ScanSettings.Builder() .setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES) .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY) .build()//, //new ScanFilter.Builder() // // add custom filters if needed // .build() ) .timeout(scanSeconds, TimeUnit.SECONDS) // is unreliable .subscribeOn(Schedulers.io()) .subscribe(this::onScanResult, this::onScanFailure); Inevitable.task(STOP_SCAN_TASK_ID, scanSeconds * Constants.SECOND_IN_MS, this::stopScanWithTimeoutCallback); }
public synchronized void scan() { extendWakeLock((scanSeconds + 1) * Constants.SECOND_IN_MS); stopScan("Scan start"); UserError.Log.d(TAG, "startScan called: hunting: " + address + " " + name); scanSubscription = rxBleClient.scanBleDevices( new ScanSettings.Builder() .setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES) .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY) .build()//, //new ScanFilter.Builder() // // add custom filters if needed // .build() ) .timeout(scanSeconds, TimeUnit.SECONDS) // is unreliable .subscribeOn(Schedulers.io()) .subscribe(this::onScanResult, this::onScanFailure); Inevitable.task(STOP_SCAN_TASK_ID, scanSeconds * Constants.SECOND_IN_MS, this::stopScanWithTimeoutCallback); }
protected synchronized void onScanFailure(Throwable throwable) { UserError.Log.d(TAG, "onScanFailure: " + throwable); if (throwable instanceof BleScanException) { final String info = HandleBleScanException.handle(TAG, (BleScanException) throwable); UserError.Log.d(TAG, "Scan failure: " + info); if (!lastFailureReason.equals(info) || JoH.ratelimit("scanmeister-fail-error", 600)) { UserError.Log.e(TAG, "Failed to scan: " + info); lastFailureReason = info; } if (((BleScanException) throwable).getReason() == BleScanException.BLUETOOTH_DISABLED) { // Attempt to turn bluetooth on if (ratelimit("bluetooth_toggle_on", 30)) { UserError.Log.d(TAG, "Pause before Turn Bluetooth on"); JoH.threadSleep(2000); UserError.Log.e(TAG, "Trying to Turn Bluetooth on"); JoH.setBluetoothEnabled(xdrip.getAppContext(), true); } } processCallBacks(address, SCAN_FAILED_CALLBACK); } else if (throwable instanceof TimeoutException) { // note this code path not always reached - see inevitable task processCallBacks(address, SCAN_TIMEOUT_CALLBACK); } stopScan("Scan failure"); releaseWakeLock(); }
protected synchronized void onScanFailure(Throwable throwable) { UserError.Log.d(TAG, "onScanFailure: " + throwable); if (throwable instanceof BleScanException) { final String info = HandleBleScanException.handle(TAG, (BleScanException) throwable); UserError.Log.d(TAG, "Scan failure: " + info); if (!lastFailureReason.equals(info) || JoH.ratelimit("scanmeister-fail-error", 600)) { UserError.Log.e(TAG, "Failed to scan: " + info); lastFailureReason = info; } if (((BleScanException) throwable).getReason() == BleScanException.BLUETOOTH_DISABLED) { // Attempt to turn bluetooth on if (ratelimit("bluetooth_toggle_on", 30)) { UserError.Log.d(TAG, "Pause before Turn Bluetooth on"); JoH.threadSleep(2000); UserError.Log.e(TAG, "Trying to Turn Bluetooth on"); JoH.setBluetoothEnabled(xdrip.getAppContext(), true); } } processCallBacks(address, SCAN_FAILED_CALLBACK); } else if (throwable instanceof TimeoutException) { // note this code path not always reached - see inevitable task processCallBacks(address, SCAN_TIMEOUT_CALLBACK); } stopScan("Scan failure"); releaseWakeLock(); }
protected synchronized void onScanFailure(Throwable throwable) { UserError.Log.d(TAG, "onScanFailure: " + throwable); if (throwable instanceof BleScanException) { final String info = HandleBleScanException.handle(TAG, (BleScanException) throwable); UserError.Log.d(TAG, "Scan failure: " + info); if (!lastFailureReason.equals(info) || JoH.ratelimit("scanmeister-fail-error", 600)) { UserError.Log.e(TAG, "Failed to scan: " + info); lastFailureReason = info; } if (((BleScanException) throwable).getReason() == BleScanException.BLUETOOTH_DISABLED) { // Attempt to turn bluetooth on if (ratelimit("bluetooth_toggle_on", 30)) { UserError.Log.d(TAG, "Pause before Turn Bluetooth on"); JoH.threadSleep(2000); UserError.Log.e(TAG, "Trying to Turn Bluetooth on"); JoH.setBluetoothEnabled(xdrip.getAppContext(), true); } } processCallBacks(address, SCAN_FAILED_CALLBACK); } else if (throwable instanceof TimeoutException) { // note this code path not always reached - see inevitable task processCallBacks(address, SCAN_TIMEOUT_CALLBACK); } stopScan("Scan failure"); releaseWakeLock(); }