Skip to content

Commit

Permalink
Merge pull request #441 from NordicSemiconductor/reliable-write-fix
Browse files Browse the repository at this point in the history
Don't verify write without response operations
  • Loading branch information
philips77 committed Nov 28, 2022
2 parents 1484b15 + 5af46f7 commit acddd16
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ble/src/main/java/no/nordicsemi/android/ble/WriteRequest.java
Expand Up @@ -275,7 +275,7 @@ boolean notifyPacketSent(@NonNull final BluetoothDevice device, @Nullable final
handler.post(() -> {
if (progressCallback != null) {
try {
progressCallback.onPacketSent(device, data, count);
progressCallback.onPacketSent(device, currentChunk, count);
} catch (final Throwable t) {
Log.e(TAG, "Exception in Progress callback", t);
}
Expand All @@ -293,7 +293,13 @@ boolean notifyPacketSent(@NonNull final BluetoothDevice device, @Nullable final
}
});
}
return Arrays.equals(data, currentChunk);
if (writeType == BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT) {
// Compare the data received with the data sent.
return Arrays.equals(data, currentChunk);
} else {
// Don't check the data when using Write Without Response.
return true;
}
}

/**
Expand Down

0 comments on commit acddd16

Please sign in to comment.