SMS read status after bolus

This commit is contained in:
Milos Kozak 2019-03-11 18:29:43 +01:00
parent c7c3506b53
commit b9ea583d3d

View file

@ -667,18 +667,21 @@ public class SmsCommunicatorPlugin extends PluginBase {
detailedBolusInfo.insulin = aDouble;
detailedBolusInfo.source = Source.USER;
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, new Callback() {
@Override
public void run() {
final boolean resultSuccess = result.success;
final double resultBolusDelivered = result.bolusDelivered;
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("SMS", new Callback() {
@Override
public void run() {
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
if (result.success) {
SystemClock.sleep(T.secs(15).msecs()); // wait some time to get history
String reply = String.format(MainApp.gs(R.string.smscommunicator_bolusdelivered), result.bolusDelivered);
if (resultSuccess) {
String reply = String.format(MainApp.gs(R.string.smscommunicator_bolusdelivered), resultBolusDelivered);
if (pump != null)
reply += "\n" + pump.shortStatus(true);
lastRemoteBolusTime = new Date();
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply));
} else {
SystemClock.sleep(T.secs(60).msecs()); // wait some time to get history
String reply = MainApp.gs(R.string.smscommunicator_bolusfailed);
if (pump != null)
reply += "\n" + pump.shortStatus(true);
@ -688,6 +691,8 @@ public class SmsCommunicatorPlugin extends PluginBase {
});
}
});
}
});
} else
sendSMS(new Sms(receivedSms.phoneNumber, R.string.wrongformat));
}