diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManager.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManager.java index 40364ae0..37d24935 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManager.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManager.java @@ -51,6 +51,10 @@ import no.nordicsemi.android.nrftoolbox.utility.DebugLogger; import no.nordicsemi.android.nrftoolbox.utility.ParserUtils; /** + * DO NOT EDIT THIS FILE UNLESS NECESSARY! + * The BleManager should be overridden in your app and all the 'high level' callbacks should be called from there. + * Keeping this file as is (and {@link BleManagerCallbacks} as well) will allow to quickly update it when an update is posted here. + * *

The BleManager is responsible for managing the low level communication with a Bluetooth Smart device. Please see profiles implementation for an example of use. * This base manager has been tested against number of devices and samples from Nordic SDK.

*

The manager handles connection events and initializes the device after establishing the connection. @@ -1191,6 +1195,7 @@ public abstract class BleManager implements ILogg mOperationInProgress = true; // no more calls are possible mInitQueue = null; mTaskQueue.clear(); + final boolean wasConnected = mConnected; if (mConnected) { notifyDeviceDisconnected(gatt.getDevice()); // This sets the mConnected flag to false } @@ -1199,11 +1204,13 @@ public abstract class BleManager implements ILogg if (mInitialConnection) { connect(gatt.getDevice()); } - return; - } - // TODO Should the disconnect method be called or the connection is still valid? Does this ever happen? - Logger.e(mLogSession, "Error (0x" + Integer.toHexString(status) + "): " + GattError.parseConnectionError(status)); + if (wasConnected || status == BluetoothGatt.GATT_SUCCESS) + return; + } else { + if (status != BluetoothGatt.GATT_SUCCESS) + Logger.e(mLogSession, "Error (0x" + Integer.toHexString(status) + "): " + GattError.parseConnectionError(status)); + } mCallbacks.onError(gatt.getDevice(), ERROR_CONNECTION_STATE_CHANGE, status); } } diff --git a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManagerCallbacks.java b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManagerCallbacks.java index 6ba0a8fb..ea67f998 100644 --- a/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManagerCallbacks.java +++ b/app/src/main/java/no/nordicsemi/android/nrftoolbox/profile/BleManagerCallbacks.java @@ -25,6 +25,12 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCallback; +/** + * DO NOT EDIT THIS FILE UNLESS NECESSARY! + * The BleManagerCallbacks should be overridden in your app and all the 'high level' callbacks should be added there. + * Keeping this file as is (and {@link BleManager} as well) will allow to quickly update it when an update is posted here. + * @see no.nordicsemi.android.nrftoolbox.rsc.RSCManagerCallbacks + */ public interface BleManagerCallbacks { /**