RS connection improvement
This commit is contained in:
parent
c99830968a
commit
02c57fb9a3
|
@ -61,6 +61,13 @@ public class DanaRFragment extends SubscriberFragment {
|
||||||
Button historyButton;
|
Button historyButton;
|
||||||
Button statsButton;
|
Button statsButton;
|
||||||
|
|
||||||
|
static Runnable connectRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainApp.getConfigBuilder().refreshDataFromPump("Connect request from GUI");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
public DanaRFragment() {
|
public DanaRFragment() {
|
||||||
if (sHandlerThread == null) {
|
if (sHandlerThread == null) {
|
||||||
|
@ -135,13 +142,8 @@ public class DanaRFragment extends SubscriberFragment {
|
||||||
btConnectionView.setOnClickListener(new View.OnClickListener() {
|
btConnectionView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
sHandler.post(new Runnable() {
|
log.debug("Clicked connect to pump");
|
||||||
@Override
|
sHandler.post(connectRunnable);
|
||||||
public void run() {
|
|
||||||
MainApp.getConfigBuilder().refreshDataFromPump("Connect request from GUI");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
@ -217,8 +218,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
connect(from);
|
connect(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void connect(String from) {
|
public static synchronized void connect(String from) {
|
||||||
|
log.debug("RS connect from: " + from);
|
||||||
if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) {
|
if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) {
|
||||||
final Object o = new Object();
|
final Object o = new Object();
|
||||||
|
|
||||||
|
@ -232,7 +233,13 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
}
|
}
|
||||||
pumpDescription.basalStep = pump.basalStep;
|
pumpDescription.basalStep = pump.basalStep;
|
||||||
pumpDescription.bolusStep = pump.bolusStep;
|
pumpDescription.bolusStep = pump.bolusStep;
|
||||||
log.debug("RS connected:" + from);
|
if (isConnected())
|
||||||
|
log.debug("RS connected: " + from);
|
||||||
|
else {
|
||||||
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
|
||||||
|
danaRSService.stopConnecting();
|
||||||
|
log.debug("RS connect failed from: " + from);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,9 +427,11 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshDataFromPump(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
|
log.debug("Refreshing data from pump");
|
||||||
if (!isConnected() && !isConnecting()) {
|
if (!isConnected() && !isConnecting()) {
|
||||||
connect(reason);
|
connect(reason);
|
||||||
}
|
} else
|
||||||
|
log.debug("Already connecting ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -194,6 +194,11 @@ public class BLEComm {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stopConnecting() {
|
||||||
|
isConnecting = false;
|
||||||
|
sHandler.removeCallbacks(updateProgress); // just to be sure
|
||||||
|
}
|
||||||
|
|
||||||
public void disconnect(String from) {
|
public void disconnect(String from) {
|
||||||
log.debug("disconnect from: " + from);
|
log.debug("disconnect from: " + from);
|
||||||
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
|
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
|
||||||
|
|
|
@ -109,6 +109,10 @@ public class DanaRSService extends Service {
|
||||||
return bleComm.connect(from, address, confirmConnect);
|
return bleComm.connect(from, address, confirmConnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stopConnecting() {
|
||||||
|
bleComm.stopConnecting();
|
||||||
|
}
|
||||||
|
|
||||||
public void disconnect(String from) {
|
public void disconnect(String from) {
|
||||||
bleComm.disconnect(from);
|
bleComm.disconnect(from);
|
||||||
}
|
}
|
||||||
|
|
|
@ -745,5 +745,6 @@
|
||||||
<string name="reuse">reuse</string>
|
<string name="reuse">reuse</string>
|
||||||
<string name="wearcontrol_title">Controls from Watch</string>
|
<string name="wearcontrol_title">Controls from Watch</string>
|
||||||
<string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string>
|
<string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string>
|
||||||
|
<string name="connectiontimedout">Connection timed out</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue