V4.2.4 - fault rather than crash if bluetooth system crashes.

This commit is contained in:
Graham Jones
2024-03-26 21:12:13 +00:00
parent fb59ec6db6
commit ba9b092147
5 changed files with 57 additions and 34 deletions

View File

@@ -1,6 +1,7 @@
OpenSeizureDetector Android App - Change Log 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. 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 latched alarms (Issue #146)
- fixed HR alarms selection issue (#153) - fixed HR alarms selection issue (#153)

View File

@@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:versionCode="138" android:versionCode="138"
android:versionName="4.2.4b"> android:versionName="4.2.4">
<!-- android:allowBackup="false" --> <!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

View File

@@ -368,7 +368,20 @@ public class SdDataSourceBLE extends SdDataSource {
* @param gattCharacteristic - the characteristic to be read. * @param gattCharacteristic - the characteristic to be read.
*/ */
private void executeReadCharacteristic(BluetoothGattCharacteristic gattCharacteristic) { private void executeReadCharacteristic(BluetoothGattCharacteristic gattCharacteristic) {
if (gattCharacteristic != null) { 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); boolean retVal = mBluetoothGatt.readCharacteristic(gattCharacteristic);
if (retVal) { if (retVal) {
Log.d(TAG, "executeReadCharacteristic - read initiated successfully"); Log.d(TAG, "executeReadCharacteristic - read initiated successfully");
@@ -381,9 +394,6 @@ public class SdDataSourceBLE extends SdDataSource {
} }
}, 100); }, 100);
} }
} else {
Log.i(TAG,"ExecuteReadCharacteristic() - gatCharacteristic is null, so not doing anything");
}
} }
/** /**
@@ -391,12 +401,26 @@ public class SdDataSourceBLE extends SdDataSource {
* of a given characteristic. * of a given characteristic.
* Because only one BLE operation can be taking place at a time, it may fail, in which case * 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. * the read is re-tried after a 100ms delay.
*
* @param gattCharacteristic - the characteristic to be read. * @param gattCharacteristic - the characteristic to be read.
* @param valBytes[] - array of bytes to send * @param valBytes[] - array of bytes to send
* @param nBytes - number of bytes to send. * @param nBytes - number of bytes to send.
*/ */
private void executeWriteCharacteristic(BluetoothGattCharacteristic gattCharacteristic, byte[] valBytes) { private void executeWriteCharacteristic(BluetoothGattCharacteristic gattCharacteristic, byte[] valBytes) {
if (gattCharacteristic != null) { 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); gattCharacteristic.setValue(valBytes);
boolean retVal = mBluetoothGatt.writeCharacteristic(gattCharacteristic); boolean retVal = mBluetoothGatt.writeCharacteristic(gattCharacteristic);
if (retVal) { if (retVal) {
@@ -410,9 +434,6 @@ public class SdDataSourceBLE extends SdDataSource {
} }
}, 100); }, 100);
} }
} else {
Log.i(TAG,"ExecuteWriteCharacteristic() - gatCharacteristic is null, so not doing anything");
}
} }

View File

@@ -2,8 +2,9 @@
<resources> <resources>
<string name="app_name">OpenSeizureDetector</string> <string name="app_name">OpenSeizureDetector</string>
<string name="changelog"> <string name="changelog">
"\n "\nV4.2.4 - Fault alarm rather than crash if bluetooth system crashes.
\nV4.2.1 - Added support for PineTime Watches using Bluetooth data source. \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.. \n - Added new, swipeable user interface to simplify the main screen..
"</string> "</string>
<string name="UpgradeMsg"> <string name="UpgradeMsg">