V4.2.4a - check for null gatt characteristic before writing - should fix #158
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:versionCode="137"
|
||||
android:versionName="4.2.3">
|
||||
android:versionCode="138"
|
||||
android:versionName="4.2.4a">
|
||||
<!-- android:allowBackup="false" -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
|
||||
@@ -392,18 +392,22 @@ public class SdDataSourceBLE extends SdDataSource {
|
||||
* @param nBytes - number of bytes to send.
|
||||
*/
|
||||
private void executeWriteCharacteristic(BluetoothGattCharacteristic gattCharacteristic, byte[] valBytes) {
|
||||
gattCharacteristic.setValue(valBytes);
|
||||
boolean retVal = mBluetoothGatt.writeCharacteristic(gattCharacteristic);
|
||||
if (retVal) {
|
||||
Log.d(TAG, "executeWriteCharacteristic - write initiated successfully");
|
||||
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);
|
||||
}
|
||||
} 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);
|
||||
Log.i(TAG,"ExecuteWriteCharacteristic() - gatCharacteristic is null, so not doing anything");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user