diff options
author | Sven Gothel <[email protected]> | 2020-07-27 07:33:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-07-27 07:33:47 +0200 |
commit | 5a660fe04c5ddaa68a49ddfb50a2bc562fc390a8 (patch) | |
tree | 4af24e8e430267ce43e0a0d6abcfe12ff12492e5 /java | |
parent | 6e71e6e8fcf1a075d2b14ce5b2f18081cb436abd (diff) |
DBTManager.getServices(): Simplify gathering services, dropping manual connect.
Diffstat (limited to 'java')
-rw-r--r-- | java/direct_bt/tinyb/DBTManager.java | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/java/direct_bt/tinyb/DBTManager.java b/java/direct_bt/tinyb/DBTManager.java index d4dcd70f..6874da74 100644 --- a/java/direct_bt/tinyb/DBTManager.java +++ b/java/direct_bt/tinyb/DBTManager.java @@ -213,21 +213,16 @@ public class DBTManager implements BluetoothManager /** * {@inheritDoc} * <p> - * This call is a quite expensive service query, see below. + * This call could be a quite expensive service query, see below. * </p> * <p> - * This implementation only fetches all {@link BluetoothGattService} from all {@link BluetoothDevice}s - * from the {@link #getDefaultAdapter()}. + * This implementation returns all {@link BluetoothGattService} from all {@link BluetoothDevice}s + * from the {@link #getDefaultAdapter()} using {@link BluetoothDevice#getServices()}. * </p> * <p> * This implementation does not {@link BluetoothAdapter#startDiscovery() start} an explicit discovery, * but previous {@link BluetoothAdapter#getDevices() discovered devices} are being queried. * </p> - * <p> - * In case a {@link BluetoothDevice} hasn't detected any service yet, - * i.e. {@link BluetoothDevice#getServicesResolved()} and {@link BluetoothDevice#getConnected()} is false, - * a new {@link BluetoothDevice#connect() connect/disconnect} cycle is performed. - * </p> */ @Override public List<BluetoothGattService> getServices() { @@ -237,16 +232,10 @@ public class DBTManager implements BluetoothManager final List<BluetoothDevice> devices = adapter.getDevices(); for(final Iterator<BluetoothDevice> iterD=devices.iterator(); iterD.hasNext(); ) { final BluetoothDevice device = iterD.next(); - if( !device.getServicesResolved() && !device.getConnected() ) { - if( device.connect() ) { - if( !device.getServicesResolved() ) { - throw new InternalError("Device connected but services not resolved"); - } - device.disconnect(); - } - } final List<BluetoothGattService> devServices = device.getServices(); - res.addAll(devServices); + if( null != devServices ) { + res.addAll(devServices); + } } } return res; |