public synchronized void scan() { if (scanMeister == null) { scanMeister = new ScanMeister(); } else { scanMeister.stop(); } // TODO expand this list scanMeister .setName("Lefun") .setName("F3") .setName("W3") .addCallBack(this, TAG).scan(); }
private void stopScanWithTimeoutCallback() { stopScan("Stop with Timeout"); processCallBacks(address, SCAN_TIMEOUT_CALLBACK); }
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(); }
if (useScanning()) { status("Scanning" + (Home.get_engineering_mode() ? ": " + deviceAddress : "")); scanMeister.setAddress(deviceAddress).addCallBack(this, TAG).scan(); } else { status("Connecting" + (Home.get_engineering_mode() ? ": " + deviceAddress : ""));
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); }
@Override public void onCreate() { if (scanMeister == null) { scanMeister = new ScanMeister() .addCallBack(this, TAG); } foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this); foregroundServiceStarter.start(); //mContext = getApplicationContext(); dexCollectionService = this; prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(); //bgToSpeech = BgToSpeech.setupTTS(mContext); //keep reference to not being garbage collected if (CollectionServiceStarter.isDexBridgeOrWifiandDexBridge()) { Log.i(TAG, "onCreate: resetting bridge_battery preference to 0"); prefs.edit().putInt("bridge_battery", 0).apply(); //if (Home.get_master()) GcmActivity.sendBridgeBattery(prefs.getInt("bridge_battery",-1)); } cloner.dontClone( android.bluetooth.BluetoothDevice.class, android.bluetooth.BluetoothGattService.class ); final IntentFilter pairingRequestFilter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST); pairingRequestFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1); registerReceiver(mPairingRequestRecevier, pairingRequestFilter); Log.i(TAG, "onCreate: STARTING SERVICE: pin code: " + DEFAULT_BT_PIN); Blukon.unBondIfBlukonAtInit(); }
scanMeister.removeCallBack(TAG); scanMeister.stop();
public void stop() { stopScan("Scan stop"); }
private synchronized void handleConnectedStateChange() { mConnectionState = STATE_CONNECTED; scanMeister.stop(); if ((servicesDiscovered == DISCOVERED.NULL) || Pref.getBoolean("always_discover_services", true)) { Log.d(TAG, "Requesting to discover services: previous: " + servicesDiscovered);
private void scan_for_device() { status("Scanning"); UserError.Log.d(TAG, "Scanning for device"); scanner.setAddress(address).scan(); }
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(); }
if (useScanning()) { status("Scanning" + (Home.get_engineering_mode() ? ": " + deviceAddress : "")); scanMeister.setAddress(deviceAddress).addCallBack(this, TAG).scan(); } else { status("Connecting" + (Home.get_engineering_mode() ? ": " + deviceAddress : ""));
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); }
@Override public void onCreate() { if (scanMeister == null) { scanMeister = new ScanMeister() .addCallBack(this, TAG); } foregroundServiceStarter = new ForegroundServiceStarter(getApplicationContext(), this); foregroundServiceStarter.start(); //mContext = getApplicationContext(); dexCollectionService = this; prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); listenForChangeInSettings(); //bgToSpeech = BgToSpeech.setupTTS(mContext); //keep reference to not being garbage collected if (CollectionServiceStarter.isDexBridgeOrWifiandDexBridge()) { Log.i(TAG, "onCreate: resetting bridge_battery preference to 0"); prefs.edit().putInt("bridge_battery", 0).apply(); //if (Home.get_master()) GcmActivity.sendBridgeBattery(prefs.getInt("bridge_battery",-1)); } cloner.dontClone( android.bluetooth.BluetoothDevice.class, android.bluetooth.BluetoothGattService.class ); final IntentFilter pairingRequestFilter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST); pairingRequestFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY - 1); registerReceiver(mPairingRequestRecevier, pairingRequestFilter); Log.i(TAG, "onCreate: STARTING SERVICE: pin code: " + DEFAULT_BT_PIN); Blukon.unBondIfBlukonAtInit(); }
scanMeister.removeCallBack(TAG); scanMeister.stop();
public void stop() { stopScan("Scan stop"); }
private synchronized void handleConnectedStateChange() { mConnectionState = STATE_CONNECTED; scanMeister.stop(); if ((servicesDiscovered == DISCOVERED.NULL) || Pref.getBoolean("always_discover_services", true)) { Log.d(TAG, "Requesting to discover services: previous: " + servicesDiscovered);
private void scan_for_device() { status("Scanning"); UserError.Log.d(TAG, "Scanning for device"); scanner.setAddress(address).scan(); }
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(); }
public synchronized void scan() { if (scanMeister == null) { scanMeister = new ScanMeister(); } else { scanMeister.stop(); } // TODO expand this list scanMeister .setName("Lefun") .setName("F3") .setName("W3") .addCallBack(this, TAG).scan(); }