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

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