V4.2.4a - check for null gatt characteristic before writing - should fix #158

This commit is contained in:
Graham Jones
2024-03-24 22:16:13 +00:00
parent 340b82ad1b
commit cff9d4567c
2 changed files with 17 additions and 13 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<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="137" android:versionCode="138"
android:versionName="4.2.3"> android:versionName="4.2.4a">
<!-- 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

@@ -392,6 +392,7 @@ public class SdDataSourceBLE extends SdDataSource {
* @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) {
gattCharacteristic.setValue(valBytes); gattCharacteristic.setValue(valBytes);
boolean retVal = mBluetoothGatt.writeCharacteristic(gattCharacteristic); boolean retVal = mBluetoothGatt.writeCharacteristic(gattCharacteristic);
if (retVal) { if (retVal) {
@@ -405,6 +406,9 @@ public class SdDataSourceBLE extends SdDataSource {
} }
}, 100); }, 100);
} }
} else {
Log.i(TAG,"ExecuteWriteCharacteristic() - gatCharacteristic is null, so not doing anything");
}
} }