@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { if (intent == null || !intent.hasExtra(EXTRA_DEVICE_ADDRESS)) throw new UnsupportedOperationException("No device address at EXTRA_DEVICE_ADDRESS key"); final Uri logUri = intent.getParcelableExtra(EXTRA_LOG_URI); mLogSession = Logger.openSession(getApplicationContext(), logUri); mDeviceName = intent.getStringExtra(EXTRA_DEVICE_NAME); Logger.i(mLogSession, "Service started"); final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); final String deviceAddress = intent.getStringExtra(EXTRA_DEVICE_ADDRESS); mBluetoothDevice = adapter.getRemoteDevice(deviceAddress); mBleManager.setLogger(mLogSession); onServiceStarted(); mBleManager.connect(mBluetoothDevice) .useAutoConnect(shouldAutoConnect()) .retry(3, 100) .enqueue(); return START_REDELIVER_INTENT; }
@Override public void onDeviceSelected(final BluetoothDevice device, final String name) { final int titleId = getLoggerProfileTitle(); if (titleId > 0) { mLogSession = Logger.newSession(getApplicationContext(), getString(titleId), device.getAddress(), name); // If nRF Logger is not installed we may want to use local logger if (mLogSession == null && getLocalAuthorityLogger() != null) { mLogSession = LocalLogSession.newSession(getApplicationContext(), getLocalAuthorityLogger(), device.getAddress(), name); } } mDeviceName = name; mBleManager.setLogger(mLogSession); mBleManager.connect(device) .useAutoConnect(shouldAutoConnect()) .retry(3, 100) .enqueue(); }
@Override public void onDeviceSelected(final BluetoothDevice device, final String name) { final int titleId = getLoggerProfileTitle(); if (titleId > 0) { mLogSession = Logger.newSession(getApplicationContext(), getString(titleId), device.getAddress(), name); // If nRF Logger is not installed we may want to use local logger if (mLogSession == null && getLocalAuthorityLogger() != null) { mLogSession = LocalLogSession.newSession(getApplicationContext(), getLocalAuthorityLogger(), device.getAddress(), name); } } mDeviceName = name; mBleManager.setLogger(mLogSession); mBleManager.connect(device) .useAutoConnect(shouldAutoConnect()) .retry(3, 100) .enqueue(); }