Skip to content

Commit f23409c

Browse files
committed
Fixed issue related to Android 7 and old version of firefly vaporizer.
1 parent 7d68a5d commit f23409c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

dfu/src/main/java/no/nordicsemi/android/dfu/BaseCustomDfuImpl.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,14 @@ public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattC
141141
buffer = new byte[available];
142142
final int size = mFirmwareStream.read(buffer);
143143
writePacket(gatt, characteristic, buffer, size);
144-
Thread.sleep(10); /* Hotfix. Fixed issue related to Android 7 and
145-
old version of firefly vaporizer */
146144
return;
147145
} catch (final HexFileValidationException e) {
148146
loge("Invalid HEX file");
149147
mError = DfuBaseService.ERROR_FILE_INVALID;
150148
} catch (final IOException e) {
151149
loge("Error while reading the input stream", e);
152150
mError = DfuBaseService.ERROR_FILE_IO_EXCEPTION;
153-
} catch (InterruptedException e) {
154-
loge("Sleep was interrupted after writing a packet",e);
155-
}
151+
}
156152
} else {
157153
onPacketCharacteristicWrite(gatt, characteristic, status);
158154
}
@@ -395,6 +391,14 @@ private void writePacket(final BluetoothGatt gatt, final BluetoothGattCharacteri
395391
characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
396392
characteristic.setValue(locBuffer);
397393
gatt.writeCharacteristic(characteristic);
394+
395+
// Hotfix. Fixed issue related to Android 7 (Nexus 5x) and old version of firefly vaporizer.
396+
try {
397+
Thread.sleep(10);
398+
} catch (InterruptedException e) {
399+
loge("Sleep was interrupted after writing a packet",e);
400+
}
401+
398402
// FIXME BLE buffer overflow
399403
// after writing to the device with WRITE_NO_RESPONSE property the onCharacteristicWrite callback is received immediately after writing data to a buffer.
400404
// The real sending is much slower than adding to the buffer. This method does not return false if writing didn't succeed.. just the callback is not invoked.

0 commit comments

Comments
 (0)