/** * Returns <code>true</code> if the device is connected to the sensor. * @param device the target device * @return <code>true</code> if device is connected to the sensor, <code>false</code> otherwise */ public final boolean isConnected(final BluetoothDevice device) { final BleManager<BleManagerCallbacks> manager = mBleManagers.get(device); return manager != null && manager.isConnected(); }
/** * Returns <code>true</code> if the device is connected to the sensor. * @param device the target device * @return <code>true</code> if device is connected to the sensor, <code>false</code> otherwise */ protected boolean isConnected(final BluetoothDevice device) { final BleManager<BleManagerCallbacks> manager = mBleManagers.get(device); return manager != null && manager.isConnected(); } }
/** * Disconnects the given device and removes the associated BleManager object. * If the list of BleManagers is empty while the last activity unbinds from the service, * the service will stop itself. * @param device target device to disconnect and forget */ public void disconnect(final BluetoothDevice device) { final BleManager<BleManagerCallbacks> manager = mBleManagers.get(device); if (manager != null && manager.isConnected()) { manager.disconnect().enqueue(); } mManagedDevices.remove(device); }
/** * This method is called when Bluetooth Adapter has been enabled. It is also called * after the service was created if Bluetooth Adapter was enabled at that moment. * This method could initialize all Bluetooth related features, for example open the GATT server. * Make sure you call <code>super.onBluetoothEnabled()</code> at this methods reconnects to * devices that were connected before the Bluetooth was turned off. */ protected void onBluetoothEnabled() { for (final BluetoothDevice device : mManagedDevices) { final BleManager<BleManagerCallbacks> manager = mBleManagers.get(device); if (!manager.isConnected()) manager.connect(device).enqueue(); } }