diff --git a/CHANGELOG.md b/CHANGELOG.md index 24f8292..8905669 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ OpenSeizureDetector Android App - Change Log ============================================ + V4.2.4 - Added checks and a FAULT condition for Bluetooth errors in Bluetooth Data Source V4.2.3 - Uses 3d accelerometer data to calculate magnitude if vector magnitude is not sent from data source. - fixed latched alarms (Issue #146) - fixed HR alarms selection issue (#153) diff --git a/app/release/app-release-4.2.3.apk b/app/release/app-release-4.2.4.apk similarity index 84% rename from app/release/app-release-4.2.3.apk rename to app/release/app-release-4.2.4.apk index 12820d5..c7e8299 100644 Binary files a/app/release/app-release-4.2.3.apk and b/app/release/app-release-4.2.4.apk differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8d42d03..f38b9e6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:versionName="4.2.4"> diff --git a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE.java b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE.java index 61c61c0..4c07aa7 100644 --- a/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE.java +++ b/app/src/main/java/uk/org/openseizuredetector/SdDataSourceBLE.java @@ -368,21 +368,31 @@ public class SdDataSourceBLE extends SdDataSource { * @param gattCharacteristic - the characteristic to be read. */ private void executeReadCharacteristic(BluetoothGattCharacteristic gattCharacteristic) { - if (gattCharacteristic != null) { - boolean retVal = mBluetoothGatt.readCharacteristic(gattCharacteristic); - if (retVal) { - Log.d(TAG, "executeReadCharacteristic - read initiated successfully"); - } else { - Log.d(TAG, "executeReadCharacteristic - read initiation failed - waiting, then re-trying"); - mHandler.postDelayed(new Runnable() { - public void run() { - Log.w(TAG, "Executing delayed read of characteristic"); - executeReadCharacteristic(gattCharacteristic); - } - }, 100); - } + if (gattCharacteristic == null) { + Log.i(TAG, "ExecuteReadCharacteristic() - gatCharacteristic is null, so not doing anything"); + mUtil.showToast("ERROR: gatCharacteristic is null - this should not happen"); + mSdDataReceiver.onSdDataFault(mSdData); + return; + } + if (mBluetoothGatt == null) { + Log.e(TAG, "executeReadCharacteristic() - mBluetoothGatt is null - Characteristic=" + gattCharacteristic.getUuid().toString()); + mUtil.showToast("ERROR: mGatCharacteristic is null - this should not happen"); + mSdDataReceiver.onSdDataFault(mSdData); + return; + } + + // To get here both gatCharacteristic and mBluetoothGatt must be non-null + boolean retVal = mBluetoothGatt.readCharacteristic(gattCharacteristic); + if (retVal) { + Log.d(TAG, "executeReadCharacteristic - read initiated successfully"); } else { - Log.i(TAG,"ExecuteReadCharacteristic() - gatCharacteristic is null, so not doing anything"); + Log.d(TAG, "executeReadCharacteristic - read initiation failed - waiting, then re-trying"); + mHandler.postDelayed(new Runnable() { + public void run() { + Log.w(TAG, "Executing delayed read of characteristic"); + executeReadCharacteristic(gattCharacteristic); + } + }, 100); } } @@ -391,27 +401,38 @@ public class SdDataSourceBLE extends SdDataSource { * of a given characteristic. * Because only one BLE operation can be taking place at a time, it may fail, in which case * the read is re-tried after a 100ms delay. + * * @param gattCharacteristic - the characteristic to be read. - * @param valBytes[] - array of bytes to send - * @param nBytes - number of bytes to send. + * @param valBytes[] - array of bytes to send + * @param nBytes - number of bytes to send. */ private void executeWriteCharacteristic(BluetoothGattCharacteristic gattCharacteristic, byte[] valBytes) { - if (gattCharacteristic != null) { - gattCharacteristic.setValue(valBytes); - boolean retVal = mBluetoothGatt.writeCharacteristic(gattCharacteristic); - if (retVal) { - Log.d(TAG, "executeWriteCharacteristic - write initiated successfully"); - } else { - Log.d(TAG, "executeWriteCharacteristic - write initiation failed - waiting, then re-trying"); - mHandler.postDelayed(new Runnable() { - public void run() { - Log.w(TAG, "Executing delayed write of characteristic"); - executeWriteCharacteristic(gattCharacteristic, valBytes); - } - }, 100); - } + if (gattCharacteristic == null) { + Log.i(TAG, "ExecuteWriteCharacteristic() - gatCharacteristic is null, so not doing anything"); + mUtil.showToast("ERROR: gatCharacteristic is null - this should not happen"); + mSdDataReceiver.onSdDataFault(mSdData); + return; + } + if (mBluetoothGatt == null) { + Log.e(TAG, "executeWriteCharacteristic() - mBluetoothGatt is null - Characteristic=" + gattCharacteristic.getUuid().toString()); + mUtil.showToast("ERROR: mGatCharacteristic is null - this should not happen"); + mSdDataReceiver.onSdDataFault(mSdData); + return; + } + + // To get here both gatCharacteristic and mBluetoothGatt must be non-null + gattCharacteristic.setValue(valBytes); + boolean retVal = mBluetoothGatt.writeCharacteristic(gattCharacteristic); + if (retVal) { + Log.d(TAG, "executeWriteCharacteristic - write initiated successfully"); } else { - Log.i(TAG,"ExecuteWriteCharacteristic() - gatCharacteristic is null, so not doing anything"); + Log.d(TAG, "executeWriteCharacteristic - write initiation failed - waiting, then re-trying"); + mHandler.postDelayed(new Runnable() { + public void run() { + Log.w(TAG, "Executing delayed write of characteristic"); + executeWriteCharacteristic(gattCharacteristic, valBytes); + } + }, 100); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d41503d..23b3930 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,8 +2,9 @@ OpenSeizureDetector - "\n - \nV4.2.1 - Added support for PineTime Watches using Bluetooth data source. + "\nV4.2.4 - Fault alarm rather than crash if bluetooth system crashes. + \nV4.2.3 - Bug Fixes (heart rate alarm and latched alarm issues) + \nV4.2 - Added support for PineTime Watches using Bluetooth data source. \n - Added new, swipeable user interface to simplify the main screen.. "