Merge pull request #188 from nightscout/crashalytics_280_jan21
Crashalytics 280 jan21
This commit is contained in:
commit
8109472a04
|
@ -422,14 +422,16 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
|
||||
@Override
|
||||
public void getPumpStatus(String reason) {
|
||||
boolean needRefresh = true;
|
||||
|
||||
if (firstRun) {
|
||||
initializePump(!isRefresh);
|
||||
needRefresh = initializePump(!isRefresh);
|
||||
} else {
|
||||
refreshAnyStatusThatNeedsToBeRefreshed();
|
||||
}
|
||||
|
||||
rxBus.send(new EventMedtronicPumpValuesChanged());
|
||||
if (needRefresh)
|
||||
rxBus.send(new EventMedtronicPumpValuesChanged());
|
||||
}
|
||||
|
||||
|
||||
|
@ -556,7 +558,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
}
|
||||
|
||||
|
||||
private void initializePump(boolean realInit) {
|
||||
private boolean initializePump(boolean realInit) {
|
||||
|
||||
if (rileyLinkMedtronicService==null)
|
||||
return false;
|
||||
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "initializePump - start");
|
||||
|
||||
|
@ -571,7 +576,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
|
||||
setRefreshButtonEnabled(true);
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
medtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable, rxBus);
|
||||
|
@ -614,7 +619,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
aapsLogger.error("Number of error counts was 5 or more. Starting tunning.");
|
||||
setRefreshButtonEnabled(true);
|
||||
serviceTaskExecutor.startTask(new WakeAndTuneTask(getInjector()));
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
medtronicPumpStatus.setLastCommunicationToNow();
|
||||
|
@ -628,6 +633,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
// this.pumpState = PumpDriverState.Initialized;
|
||||
|
||||
this.firstRun = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void getBasalProfiles() {
|
||||
|
|
|
@ -149,8 +149,14 @@ public class MedtronicConverter {
|
|||
|
||||
if (rawData.length > 1) {
|
||||
|
||||
Double d = null;
|
||||
|
||||
// if response in 3 bytes then we add additional information
|
||||
double d = (ByteUtil.toInt(rawData[1], rawData[2]) * 1.0d) / 100.0d;
|
||||
if (rawData.length == 2) {
|
||||
d = (rawData[1] * 1.0d) / 100.0d;
|
||||
} else {
|
||||
d = (ByteUtil.toInt(rawData[1], rawData[2]) * 1.0d) / 100.0d;
|
||||
}
|
||||
|
||||
batteryStatus.voltage = d;
|
||||
batteryStatus.extendedDataReceived = true;
|
||||
|
@ -171,7 +177,14 @@ public class MedtronicConverter {
|
|||
startIdx = 2;
|
||||
}
|
||||
|
||||
float value = ByteUtil.toInt(rawData[startIdx], rawData[startIdx + 1]) / (1.0f * strokes);
|
||||
int reqLength = startIdx+1;
|
||||
float value = 0;
|
||||
|
||||
if (reqLength >= rawData.length) {
|
||||
value = rawData[startIdx] / (1.0f * strokes);
|
||||
} else {
|
||||
value = ByteUtil.toInt(rawData[startIdx], rawData[startIdx + 1]) / (1.0f * strokes);
|
||||
}
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Remaining insulin: " + value);
|
||||
return value;
|
||||
|
|
|
@ -106,8 +106,10 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
|||
int els = getUnsignedInt(elements);
|
||||
|
||||
for (int k = 0; k < (els - 2); k++) {
|
||||
listRawData.add(dataClear.get(counter));
|
||||
counter++;
|
||||
if (counter<1022) {
|
||||
listRawData.add(dataClear.get(counter));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
special = true;
|
||||
|
|
|
@ -133,7 +133,11 @@ public class PumpMessage implements RLMessage {
|
|||
|
||||
public byte[] getRawContentOfFrame() {
|
||||
byte[] raw = messageBody.getTxData();
|
||||
return ByteUtil.substring(raw, 1, Math.min(FRAME_DATA_LENGTH, raw.length - 1));
|
||||
if (raw==null || raw.length==0) {
|
||||
return new byte[0];
|
||||
} else {
|
||||
return ByteUtil.substring(raw, 1, Math.min(FRAME_DATA_LENGTH, raw.length - 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1523,7 +1523,9 @@ public class MedtronicHistoryData {
|
|||
// HELPER METHODS
|
||||
|
||||
private void sort(List<PumpHistoryEntry> list) {
|
||||
Collections.sort(list, new PumpHistoryEntry.Comparator());
|
||||
if (list!=null && !list.isEmpty()) {
|
||||
Collections.sort(list, new PumpHistoryEntry.Comparator());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -390,7 +390,8 @@ public class RFSpy {
|
|||
private void setMedtronicEncoding() {
|
||||
RileyLinkEncodingType encoding = RileyLinkEncodingType.FourByteSixByteLocal;
|
||||
|
||||
if (rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) {
|
||||
if (rileyLinkServiceData.firmwareVersion!=null &&
|
||||
rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) {
|
||||
if (sp.getString(RileyLinkConst.Prefs.Encoding, "None")
|
||||
.equals(resourceHelper.gs(R.string.key_medtronic_pump_encoding_4b6b_rileylink))) {
|
||||
encoding = RileyLinkEncodingType.FourByteSixByteRileyLink;
|
||||
|
|
|
@ -12,7 +12,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
|
|||
*/
|
||||
public class DiscoverGattServicesTask extends ServiceTask {
|
||||
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
|
||||
public boolean needToConnect = false;
|
||||
|
@ -31,6 +31,11 @@ public class DiscoverGattServicesTask extends ServiceTask {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (!isRileyLinkDevice()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
|
||||
|
||||
if (needToConnect) {
|
||||
|
|
|
@ -29,7 +29,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|||
public class InitializePumpManagerTask extends ServiceTask {
|
||||
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
//@Inject ActivePluginProvider activePlugin;
|
||||
@Inject SP sp;
|
||||
@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||
@Inject RileyLinkUtil rileyLinkUtil;
|
||||
|
@ -49,6 +49,10 @@ public class InitializePumpManagerTask extends ServiceTask {
|
|||
@Override
|
||||
public void run() {
|
||||
|
||||
if (!isRileyLinkDevice()) {
|
||||
return;
|
||||
}
|
||||
|
||||
double lastGoodFrequency;
|
||||
|
||||
if (rileyLinkServiceData.lastGoodFrequency == null) {
|
||||
|
|
|
@ -24,6 +24,11 @@ public class ResetRileyLinkConfigurationTask extends PumpTask {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (!isRileyLinkDevice()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RileyLinkPumpDevice rileyLinkPumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
|
||||
|
||||
rxBus.send(new EventRefreshButtonState(false));
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||
|
||||
/**
|
||||
|
@ -8,6 +12,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.
|
|||
*/
|
||||
public class ServiceTask implements Runnable {
|
||||
|
||||
@Inject protected ActivePluginProvider activePlugin;
|
||||
|
||||
public boolean completed = false;
|
||||
protected ServiceTransport mTransport;
|
||||
protected HasAndroidInjector injector;
|
||||
|
@ -56,4 +62,10 @@ public class ServiceTask implements Runnable {
|
|||
* RoundtripService.getInstance().sendServiceTransportResponse(mTransport,result);
|
||||
* }
|
||||
*/
|
||||
|
||||
public boolean isRileyLinkDevice() {
|
||||
return (activePlugin.getActivePump() instanceof RileyLinkPumpDevice);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
|
|||
*/
|
||||
public class WakeAndTuneTask extends PumpTask {
|
||||
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
//@Inject ActivePluginProvider activePlugin;
|
||||
@Inject RxBusWrapper rxBus;
|
||||
|
||||
private static final String TAG = "WakeAndTuneTask";
|
||||
|
@ -24,6 +24,10 @@ public class WakeAndTuneTask extends PumpTask {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isRileyLinkDevice()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RileyLinkPumpDevice pumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
|
||||
rxBus.send(new EventRefreshButtonState(false));
|
||||
pumpDevice.setBusy(true);
|
||||
|
|
Loading…
Reference in a new issue