From 5f48dd91a96732a70b56381c1f1c9f714e85c852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Urban?= Date: Fri, 17 Nov 2017 12:23:28 +0100 Subject: [PATCH] [#319] Added possibility to change default operation timeout. (#321) * Finished migration to gradle 3.0. * Bumped version to 1.5.0 [#319] Added possibility to change default operation timeout. * Replaced ConnectionSetup API with a overloaded method. * Finished migration to gradle 3.0. * Added missing method to a mock. * Fixed test. * Applied code review requests. --- gradle.properties | 2 +- .../mockrxandroidble/RxBleDeviceMock.java | 6 +++ .../{internal => }/ConnectionSetup.java | 31 ++++++++++++++-- .../com/polidea/rxandroidble/RxBleDevice.java | 37 +++++++++++++++++++ .../com/polidea/rxandroidble/Timeout.java | 14 +++++++ .../rxandroidble/internal/DeviceModule.java | 6 --- .../internal/RxBleDeviceImpl.java | 13 ++++++- .../internal/connection/ConnectionModule.java | 27 +++++++++++--- .../internal/connection/Connector.java | 2 +- .../internal/connection/ConnectorImpl.java | 2 +- .../CharacteristicLongWriteOperation.java | 8 ++-- .../CharacteristicReadOperation.java | 4 +- .../CharacteristicWriteOperation.java | 4 +- .../operations/DescriptorReadOperation.java | 4 +- .../operations/DescriptorWriteOperation.java | 4 +- .../operations/OperationsProviderImpl.java | 4 +- .../operations/ReadRssiOperation.java | 4 +- .../internal/RxBleDeviceProviderTest.groovy | 6 +++ .../internal/RxBleDeviceTest.groovy | 1 + .../connection/ConnectorImplTest.groovy | 2 +- 20 files changed, 145 insertions(+), 36 deletions(-) rename rxandroidble/src/main/java/com/polidea/rxandroidble/{internal => }/ConnectionSetup.java (73%) create mode 100644 rxandroidble/src/main/java/com/polidea/rxandroidble/Timeout.java diff --git a/gradle.properties b/gradle.properties index cfc3bf108..b7414d76e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.polidea.rxandroidble -VERSION_NAME=1.4.3 +VERSION_NAME=1.5.0-SNAPSHOT POM_DESCRIPTION=RxJava backed support for Bluetooth Low Energy in Android diff --git a/mockrxandroidble/src/main/java/com/polidea/rxandroidble/mockrxandroidble/RxBleDeviceMock.java b/mockrxandroidble/src/main/java/com/polidea/rxandroidble/mockrxandroidble/RxBleDeviceMock.java index fc301cdf9..fd4983071 100644 --- a/mockrxandroidble/src/main/java/com/polidea/rxandroidble/mockrxandroidble/RxBleDeviceMock.java +++ b/mockrxandroidble/src/main/java/com/polidea/rxandroidble/mockrxandroidble/RxBleDeviceMock.java @@ -6,6 +6,7 @@ import com.polidea.rxandroidble.RxBleConnection; import com.polidea.rxandroidble.RxBleDevice; import com.polidea.rxandroidble.RxBleDeviceServices; +import com.polidea.rxandroidble.Timeout; import com.polidea.rxandroidble.exceptions.BleAlreadyConnectedException; import java.util.ArrayList; @@ -96,6 +97,11 @@ public void call() { }); } + @Override + public Observable establishConnection(boolean autoConnect, Timeout operationTimeout) { + return establishConnection(autoConnect); + } + private Observable emitConnectionWithoutCompleting() { return Observable.never().startWith(rxBleConnection); } diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/ConnectionSetup.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/ConnectionSetup.java similarity index 73% rename from rxandroidble/src/main/java/com/polidea/rxandroidble/internal/ConnectionSetup.java rename to rxandroidble/src/main/java/com/polidea/rxandroidble/ConnectionSetup.java index d10daed91..3cbc6763c 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/ConnectionSetup.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/ConnectionSetup.java @@ -1,13 +1,18 @@ -package com.polidea.rxandroidble.internal; +package com.polidea.rxandroidble; import android.bluetooth.BluetoothGattCallback; import android.content.Context; -import com.polidea.rxandroidble.RxBleDevice; + +import com.polidea.rxandroidble.internal.BleIllegalOperationException; + +import java.util.concurrent.TimeUnit; /** * Container for various connection parameters. */ public class ConnectionSetup { + + public static final int DEFAULT_OPERATION_TIMEOUT = 30; /** * Flag related with * {@link android.bluetooth.BluetoothDevice#connectGatt(Context, boolean, BluetoothGattCallback)} autoConnect flag. @@ -22,16 +27,23 @@ public class ConnectionSetup { * don't match those required by the operation. If set to true, an event will be logged without interrupting the execution. */ public final boolean suppressOperationCheck; + /** + * Timeout in seconds after which the operation will be considered as broken. Eventually the operation will be + * canceled and removed from queue. + */ + public final Timeout operationTimeout; - private ConnectionSetup(boolean autoConnect, boolean suppressOperationCheck) { + private ConnectionSetup(boolean autoConnect, boolean suppressOperationCheck, Timeout operationTimeout) { this.autoConnect = autoConnect; this.suppressOperationCheck = suppressOperationCheck; + this.operationTimeout = operationTimeout; } public static class Builder { private boolean autoConnect = false; private boolean suppressOperationCheck = false; + private Timeout operationTimeout = new Timeout(DEFAULT_OPERATION_TIMEOUT, TimeUnit.SECONDS); /** @@ -64,8 +76,19 @@ public Builder setSuppressIllegalOperationCheck(boolean suppressOperationCheck) return this; } + /** + * @param operationTimeout Timeout after which the operation will be considered as broken. Eventually the operation + * will be canceled and removed from queue. Keep in mind that it will cancel the library's operation + * only and may leave Android's BLE stack in an inconsistent state. + * @return this builder instance + */ + public Builder setOperationTimeout(Timeout operationTimeout) { + this.operationTimeout = operationTimeout; + return this; + } + public ConnectionSetup build() { - return new ConnectionSetup(autoConnect, suppressOperationCheck); + return new ConnectionSetup(autoConnect, suppressOperationCheck, operationTimeout); } } } diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/RxBleDevice.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/RxBleDevice.java index 39ced11e6..b0620ccdb 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/RxBleDevice.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/RxBleDevice.java @@ -3,6 +3,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothGattCallback; import android.content.Context; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import com.polidea.rxandroidble.exceptions.BleDisconnectedException; @@ -86,6 +87,42 @@ public interface RxBleDevice { */ Observable establishConnection(boolean autoConnect); + /** + * Establishes connection with a given BLE device. {@link RxBleConnection} is a handle, used to process BLE operations with a connected + * device. + *

+ * The connection is automatically disconnected (and released) when resulting Observable is unsubscribed. + * On the other hand when the connections is interrupted by the device or the system, the Observable will be unsubscribed as well + * following BleDisconnectedException or BleGattException emission. + *

+ * During the disconnect process the library automatically handles order and requirement of device disconnect and gatt close operations. + *

+ * Autoconnect concept may be misleading at first glance. In cases when the BLE device is available and it is advertising constantly you + * won't need to use autoconnect. Use autoconnect for connections where the BLE device is not advertising at + * the moment of #establishConnection call. + * + * @param autoConnect Flag related to + * {@link android.bluetooth.BluetoothDevice#connectGatt(Context, boolean, BluetoothGattCallback)} + * autoConnect flag. In case of auto connect is enabled the observable will wait with the emission + * of RxBleConnection. Without auto connect flag set to true the connection will fail + * with {@link com.polidea.rxandroidble.exceptions.BleGattException} if the device is not + * in range after a 30 seconds timeout. + * @param operationTimeout Timeout configuration after which the operation will be considered as broken. Eventually the operation + * will be canceled and removed from queue. Keep in mind that it will cancel the library's operation + * only and may leave Android's BLE stack in an inconsistent state. + * @return Observable emitting the connection. + * @throws BleDisconnectedException emitted when the BLE link has been disconnected either when the connection + * was already established or was in pending connection state. This occurs when the + * connection was released as a part of expected behavior + * (with {@link android.bluetooth.BluetoothGatt#GATT_SUCCESS} state). + * @throws BleGattException emitted when the BLE link has been interrupted as a result of an error. + * The exception contains detailed explanation of the error source (type of operation) and + * the code proxied from the Android system. + * @throws BleGattCallbackTimeoutException emitted when an internal timeout for connection has been reached. The operation will + * timeout in direct mode (autoConnect = false) after 35 seconds. + */ + Observable establishConnection(boolean autoConnect, @NonNull Timeout operationTimeout); + /** * Name of the device. Name is optional and it's up to the device vendor if will be provided. * diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/Timeout.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/Timeout.java new file mode 100644 index 000000000..0549d4e34 --- /dev/null +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/Timeout.java @@ -0,0 +1,14 @@ +package com.polidea.rxandroidble; + +import java.util.concurrent.TimeUnit; + +public class Timeout { + + public final TimeUnit timeUnit; + public final long timeout; + + public Timeout(long timeout, TimeUnit timeUnit) { + this.timeUnit = timeUnit; + this.timeout = timeout; + } +} diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/DeviceModule.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/DeviceModule.java index 25a6eb8c2..856249143 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/DeviceModule.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/DeviceModule.java @@ -47,12 +47,6 @@ String provideMacAddress() { return macAddress; } - @Provides - @Named(OPERATION_TIMEOUT) - static TimeoutConfiguration providesOperationTimeoutConf(@Named(NamedSchedulers.TIMEOUT) Scheduler timeoutScheduler) { - return new TimeoutConfiguration(DEFAULT_OPERATION_TIMEOUT, TimeUnit.SECONDS, timeoutScheduler); - } - @Provides @Named(CONNECT_TIMEOUT) static TimeoutConfiguration providesConnectTimeoutConf(@Named(ClientComponent.NamedSchedulers.TIMEOUT) Scheduler timeoutScheduler) { diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/RxBleDeviceImpl.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/RxBleDeviceImpl.java index 5e3897418..e201e8824 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/RxBleDeviceImpl.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/RxBleDeviceImpl.java @@ -5,8 +5,10 @@ import android.support.annotation.Nullable; import com.jakewharton.rxrelay.BehaviorRelay; +import com.polidea.rxandroidble.ConnectionSetup; import com.polidea.rxandroidble.RxBleConnection; import com.polidea.rxandroidble.RxBleDevice; +import com.polidea.rxandroidble.Timeout; import com.polidea.rxandroidble.exceptions.BleAlreadyConnectedException; import com.polidea.rxandroidble.internal.connection.Connector; @@ -62,7 +64,16 @@ public Observable establishConnection(final boolean autoConnect return establishConnection(options); } -// @Override + @Override + public Observable establishConnection(final boolean autoConnect, final Timeout timeout) { + ConnectionSetup options = new ConnectionSetup.Builder() + .setAutoConnect(autoConnect) + .setOperationTimeout(timeout) + .setSuppressIllegalOperationCheck(true) + .build(); + return establishConnection(options); + } + public Observable establishConnection(final ConnectionSetup options) { return Observable.defer(new Func0>() { @Override diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/ConnectionModule.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/ConnectionModule.java index d5083f599..4f781860f 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/ConnectionModule.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/ConnectionModule.java @@ -1,24 +1,34 @@ package com.polidea.rxandroidble.internal.connection; -import static com.polidea.rxandroidble.internal.connection.ConnectionComponent.NamedBooleans.AUTO_CONNECT; - import android.bluetooth.BluetoothGattCharacteristic; -import com.polidea.rxandroidble.internal.ConnectionSetup; + +import com.polidea.rxandroidble.ClientComponent; +import com.polidea.rxandroidble.ConnectionSetup; +import com.polidea.rxandroidble.Timeout; +import com.polidea.rxandroidble.internal.operations.TimeoutConfiguration; import com.polidea.rxandroidble.internal.util.CharacteristicPropertiesParser; -import dagger.Module; -import dagger.Provides; + import javax.inject.Named; import javax.inject.Provider; +import dagger.Module; +import dagger.Provides; +import rx.Scheduler; + +import static com.polidea.rxandroidble.internal.connection.ConnectionComponent.NamedBooleans.AUTO_CONNECT; + @Module public class ConnectionModule { + public static final String OPERATION_TIMEOUT = "operation-timeout"; final boolean autoConnect; final boolean suppressOperationCheck; + private final Timeout operationTimeout; ConnectionModule(ConnectionSetup connectionSetup) { this.autoConnect = connectionSetup.autoConnect; this.suppressOperationCheck = connectionSetup.suppressOperationCheck; + this.operationTimeout = connectionSetup.operationTimeout; } @ConnectionScope @@ -26,6 +36,13 @@ public class ConnectionModule { return autoConnect; } + + @Provides + @Named(OPERATION_TIMEOUT) + TimeoutConfiguration providesOperationTimeoutConf(@Named(ClientComponent.NamedSchedulers.TIMEOUT) Scheduler timeoutScheduler) { + return new TimeoutConfiguration(operationTimeout.timeout, operationTimeout.timeUnit, timeoutScheduler); + } + @Provides IllegalOperationHandler provideIllegalOperationHandler( Provider loggingIllegalOperationHandlerProvider, diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/Connector.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/Connector.java index 6919ccb4a..87de16fea 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/Connector.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/Connector.java @@ -1,7 +1,7 @@ package com.polidea.rxandroidble.internal.connection; -import com.polidea.rxandroidble.internal.ConnectionSetup; +import com.polidea.rxandroidble.ConnectionSetup; import com.polidea.rxandroidble.RxBleConnection; import rx.Observable; diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/ConnectorImpl.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/ConnectorImpl.java index 1acf2c017..3b9ea08b6 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/ConnectorImpl.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/connection/ConnectorImpl.java @@ -4,7 +4,7 @@ import com.polidea.rxandroidble.ClientComponent; import com.polidea.rxandroidble.RxBleConnection; -import com.polidea.rxandroidble.internal.ConnectionSetup; +import com.polidea.rxandroidble.ConnectionSetup; import com.polidea.rxandroidble.internal.serialization.ClientOperationQueue; import java.util.Set; diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicLongWriteOperation.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicLongWriteOperation.java index a50fd1461..5de8b7dc7 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicLongWriteOperation.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicLongWriteOperation.java @@ -13,14 +13,14 @@ import com.polidea.rxandroidble.exceptions.BleGattCallbackTimeoutException; import com.polidea.rxandroidble.exceptions.BleGattCannotStartException; import com.polidea.rxandroidble.exceptions.BleGattOperationType; -import com.polidea.rxandroidble.internal.DeviceModule; -import com.polidea.rxandroidble.internal.serialization.QueueReleaseInterface; import com.polidea.rxandroidble.internal.QueueOperation; +import com.polidea.rxandroidble.internal.connection.ConnectionModule; import com.polidea.rxandroidble.internal.connection.PayloadSizeLimitProvider; import com.polidea.rxandroidble.internal.connection.RxBleGattCallback; +import com.polidea.rxandroidble.internal.serialization.QueueReleaseInterface; import com.polidea.rxandroidble.internal.util.ByteAssociation; - import com.polidea.rxandroidble.internal.util.QueueReleasingEmitterWrapper; + import java.nio.ByteBuffer; import java.util.UUID; @@ -50,7 +50,7 @@ public class CharacteristicLongWriteOperation extends QueueOperation { BluetoothGatt bluetoothGatt, RxBleGattCallback rxBleGattCallback, @Named(ClientComponent.NamedSchedulers.BLUETOOTH_INTERACTION) Scheduler bluetoothInteractionScheduler, - @Named(DeviceModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration, + @Named(ConnectionModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration, BluetoothGattCharacteristic bluetoothGattCharacteristic, PayloadSizeLimitProvider batchSizeProvider, WriteOperationAckStrategy writeOperationAckStrategy, diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicReadOperation.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicReadOperation.java index 61e29c74b..12c41ee98 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicReadOperation.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicReadOperation.java @@ -4,8 +4,8 @@ import android.bluetooth.BluetoothGattCharacteristic; import com.polidea.rxandroidble.exceptions.BleGattOperationType; -import com.polidea.rxandroidble.internal.DeviceModule; import com.polidea.rxandroidble.internal.SingleResponseOperation; +import com.polidea.rxandroidble.internal.connection.ConnectionModule; import com.polidea.rxandroidble.internal.connection.RxBleGattCallback; import com.polidea.rxandroidble.internal.util.ByteAssociation; @@ -21,7 +21,7 @@ public class CharacteristicReadOperation extends SingleResponseOperation private final BluetoothGattCharacteristic bluetoothGattCharacteristic; CharacteristicReadOperation(RxBleGattCallback rxBleGattCallback, BluetoothGatt bluetoothGatt, - @Named(DeviceModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration, + @Named(ConnectionModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration, BluetoothGattCharacteristic bluetoothGattCharacteristic) { super(bluetoothGatt, rxBleGattCallback, BleGattOperationType.CHARACTERISTIC_READ, timeoutConfiguration); this.bluetoothGattCharacteristic = bluetoothGattCharacteristic; diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicWriteOperation.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicWriteOperation.java index b373c69bd..3aa34100c 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicWriteOperation.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/CharacteristicWriteOperation.java @@ -4,8 +4,8 @@ import android.bluetooth.BluetoothGattCharacteristic; import com.polidea.rxandroidble.exceptions.BleGattOperationType; -import com.polidea.rxandroidble.internal.DeviceModule; import com.polidea.rxandroidble.internal.SingleResponseOperation; +import com.polidea.rxandroidble.internal.connection.ConnectionModule; import com.polidea.rxandroidble.internal.connection.RxBleGattCallback; import com.polidea.rxandroidble.internal.util.ByteAssociation; @@ -22,7 +22,7 @@ public class CharacteristicWriteOperation extends SingleResponseOperation { DescriptorWriteOperation(RxBleGattCallback rxBleGattCallback, BluetoothGatt bluetoothGatt, - @Named(DeviceModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration, + @Named(ConnectionModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration, int bluetoothGattCharacteristicDefaultWriteType, BluetoothGattDescriptor bluetoothGattDescriptor, byte[] data) { diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/OperationsProviderImpl.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/OperationsProviderImpl.java index bdbeb64a9..fa16d6f9a 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/OperationsProviderImpl.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/OperationsProviderImpl.java @@ -8,7 +8,7 @@ import com.polidea.rxandroidble.ClientComponent; import com.polidea.rxandroidble.RxBleConnection; -import com.polidea.rxandroidble.internal.DeviceModule; +import com.polidea.rxandroidble.internal.connection.ConnectionModule; import com.polidea.rxandroidble.internal.connection.PayloadSizeLimitProvider; import com.polidea.rxandroidble.internal.connection.RxBleGattCallback; @@ -33,7 +33,7 @@ public class OperationsProviderImpl implements OperationsProvider { OperationsProviderImpl( RxBleGattCallback rxBleGattCallback, BluetoothGatt bluetoothGatt, - @Named(DeviceModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration, + @Named(ConnectionModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration, @Named(ClientComponent.NamedSchedulers.BLUETOOTH_INTERACTION) Scheduler bluetoothInteractionScheduler, @Named(ClientComponent.NamedSchedulers.TIMEOUT) Scheduler timeoutScheduler, Provider rssiReadOperationProvider) { diff --git a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/ReadRssiOperation.java b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/ReadRssiOperation.java index 7dbe3faa0..e0948965c 100644 --- a/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/ReadRssiOperation.java +++ b/rxandroidble/src/main/java/com/polidea/rxandroidble/internal/operations/ReadRssiOperation.java @@ -3,8 +3,8 @@ import android.bluetooth.BluetoothGatt; import com.polidea.rxandroidble.exceptions.BleGattOperationType; -import com.polidea.rxandroidble.internal.DeviceModule; import com.polidea.rxandroidble.internal.SingleResponseOperation; +import com.polidea.rxandroidble.internal.connection.ConnectionModule; import com.polidea.rxandroidble.internal.connection.RxBleGattCallback; import javax.inject.Inject; @@ -16,7 +16,7 @@ public class ReadRssiOperation extends SingleResponseOperation { @Inject ReadRssiOperation(RxBleGattCallback bleGattCallback, BluetoothGatt bluetoothGatt, - @Named(DeviceModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration) { + @Named(ConnectionModule.OPERATION_TIMEOUT) TimeoutConfiguration timeoutConfiguration) { super(bluetoothGatt, bleGattCallback, BleGattOperationType.READ_RSSI, timeoutConfiguration); } diff --git a/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/RxBleDeviceProviderTest.groovy b/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/RxBleDeviceProviderTest.groovy index 0c061828d..0671c7e29 100644 --- a/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/RxBleDeviceProviderTest.groovy +++ b/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/RxBleDeviceProviderTest.groovy @@ -2,8 +2,10 @@ package com.polidea.rxandroidble.internal import android.bluetooth.BluetoothDevice import android.content.Context +import com.polidea.rxandroidble.ConnectionSetup import com.polidea.rxandroidble.RxBleConnection import com.polidea.rxandroidble.RxBleDevice +import com.polidea.rxandroidble.Timeout import com.polidea.rxandroidble.internal.cache.DeviceComponentCache import rx.Observable import spock.lang.Specification @@ -41,6 +43,10 @@ class RxBleDeviceProviderTest extends Specification { throw UnsupportedOperationException() } + @Override + Observable establishConnection(boolean autoConnect, Timeout operationTimeoutSetup) { + establishConnection(autoConnect) + } // @Override Observable establishConnection(ConnectionSetup options) { throw UnsupportedOperationException() diff --git a/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/RxBleDeviceTest.groovy b/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/RxBleDeviceTest.groovy index 35834bab8..b08395c51 100644 --- a/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/RxBleDeviceTest.groovy +++ b/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/RxBleDeviceTest.groovy @@ -3,6 +3,7 @@ package com.polidea.rxandroidble.internal import android.bluetooth.BluetoothDevice import android.bluetooth.BluetoothGatt import com.jakewharton.rxrelay.BehaviorRelay +import com.polidea.rxandroidble.ConnectionSetup import com.polidea.rxandroidble.RxBleConnection import com.polidea.rxandroidble.RxBleDevice import com.polidea.rxandroidble.exceptions.BleAlreadyConnectedException diff --git a/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/connection/ConnectorImplTest.groovy b/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/connection/ConnectorImplTest.groovy index 62f3de2e7..c70c476f9 100644 --- a/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/connection/ConnectorImplTest.groovy +++ b/rxandroidble/src/test/groovy/com/polidea/rxandroidble/internal/connection/ConnectorImplTest.groovy @@ -1,7 +1,7 @@ package com.polidea.rxandroidble.internal.connection import android.bluetooth.BluetoothGatt -import com.polidea.rxandroidble.internal.ConnectionSetup +import com.polidea.rxandroidble.ConnectionSetup import com.polidea.rxandroidble.RxBleConnection import com.polidea.rxandroidble.internal.serialization.ClientOperationQueue