use actual MTU instead of fixed size for TransactionBuilder.writeChunkedData

This commit is contained in:
Thomas Kuehne
2025-07-18 19:56:30 +02:00
committed by José Rebelo
parent ae1d5b1f01
commit 9f168fa350
3 changed files with 3 additions and 6 deletions
@@ -593,9 +593,7 @@ public abstract class AbstractBTLEMultiDeviceSupport extends AbstractBTLEDeviceS
}
/**
* Gets the current MTU, or 0 if unknown
*
* @return the current MTU, 0 if unknown
* Get the current MTU, or the minimum 23 if unknown
*/
public int getMTU(int deviceIdx) {
validateDeviceIndex(deviceIdx);
@@ -529,8 +529,7 @@ public abstract class AbstractBTLESingleDeviceSupport extends AbstractBTLEDevice
}
/**
* Gets the current MTU, or 0 if unknown
* @return the current MTU, 0 if unknown
* Get the current MTU, or the minimum 23 if unknown
*/
public int getMTU() {
return mMTU;
@@ -389,7 +389,7 @@ public class GenericThermalPrinterSupport extends AbstractBTLESingleDeviceSuppor
public void send(String taskname, byte[] command) {
TransactionBuilder builder = createTransactionBuilder(taskname);
builder.writeChunkedData(getCharacteristic(writeCharUUID), command, 123);
builder.writeChunkedData(getCharacteristic(writeCharUUID), command, getMTU() - 3);
builder.queue();
}