Printing PHY updates
This commit is contained in:
parent
9092b3be9b
commit
9bd1ecca62
|
@ -168,7 +168,7 @@ import no.nordicsemi.android.dfu.internal.scanner.BootloaderScannerFactory;
|
||||||
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_INFO, "MTU changed to: " + mtu);
|
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_INFO, "MTU changed to: " + mtu);
|
||||||
if (mtu - 3 > mBuffer.length)
|
if (mtu - 3 > mBuffer.length)
|
||||||
mBuffer = new byte[mtu - 3]; // Maximum payload size is MTU - 3 bytes
|
mBuffer = new byte[mtu - 3]; // Maximum payload size is MTU - 3 bytes
|
||||||
logw("MTU changed to: " + mtu);
|
logi("MTU changed to: " + mtu);
|
||||||
} else {
|
} else {
|
||||||
logw("Changing MTU failed: " + status + " (mtu: " + mtu + ")");
|
logw("Changing MTU failed: " + status + " (mtu: " + mtu + ")");
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,16 @@ import no.nordicsemi.android.dfu.internal.scanner.BootloaderScannerFactory;
|
||||||
notifyLock();
|
notifyLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPhyUpdate(final BluetoothGatt gatt, final int txPhy, final int rxPhy, final int status) {
|
||||||
|
if (status == BluetoothGatt.GATT_SUCCESS) {
|
||||||
|
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_INFO, "PHY updated (TX: " + phyToString(txPhy) + ", RX: " + phyToString(rxPhy) + ")");
|
||||||
|
logi("PHY updated (TX: " + phyToString(txPhy) + ", RX: " + phyToString(rxPhy) + ")");
|
||||||
|
} else {
|
||||||
|
logw("Updating PHY failed: " + status + " (txPhy: " + txPhy + ", rxPhy: " + rxPhy + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected String parse(final BluetoothGattCharacteristic characteristic) {
|
protected String parse(final BluetoothGattCharacteristic characteristic) {
|
||||||
return parse(characteristic.getValue());
|
return parse(characteristic.getValue());
|
||||||
}
|
}
|
||||||
|
@ -201,6 +211,19 @@ import no.nordicsemi.android.dfu.internal.scanner.BootloaderScannerFactory;
|
||||||
}
|
}
|
||||||
return new String(out);
|
return new String(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String phyToString(final int phy) {
|
||||||
|
switch (phy) {
|
||||||
|
case BluetoothDevice.PHY_LE_1M:
|
||||||
|
return "LE 1M";
|
||||||
|
case BluetoothDevice.PHY_LE_2M:
|
||||||
|
return "LE 2M";
|
||||||
|
case BluetoothDevice.PHY_LE_CODED:
|
||||||
|
return "LE Coded";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN (" + phy + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ BaseDfuImpl(final Intent intent, final DfuBaseService service) {
|
/* package */ BaseDfuImpl(final Intent intent, final DfuBaseService service) {
|
||||||
|
|
|
@ -826,6 +826,13 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
|
||||||
if (mDfuServiceImpl != null)
|
if (mDfuServiceImpl != null)
|
||||||
mDfuServiceImpl.getGattCallback().onMtuChanged(gatt, mtu, status);
|
mDfuServiceImpl.getGattCallback().onMtuChanged(gatt, mtu, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
@Override
|
||||||
|
public void onPhyUpdate(final BluetoothGatt gatt, final int txPhy, final int rxPhy, final int status) {
|
||||||
|
if (mDfuServiceImpl != null)
|
||||||
|
mDfuServiceImpl.getGattCallback().onPhyUpdate(gatt, txPhy, rxPhy, status);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public DfuBaseService() {
|
public DfuBaseService() {
|
||||||
|
|
Loading…
Reference in New Issue