synchronized connectifnotconnected
This commit is contained in:
parent
a10a819a9d
commit
b818027b02
1 changed files with 32 additions and 28 deletions
|
@ -68,6 +68,8 @@ public class DanaConnection {
|
||||||
PowerManager.WakeLock mWakeLock;
|
PowerManager.WakeLock mWakeLock;
|
||||||
private Treatment bolusingTreatment = null;
|
private Treatment bolusingTreatment = null;
|
||||||
|
|
||||||
|
private static Object connectionInProgress = new Object();
|
||||||
|
|
||||||
private DanaRFragment danaRFragment;
|
private DanaRFragment danaRFragment;
|
||||||
private DanaRPump danaRPump;
|
private DanaRPump danaRPump;
|
||||||
|
|
||||||
|
@ -77,7 +79,7 @@ public class DanaConnection {
|
||||||
|
|
||||||
private static final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
|
private static final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb");
|
||||||
|
|
||||||
// TODO: keepalive kills active connection
|
// TODO: keepalive kills active connection
|
||||||
public DanaConnection(Bus bus) {
|
public DanaConnection(Bus bus) {
|
||||||
danaRFragment = (DanaRFragment) MainActivity.getSpecificPlugin(DanaRFragment.class);
|
danaRFragment = (DanaRFragment) MainActivity.getSpecificPlugin(DanaRFragment.class);
|
||||||
danaRFragment.setDanaConnection(this);
|
danaRFragment.setDanaConnection(this);
|
||||||
|
@ -159,6 +161,7 @@ public class DanaConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void connectIfNotConnected(String callerName) {
|
public synchronized void connectIfNotConnected(String callerName) {
|
||||||
|
synchronized (connectionInProgress) {
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
short connectionAttemptCount = 0;
|
short connectionAttemptCount = 0;
|
||||||
|
@ -191,6 +194,7 @@ public class DanaConnection {
|
||||||
}
|
}
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized void connectBT() {
|
private synchronized void connectBT() {
|
||||||
if (mDevice == null) {
|
if (mDevice == null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue