Combo: provide pump serial number, notify about pump change.
This commit is contained in:
parent
38bab84047
commit
97bf95a6fa
|
@ -73,9 +73,12 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
|
public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
|
||||||
|
// TODO clean up?
|
||||||
|
static final String COMBO_PUMP_SERIAL = "combo_pump_serial";
|
||||||
static final String COMBO_TBRS_SET = "combo_tbrs_set";
|
static final String COMBO_TBRS_SET = "combo_tbrs_set";
|
||||||
static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
|
static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
|
||||||
|
|
||||||
|
// collaborators
|
||||||
private final ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private RxBusWrapper rxBus;
|
private RxBusWrapper rxBus;
|
||||||
|
@ -403,6 +406,17 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read pump BT mac address and use it as the pump's serial
|
||||||
|
String macAddress = ruffyScripter.getMacAddress();
|
||||||
|
if (macAddress != null) {
|
||||||
|
String lastKnownSN = serialNumber();
|
||||||
|
if (!lastKnownSN.equals(fakeSerialNumber()) && !lastKnownSN.equals(macAddress)) {
|
||||||
|
getAapsLogger().info(LTag.PUMP, "Pump serial number changed " + lastKnownSN + " -> " + macAddress);
|
||||||
|
pumpSync.connectNewPump();
|
||||||
|
}
|
||||||
|
sp.putString(COMBO_PUMP_SERIAL, macAddress);
|
||||||
|
}
|
||||||
|
|
||||||
// ComboFragment updates state fully only after the pump has initialized,
|
// ComboFragment updates state fully only after the pump has initialized,
|
||||||
// so force an update after initialization completed
|
// so force an update after initialization completed
|
||||||
rxBus.send(new EventComboPumpUpdateGUI());
|
rxBus.send(new EventComboPumpUpdateGUI());
|
||||||
|
@ -1309,7 +1323,11 @@ public class ComboPlugin extends PumpPluginBase implements Pump, Constraints {
|
||||||
|
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
public String serialNumber() {
|
public String serialNumber() {
|
||||||
return InstanceId.INSTANCE.instanceId(); // TODO replace by real serial
|
return sp.getString(COMBO_PUMP_SERIAL, fakeSerialNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String fakeSerialNumber() {
|
||||||
|
return InstanceId.INSTANCE.instanceId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
|
|
Loading…
Reference in a new issue