Order methods in the order they're called, start Alerter service earlier to make sure it can catch early errors.
This commit is contained in:
parent
487e9deb88
commit
599f3ce23c
|
@ -84,43 +84,37 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
public ComboPlugin() {
|
public ComboPlugin() {
|
||||||
definePumpCapabilities();
|
definePumpCapabilities();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
startAlerter();
|
||||||
bindRuffyService();
|
bindRuffyService();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindRuffyService() {
|
private void definePumpCapabilities() {
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
pumpDescription.isBolusCapable = true;
|
||||||
|
pumpDescription.bolusStep = 0.1d;
|
||||||
|
|
||||||
Intent intent = new Intent()
|
pumpDescription.isExtendedBolusCapable = false; // TODO
|
||||||
.setComponent(new ComponentName(
|
pumpDescription.extendedBolusStep = 0.1d;
|
||||||
// this must be the base package of the app (check package attribute in
|
pumpDescription.extendedBolusDurationStep = 15;
|
||||||
// manifest element in the manifest file of the providing app)
|
pumpDescription.extendedBolusMaxDuration = 12 * 60;
|
||||||
"org.monkey.d.ruffy.ruffy",
|
|
||||||
// full path to the driver
|
|
||||||
// in the logs this service is mentioned as (note the slash)
|
|
||||||
// "org.monkey.d.ruffy.ruffy/.driver.Ruffy"
|
|
||||||
"org.monkey.d.ruffy.ruffy.driver.Ruffy"
|
|
||||||
));
|
|
||||||
context.startService(intent);
|
|
||||||
|
|
||||||
mRuffyServiceConnection = new ServiceConnection() {
|
pumpDescription.isTempBasalCapable = true;
|
||||||
|
pumpDescription.tempBasalStyle = PumpDescription.PERCENT;
|
||||||
|
|
||||||
@Override
|
pumpDescription.maxTempPercent = 500;
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
pumpDescription.tempPercentStep = 10;
|
||||||
ruffyScripter = new RuffyScripter(IRuffyService.Stub.asInterface(service));
|
|
||||||
log.debug("ruffy serivce connected");
|
pumpDescription.tempDurationStep = 15;
|
||||||
}
|
pumpDescription.tempMaxDuration = 24 * 60;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
pumpDescription.isSetBasalProfileCapable = false; // TODO
|
||||||
log.debug("ruffy service disconnected");
|
pumpDescription.basalStep = 0.01d;
|
||||||
}
|
pumpDescription.basalMinimumRate = 0.0d;
|
||||||
};
|
|
||||||
|
pumpDescription.isRefillingCapable = false;
|
||||||
boolean success = context.bindService(intent, mRuffyServiceConnection, Context.BIND_AUTO_CREATE);
|
|
||||||
if (!success) {
|
|
||||||
log.error("Binding to ruffy service failed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startAlerter() {
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -164,28 +158,34 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
}, "combo-alerter").start();
|
}, "combo-alerter").start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void definePumpCapabilities() {
|
private void bindRuffyService() {
|
||||||
pumpDescription.isBolusCapable = true;
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
pumpDescription.bolusStep = 0.1d;
|
|
||||||
|
|
||||||
pumpDescription.isExtendedBolusCapable = false; // TODO
|
Intent intent = new Intent()
|
||||||
pumpDescription.extendedBolusStep = 0.1d;
|
.setComponent(new ComponentName(
|
||||||
pumpDescription.extendedBolusDurationStep = 15;
|
// this must be the base package of the app (check package attribute in
|
||||||
pumpDescription.extendedBolusMaxDuration = 12 * 60;
|
// manifest element in the manifest file of the providing app)
|
||||||
|
"org.monkey.d.ruffy.ruffy",
|
||||||
|
// full path to the driver
|
||||||
|
// in the logs this service is mentioned as (note the slash)
|
||||||
|
// "org.monkey.d.ruffy.ruffy/.driver.Ruffy"
|
||||||
|
"org.monkey.d.ruffy.ruffy.driver.Ruffy"
|
||||||
|
));
|
||||||
|
context.startService(intent);
|
||||||
|
|
||||||
pumpDescription.isTempBasalCapable = true;
|
mRuffyServiceConnection = new ServiceConnection() {
|
||||||
pumpDescription.tempBasalStyle = PumpDescription.PERCENT;
|
|
||||||
|
|
||||||
pumpDescription.maxTempPercent = 500;
|
@Override
|
||||||
pumpDescription.tempPercentStep = 10;
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
|
ruffyScripter = new RuffyScripter(IRuffyService.Stub.asInterface(service));
|
||||||
|
log.debug("ruffy serivce connected");
|
||||||
|
}
|
||||||
|
|
||||||
pumpDescription.tempDurationStep = 15;
|
@Override
|
||||||
pumpDescription.tempMaxDuration = 24 * 60;
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
log.debug("ruffy service disconnected");
|
||||||
|
}
|
||||||
pumpDescription.isSetBasalProfileCapable = false; // TODO
|
};
|
||||||
pumpDescription.basalStep = 0.01d;
|
|
||||||
pumpDescription.basalMinimumRate = 0.0d;
|
|
||||||
|
|
||||||
boolean success = context.bindService(intent, mRuffyServiceConnection, Context.BIND_AUTO_CREATE);
|
boolean success = context.bindService(intent, mRuffyServiceConnection, Context.BIND_AUTO_CREATE);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
|
Loading…
Reference in a new issue