Added check that characteristic is not null before reading it. Displays warning on Logcat if it is null rather than crashing.

This commit is contained in:
Graham Jones
2024-03-25 22:56:56 +00:00
parent cff9d4567c
commit fb59ec6db6
2 changed files with 15 additions and 11 deletions

View File

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

View File

@@ -368,6 +368,7 @@ 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");
@@ -380,6 +381,9 @@ public class SdDataSourceBLE extends SdDataSource {
}
}, 100);
}
} else {
Log.i(TAG,"ExecuteReadCharacteristic() - gatCharacteristic is null, so not doing anything");
}
}
/**