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);
|
||||
if (mtu - 3 > mBuffer.length)
|
||||
mBuffer = new byte[mtu - 3]; // Maximum payload size is MTU - 3 bytes
|
||||
logw("MTU changed to: " + mtu);
|
||||
logi("MTU changed to: " + mtu);
|
||||
} else {
|
||||
logw("Changing MTU failed: " + status + " (mtu: " + mtu + ")");
|
||||
}
|
||||
|
@ -176,6 +176,16 @@ import no.nordicsemi.android.dfu.internal.scanner.BootloaderScannerFactory;
|
|||
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) {
|
||||
return parse(characteristic.getValue());
|
||||
}
|
||||
|
@ -201,6 +211,19 @@ import no.nordicsemi.android.dfu.internal.scanner.BootloaderScannerFactory;
|
|||
}
|
||||
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) {
|
||||
|
@ -651,7 +674,7 @@ import no.nordicsemi.android.dfu.internal.scanner.BootloaderScannerFactory;
|
|||
* Restarts the service based on the given intent. If parameter set this method will also scan for
|
||||
* an advertising bootloader that has address equal or incremented by 1 to the current one.
|
||||
* @param intent the intent to be started as a service
|
||||
* @param scanForBootloader true to scan for advertising bootloader, false to keep the same address
|
||||
* @param scanForBootloader true to scan for advertising bootloader, false to keep the same address
|
||||
*/
|
||||
protected void restartService(final Intent intent, final boolean scanForBootloader) {
|
||||
String newAddress = null;
|
||||
|
|
|
@ -826,6 +826,13 @@ public abstract class DfuBaseService extends IntentService implements DfuProgres
|
|||
if (mDfuServiceImpl != null)
|
||||
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() {
|
||||
|
|
Loading…
Reference in New Issue