Bug fixed: #32

This commit is contained in:
Aleksander Nowakowski
2017-06-28 17:12:14 +02:00
parent c0075b400c
commit fe75efa4cd
2 changed files with 17 additions and 4 deletions

View File

@@ -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.
*
* <p>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.</p>
* <p>The manager handles connection events and initializes the device after establishing the connection.
@@ -1191,6 +1195,7 @@ public abstract class BleManager<E extends BleManagerCallbacks> 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<E extends BleManagerCallbacks> 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);
}
}

View File

@@ -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 {
/**