Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't log written data, as they may not be up-to-date #440

Merged
merged 1 commit into from Nov 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2334,17 +2334,18 @@ public void onCharacteristicRead(@NonNull final BluetoothGatt gatt,
public void onCharacteristicWrite(final BluetoothGatt gatt,
final BluetoothGattCharacteristic characteristic,
final int status) {
final byte[] data = characteristic.getValue();

if (status == BluetoothGatt.GATT_SUCCESS) {
log(Log.INFO, () ->
"Data written to " + characteristic.getUuid() +
", value: " + ParserUtils.parse(data));
// When writing without response, the characteristic value is not updated on Android 13+.
// The data written was logged out when the request was executed.
log(Log.INFO, () -> "Data written to " + characteristic.getUuid());

BleManagerHandler.this.onCharacteristicWrite(gatt, characteristic);
if (request instanceof WriteRequest) {
final WriteRequest wr = (WriteRequest) request;
final boolean valid = wr.notifyPacketSent(gatt.getDevice(), data);
// Notify the listeners about the packet being sent.
// This method also compares the data written with the data received in the callback
// if the write type is WRITE_TYPE_DEFAULT.
final boolean valid = wr.notifyPacketSent(gatt.getDevice(), characteristic.getValue());
if (!valid && requestQueue instanceof ReliableWriteRequest) {
wr.notifyFail(gatt.getDevice(), FailCallback.REASON_VALIDATION);
requestQueue.cancelQueue();
Expand Down Expand Up @@ -2451,8 +2452,7 @@ public void onDescriptorWrite(final BluetoothGatt gatt,
final byte[] data = descriptor.getValue();

if (status == BluetoothGatt.GATT_SUCCESS) {
log(Log.INFO, () -> "Data written to descr. " + descriptor.getUuid() +
", value: " + ParserUtils.parse(data));
log(Log.INFO, () -> "Data written to descr. " + descriptor.getUuid());

if (isServiceChangedCCCD(descriptor)) {
log(Log.INFO, () -> "Service Changed notifications enabled");
Expand Down