mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 18:45:49 +01:00
Add creation timestamps to BtLEActions and transactions in debug output
(I think I still sometimes get "old" notifications)
This commit is contained in:
parent
78c0f2797d
commit
580b86f41b
@ -3,6 +3,9 @@ package nodomain.freeyourgadget.gadgetbridge.btle;
|
|||||||
import android.bluetooth.BluetoothGatt;
|
import android.bluetooth.BluetoothGatt;
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Bluedroid implementation only allows performing one GATT request at a time.
|
* The Bluedroid implementation only allows performing one GATT request at a time.
|
||||||
* As they are asynchronous anyway, we encapsulate every GATT request (read and write)
|
* As they are asynchronous anyway, we encapsulate every GATT request (read and write)
|
||||||
@ -13,9 +16,11 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
|||||||
*/
|
*/
|
||||||
public abstract class BtLEAction {
|
public abstract class BtLEAction {
|
||||||
private final BluetoothGattCharacteristic characteristic;
|
private final BluetoothGattCharacteristic characteristic;
|
||||||
|
private final long creationTimestamp;
|
||||||
|
|
||||||
public BtLEAction(BluetoothGattCharacteristic characteristic) {
|
public BtLEAction(BluetoothGattCharacteristic characteristic) {
|
||||||
this.characteristic = characteristic;
|
this.characteristic = characteristic;
|
||||||
|
creationTimestamp = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,9 +49,13 @@ public abstract class BtLEAction {
|
|||||||
return characteristic;
|
return characteristic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getCreationTime() {
|
||||||
|
return DateFormat.getTimeInstance(DateFormat.MEDIUM).format(new Date(creationTimestamp));
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
BluetoothGattCharacteristic characteristic = getCharacteristic();
|
BluetoothGattCharacteristic characteristic = getCharacteristic();
|
||||||
String uuid = characteristic == null ? "(null)" : characteristic.getUuid().toString();
|
String uuid = characteristic == null ? "(null)" : characteristic.getUuid().toString();
|
||||||
return getClass().getSimpleName() + " on characteristic: " + uuid;
|
return getCreationTime() + ": " + getClass().getSimpleName() + " on characteristic: " + uuid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,9 @@ public final class BtLEQueue {
|
|||||||
for (BtLEAction action : transaction.getActions()) {
|
for (BtLEAction action : transaction.getActions()) {
|
||||||
mWaitCharacteristic = action.getCharacteristic();
|
mWaitCharacteristic = action.getCharacteristic();
|
||||||
mWaitForActionResultLatch = new CountDownLatch(1);
|
mWaitForActionResultLatch = new CountDownLatch(1);
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("About to run action: " + action);
|
||||||
|
}
|
||||||
if (action.run(mBluetoothGatt)) {
|
if (action.run(mBluetoothGatt)) {
|
||||||
// check again, maybe due to some condition, action did not need to write, so we can't wait
|
// check again, maybe due to some condition, action did not need to write, so we can't wait
|
||||||
boolean waitForResult = action.expectsResult();
|
boolean waitForResult = action.expectsResult();
|
||||||
|
@ -32,6 +32,6 @@ public class SetDeviceBusyAction extends PlainAction {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getClass().getName() + ": " + busyTask;
|
return getCreationTime() + ": " + getClass().getName() + ": " + busyTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.btle;
|
package nodomain.freeyourgadget.gadgetbridge.btle;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -14,6 +16,7 @@ import java.util.Locale;
|
|||||||
public class Transaction {
|
public class Transaction {
|
||||||
private String mName;
|
private String mName;
|
||||||
private List<BtLEAction> mActions = new ArrayList<>(4);
|
private List<BtLEAction> mActions = new ArrayList<>(4);
|
||||||
|
private long creationTimestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
public Transaction(String taskName) {
|
public Transaction(String taskName) {
|
||||||
this.mName = taskName;
|
this.mName = taskName;
|
||||||
@ -35,8 +38,12 @@ public class Transaction {
|
|||||||
return mActions.isEmpty();
|
return mActions.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getCreationTime() {
|
||||||
|
return DateFormat.getTimeInstance(DateFormat.MEDIUM).format(new Date(creationTimestamp));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format(Locale.US, "Transaction task: %s with %d actions", getTaskName(), mActions.size());
|
return String.format(Locale.US, "%s: Transaction task: %s with %d actions", getCreationTime(), getTaskName(), mActions.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user