- bolus finalized: added delay before bolus is delivered (configurable 5, 10, 15s) and if cancel is issued, after
delay, and bolus was already sent to pump, message is displayed saying that you need to manually stop the pump
to cancel bolus
- BLE Scanner refactored and finished (removed un-needed code)
- fixed 5 most common Crashalytics errors found
- fixed Basal Profile problem (I hope)
This commit is contained in:
Andy Rozman 2019-01-15 20:08:31 +00:00
parent 8fc694e812
commit 9c08bfb8bf
15 changed files with 276 additions and 261 deletions

View file

@ -64,11 +64,12 @@ android {
multiDexEnabled true
versionCode 1500
// dev_version: 2.0
version "medtronic-0.5"
version "medtronic-0.6"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
buildConfigField "String", "DEV_VERSION", '"2.0i"'
buildConfigField "String", "DEV_VERSION", '"2.0"'
buildConfigField "String", "DEV_DATE", '"4.1.2019"'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {

View file

@ -51,6 +51,10 @@
<activity
android:name=".plugins.Overview.Dialogs.ErrorHelperActivity"
android:theme="@style/Theme.AppCompat.Translucent" />
<activity
android:name=".plugins.Overview.Dialogs.MessageHelperActivity"
android:theme="@style/Theme.AppCompat.Translucent" />
<activity android:name=".activities.AgreementActivity" />
<activity android:name=".plugins.PumpDanaR.activities.DanaRHistoryActivity" />
<activity android:name=".plugins.PumpDanaR.activities.DanaRUserOptionsActivity" />

View file

@ -0,0 +1,95 @@
package info.nightscout.androidaps.plugins.Overview.Dialogs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import info.nightscout.androidaps.R;
public class MessageDialog extends DialogFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(MessageDialog.class);
// Button muteButton;
Button okButton;
TextView statusView;
MessageHelperActivity helperActivity;
static String status;
static String title;
// static int soundId;
public MessageDialog() {
super();
}
public void setStatus(String status) {
this.status = status;
}
public void setTitle(String title) {
this.title = title;
}
public void setHelperActivity(MessageHelperActivity activity) {
this.helperActivity = activity;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
getDialog().setTitle(title);
View view = inflater.inflate(R.layout.overview_message_dialog, container, false);
// muteButton = (Button)view.findViewById(R.id.overview_error_mute);
okButton = (Button)view.findViewById(R.id.overview_message_ok);
statusView = (TextView)view.findViewById(R.id.overview_message_status);
// muteButton.setOnClickListener(this);
okButton.setOnClickListener(this);
setCancelable(false);
// startAlarm();
return view;
}
@Override
public void onResume() {
super.onResume();
if (getDialog() != null)
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
statusView.setText(status);
}
@Override
public void dismiss() {
super.dismissAllowingStateLoss();
if (helperActivity != null) {
helperActivity.finish();
}
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.overview_message_ok:
log.debug("Error dialog ok button pressed");
dismiss();
break;
}
}
}

View file

@ -0,0 +1,24 @@
package info.nightscout.androidaps.plugins.Overview.Dialogs;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class MessageHelperActivity extends AppCompatActivity {
public MessageHelperActivity() {
super();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MessageDialog messageDialog = new MessageDialog();
messageDialog.setHelperActivity(this);
messageDialog.setStatus(getIntent().getStringExtra("status"));
messageDialog.setTitle(getIntent().getStringExtra("title"));
messageDialog.show(this.getSupportFragmentManager(), "Message");
}
}

View file

@ -25,7 +25,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.ParcelUuid;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
@ -65,7 +64,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
// Stops scanning after 30 seconds.
private static final long SCAN_PERIOD = 30000;
public boolean mScanning;
public Snackbar snackbar;
public ScanSettings settings;
public List<ScanFilter> filters;
public ListView listBTScan;
@ -76,6 +74,9 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
private LeDeviceListAdapter mLeDeviceListAdapter;
private Handler mHandler;
private String actionTitleStart, actionTitleStop;
private MenuItem menuItem;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -109,8 +110,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
MainApp.bus().post(new EventMedtronicPumpConfigurationChanged());
// RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.Intents.RileyLinkNewAddressSet);
finish();
});
@ -118,31 +117,21 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
toolbarBTScan.setTitle(R.string.rileylink_scanner_title);
setSupportActionBar(toolbarBTScan);
// TODO remove snackbar, stop needs to be on same button as start
snackbar = Snackbar.make(findViewById(R.id.RileyLinkScan), "Scanning...", Snackbar.LENGTH_INDEFINITE);
snackbar.setAction("STOP", new View.OnClickListener() {
@Override
public void onClick(View view) {
scanLeDevice(false);
}
});
prepareForScanning();
}
// @Override
// protected void onPause() {
// super.onPause();
// scanLeDevice(false);
// mLeDeviceListAdapter.clear();
// mLeDeviceListAdapter.notifyDataSetChanged();
// }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_rileylink_ble_scan, menu);
actionTitleStart = MainApp.gs(R.string.rileylink_scanner_scan_scan);
actionTitleStop = MainApp.gs(R.string.rileylink_scanner_scan_stop);
menuItem = menu.getItem(0);
menuItem.setTitle(actionTitleStart);
return true;
}
@ -151,8 +140,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.rileylink_miScan: {
// FIXME
scanLeDevice(true);
scanLeDevice(menuItem.getTitle().equals(actionTitleStart));
return true;
}
@ -166,7 +154,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
// https://developer.android.com/training/permissions/requesting.html
// http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
Toast.makeText(this, "R.string.ble_not_supported", Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.rileylink_scanner_ble_not_supported, Toast.LENGTH_SHORT).show();
} else {
// Use this check to determine whether BLE is supported on the device. Then
// you can selectively disable BLE-related features.
@ -179,7 +167,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
// Ensures Bluetooth is available on the device and it is enabled. If not,
// displays a dialog requesting user permission to enable Bluetooth.
if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled()) {
Toast.makeText(this, "R.string.ble_not_enabled", Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.rileylink_scanner_ble_not_enabled, Toast.LENGTH_SHORT).show();
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@ -197,7 +185,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
filters = Arrays.asList(new ScanFilter.Builder().setServiceUuid(
ParcelUuid.fromString(GattAttributes.SERVICE_RADIO)).build());
// scanLeDevice(true);
}
}
@ -224,8 +211,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
@Override
public void onScanResult(int callbackType, final ScanResult scanRecord) {
// final BleAdvertisedData badata = RileyLinkUtil.parseAdertisedData(scanRecord);
Log.d(TAG, scanRecord.toString());
runOnUiThread(() -> {
@ -243,7 +228,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
boolean added = false;
for (ScanResult result : results) {
if (addDevice(result))
added = true;
}
@ -258,13 +242,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
BluetoothDevice device = result.getDevice();
// BluetoothClass bluetoothClass = device.getBluetoothClass();
//
// StringBuilder sb = new StringBuilder("Class: ");
// sb.append("MajorClass: " + bluetoothClass.getMajorDeviceClass());
// sb.append("DeviceClass: " + bluetoothClass.getDeviceClass());
// Log.d(TAG, sb.toString());
// FIXME remove most of code
List<ParcelUuid> serviceUuids = result.getScanRecord().getServiceUuids();
if (serviceUuids == null || serviceUuids.size() == 0) {
@ -293,50 +270,53 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
", type=" + device.getType(); // + ", alias=" + device.getAlias();
}
// @Override
// public void onScanFailed(int errorCode) {
//
// Log.e("Scan Failed", "Error Code: " + errorCode);
// Toast.makeText(mContext, "Scan Failed " + errorCode, Toast.LENGTH_LONG).show();
// }
@Override
public void onScanFailed(int errorCode) {
Log.e("Scan Failed", "Error Code: " + errorCode);
Toast.makeText(mContext, MainApp.gs(R.string.rileylink_scanner_scanning_error, errorCode),
Toast.LENGTH_LONG).show();
}
};
private void scanLeDevice(final boolean enable) {
// FIXME
if (enable) {
mLeDeviceListAdapter.clear();
mLeDeviceListAdapter.notifyDataSetChanged();
// Stops scanning after a pre-defined scan period.
mHandler.postDelayed(new Runnable() {
mHandler.postDelayed(() -> {
@Override
public void run() {
if (mScanning) {
mScanning = false;
mLEScanner.stopScan(mScanCallback2);
LOG.debug("scanLeDevice: Scanning Stop");
// Toast.makeText(mContext, "Scanning finished", Toast.LENGTH_SHORT).show();
snackbar.dismiss();
Toast.makeText(mContext, R.string.rileylink_scanner_scanning_finished, Toast.LENGTH_SHORT).show();
menuItem.setTitle(actionTitleStart);
}
}, SCAN_PERIOD);
mScanning = true;
mLEScanner.startScan(filters, settings, mScanCallback2);
LOG.debug("scanLeDevice: Scanning Start");
// Toast.makeText(this, "Scanning", Toast.LENGTH_SHORT).show();
snackbar.show();
Toast.makeText(this, R.string.rileylink_scanner_scanning, Toast.LENGTH_SHORT).show();
menuItem.setTitle(actionTitleStop);
} else {
mScanning = false;
mLEScanner.stopScan(mScanCallback2);
if (mScanning) {
mScanning = false;
mLEScanner.stopScan(mScanCallback2);
LOG.debug("scanLeDevice: Scanning Stop");
// Toast.makeText(this, "Scanning finished", Toast.LENGTH_SHORT).show();
snackbar.dismiss();
LOG.debug("scanLeDevice: Scanning Stop");
Toast.makeText(this, R.string.rileylink_scanner_scanning_finished, Toast.LENGTH_SHORT).show();
menuItem.setTitle(actionTitleStart);
}
}
}
@ -357,14 +337,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
}
// public void addDevice(BluetoothDevice device) {
//
// if (!mLeDevices.contains(device)) {
// mLeDevices.add(device);
// notifyDataSetChanged();
// }
// }
public void addDevice(ScanResult result) {
if (!mLeDevices.contains(result.getDevice())) {
@ -375,11 +347,6 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
}
// public BluetoothDevice getDevice(int position) {
//
// return rileyLinkDevices.get(position);
// }
public void clear() {
mLeDevices.clear();
rileyLinkDevices.clear();
@ -435,27 +402,12 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
deviceName += " (" + getResources().getString(R.string.rileylink_scanner_selected_device) + ")";
}
// if (deviceName == null) {
// BleAdvertisedData bleAdvertisedData = mapDevices.get(device);
//
// deviceName = bleAdvertisedData.getName();
//
// Log.d(TAG, "Old name was null so we replaced it with " + deviceName);
// }
viewHolder.deviceName.setText(deviceName);
viewHolder.deviceAddress.setText(device.getAddress());
return view;
}
// public void addDevice(BluetoothDevice device, BleAdvertisedData bleAdvertisedData) {
// if (!mLeDevices.contains(device)) {
// mLeDevices.add(device);
// mapDevices.put(device, bleAdvertisedData);
// notifyDataSetChanged();
// }
// }
}
static class ViewHolder {

View file

@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.RileyLinkCommunicationException;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.RileyLinkCommand;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkBLEError;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
@ -104,14 +105,19 @@ public class RadioResponse {
case FourByteSixByteLocal: {
byte[] decodeThis = RileyLinkUtil.getEncoding4b6b().decode4b6b(encodedPayload);
decodedOK = true;
decodedPayload = ByteUtil.substring(decodeThis, 0, decodeThis.length - 1);
receivedCRC = decodeThis[decodeThis.length - 1];
byte calculatedCRC = CRC.crc8(decodedPayload);
if (receivedCRC != calculatedCRC) {
LOG.error(String.format("RadioResponse: CRC mismatch, calculated 0x%02x, received 0x%02x",
calculatedCRC, receivedCRC));
if (decodeThis != null && decodeThis.length > 2) {
decodedOK = true;
decodedPayload = ByteUtil.substring(decodeThis, 0, decodeThis.length - 1);
receivedCRC = decodeThis[decodeThis.length - 1];
byte calculatedCRC = CRC.crc8(decodedPayload);
if (receivedCRC != calculatedCRC) {
LOG.error(String.format("RadioResponse: CRC mismatch, calculated 0x%02x, received 0x%02x",
calculatedCRC, receivedCRC));
}
} else {
throw new RileyLinkCommunicationException(RileyLinkBLEError.TooShortOrNullResponse);
}
}
break;

View file

@ -7,7 +7,8 @@ package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs;
public enum RileyLinkBLEError {
CodingErrors("Coding Errors encpountered during decode of RileyLink packet."), //
Timeout("Timeout"), //
Interrupted("Interrupted");
Interrupted("Interrupted"),
TooShortOrNullResponse("Too short or null decoded response.");
private String description;

View file

@ -40,7 +40,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.Actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
import info.nightscout.androidaps.plugins.Overview.Dialogs.MessageHelperActivity;
import info.nightscout.androidaps.plugins.PumpCommon.PumpPluginAbstract;
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpDriverState;
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
@ -513,7 +513,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
return true;
}
LOG.info("isThisProfileSet: check");
// LOG.info("isThisProfileSet: check");
LOG.info("isThisProfileSet: check [basalProfileChanged={}, basalByHourSet={}, isBasalProfileInvalid={}",
basalProfileChanged, getMDTPumpStatus().basalsByHour != null, isBasalProfileInvalid);
if (!basalProfileChanged && getMDTPumpStatus().basalsByHour != null && !isBasalProfileInvalid) {
if (isLoggingEnabled())
@ -541,10 +544,14 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
boolean valid = false;
boolean noData = false;
if (responseTask.haveData()) {
LOG.debug("isThisProfileSet: haveData={}", responseTask.hasData());
if (responseTask.hasData()) {
valid = isProfileSame(profile);
LOG.debug("isThisProfileSet: valid={}", valid);
if (valid) {
basalProfileChanged = false;
}
@ -670,61 +677,56 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
if (bolusDeliveryType == BolusDeliveryType.CancelDelivery) {
LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled.");
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled.");
return setNotReachable(true, true);
}
LOG.debug("MedtronicPumpPlugin::deliverBolus - Starting wait period.");
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Starting wait period.");
SystemClock.sleep(10000);
int sleepTime = SP.getInt(MedtronicConst.Prefs.BolusDelay, 10) * 1000;
SystemClock.sleep(sleepTime);
if (bolusDeliveryType == BolusDeliveryType.CancelDelivery) {
LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled, before wait period.");
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled, before wait period.");
return setNotReachable(true, true);
}
LOG.debug("MedtronicPumpPlugin::deliverBolus - End wait period. Start delivery");
// LOG.debug("MedtronicPumpPlugin::deliverBolus - End wait period. Start delivery");
try {
bolusDeliveryType = BolusDeliveryType.Delivering;
// LOG.error("MedtronicPumpPlugin::deliverBolus Not fully implemented - Just base command.");
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Start delivery");
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBolus,
detailedBolusInfo.insulin);
Boolean response = (Boolean)responseTask.returnData;
// TODO display bolus
// setRefreshButtonEnabled(true);
setRefreshButtonEnabled(true);
bolusDeliveryType = BolusDeliveryType.Idle;
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Response: {}", response);
if (response) {
if (bolusDeliveryType == BolusDeliveryType.CancelDelivery) {
LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled after Bolus started.");
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Delivery Canceled after Bolus started.");
new Thread(() -> {
// Looper.prepare();
LOG.debug("MedtronicPumpPlugin::deliverBolus - Show dialog - before");
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Show dialog - before");
SystemClock.sleep(2000);
LOG.debug("MedtronicPumpPlugin::deliverBolus - Show dialog. Context: "
+ MainApp.instance().getApplicationContext());
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Show dialog. Context: "
// + MainApp.instance().getApplicationContext());
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
// i.putExtra("soundid", R.raw.boluserror);
Intent i = new Intent(MainApp.instance(), MessageHelperActivity.class);
i.putExtra("status", MainApp.gs(R.string.medtronic_cmd_cancel_bolus_not_supported));
i.putExtra("title", MainApp.gs(R.string.combo_warning));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
// OKDialog.show(MainApp.instance().getApplicationContext(), //
// MainApp.gs(R.string.combo_warning), //
// MainApp.gs(R.string.medtronic_cmd_cancel_bolus_not_supported), null);
}).start();
}
@ -737,142 +739,21 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses
: MedtronicConst.Statistics.StandardBoluses);
if (bolusDeliveryType == BolusDeliveryType.CancelDelivery) {
return new PumpEnactResult() //
.success(false) //
.enacted(response) //
.bolusDelivered(detailedBolusInfo.insulin) //
.carbsDelivered(detailedBolusInfo.carbs) //
.comment(MainApp.gs(R.string.medtronic_cmd_cancel_bolus_not_supported));
} else {
return new PumpEnactResult().success(response) //
.enacted(response) //
.bolusDelivered(detailedBolusInfo.insulin) //
.carbsDelivered(detailedBolusInfo.carbs);
}
} else {
return new PumpEnactResult().success(response) //
.enacted(response) //
.bolusDelivered(detailedBolusInfo.insulin) //
.carbsDelivered(detailedBolusInfo.carbs);
} else {
return new PumpEnactResult() //
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_cmd_bolus_could_not_be_delivered));
}
// pump.activity = MainApp.gs(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin);
// MainApp.bus().post(new EventComboPumpUpdateGUI());
//
// // check pump is ready and all pump bolus records are known
// CommandResult stateResult = runCommand(null, 2, () -> ruffyScripter.readQuickInfo(1));
// if (!stateResult.success) {
// return new PumpEnactResult().success(false).enacted(false)
// .comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered));
// }
// if (stateResult.reservoirLevel != -1 && stateResult.reservoirLevel - 0.5 < detailedBolusInfo.insulin) {
// return new PumpEnactResult().success(false).enacted(false)
// .comment(MainApp.gs(R.string.combo_reservoir_level_insufficient_for_bolus));
// }
// // the commands above ensured a connection was made, which updated this field
// if (pumpHistoryChanged) {
// return new PumpEnactResult().success(false).enacted(false)
// .comment(MainApp.gs(R.string.combo_bolus_rejected_due_to_pump_history_change));
// }
//
// Bolus previousBolus = stateResult.history != null && !stateResult.history.bolusHistory.isEmpty()
// ? stateResult.history.bolusHistory.get(0)
// : new Bolus(0, 0, false);
//
// // reject a bolus if one with the exact same size was successfully delivered
// // within the last 1-2 minutes
// if (Math.abs(previousBolus.amount - detailedBolusInfo.insulin) < 0.01
// && previousBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
// log.debug("Bolu request rejected, same bolus was successfully delivered very recently");
// return new PumpEnactResult().success(false).enacted(false)
// .comment(MainApp.gs(R.string.bolus_frequency_exceeded));
// }
//
//
//
// if (cancelBolus) {
// return new PumpEnactResult().success(true).enacted(false);
// }
//
// BolusProgressReporter progressReporter = detailedBolusInfo.isSMB ? nullBolusProgressReporter :
// bolusProgressReporter;
//
// // start bolus delivery
// scripterIsBolusing = true;
// runCommand(null, 0,
// () -> ruffyScripter.deliverBolus(detailedBolusInfo.insulin, progressReporter));
// scripterIsBolusing = false;
//
// // Note that the result of the issued bolus command is not checked. If there was
// // a connection problem, ruffyscripter tried to recover and we can just check the
// // history below to see what was actually delivered
//
// // get last bolus from pump history for verification
// // (reads 2 records to update `recentBoluses` further down)
// CommandResult postBolusStateResult = runCommand(null, 3, () -> ruffyScripter.readQuickInfo(2));
// if (!postBolusStateResult.success) {
// return new PumpEnactResult().success(false).enacted(false)
// .comment(MainApp.gs(R.string.combo_error_bolus_verification_failed));
// }
// Bolus lastPumpBolus = postBolusStateResult.history != null &&
// !postBolusStateResult.history.bolusHistory.isEmpty()
// ? postBolusStateResult.history.bolusHistory.get(0)
// : null;
//
// // no bolus delivered?
// if (lastPumpBolus == null || lastPumpBolus.equals(previousBolus)) {
// if (cancelBolus) {
// return new PumpEnactResult().success(true).enacted(false);
// } else {
// return new PumpEnactResult()
// .success(false)
// .enacted(false)
// .comment(MainApp.gs(R.string.combo_error_no_bolus_delivered));
// }
// }
//
// // at least some insulin delivered, so add it to treatments
// if (!addBolusToTreatments(detailedBolusInfo, lastPumpBolus))
// return new PumpEnactResult().success(false).enacted(true)
// .comment(MainApp.gs(R.string.combo_error_updating_treatment_record));
//
// // check pump bolus record has a sane timestamp
// long now = System.currentTimeMillis();
// if (lastPumpBolus.timestamp < now - 10 * 60 * 1000 || lastPumpBolus.timestamp > now + 10 * 60 * 1000) {
// Notification notification = new Notification(Notification.COMBO_PUMP_ALARM,
// MainApp.gs(R.string.combo_suspious_bolus_time), Notification.URGENT);
// MainApp.bus().post(new EventNewNotification(notification));
// }
//
// // update `recentBoluses` so the bolus was just delivered won't be detected as a new
// // bolus that has been delivered on the pump
// recentBoluses = postBolusStateResult.history.bolusHistory;
//
// // only a partial bolus was delivered
// if (Math.abs(lastPumpBolus.amount - detailedBolusInfo.insulin) > 0.01) {
// if (cancelBolus) {
// return new PumpEnactResult().success(true).enacted(true);
// }
// return new PumpEnactResult().success(false).enacted(true)
// .comment(MainApp.gs(R.string.combo_error_partial_bolus_delivered,
// lastPumpBolus.amount, detailedBolusInfo.insulin));
// }
//
// // full bolus was delivered successfully
// incrementBolusCount();
// return new PumpEnactResult()
// .success(true)
// .enacted(lastPumpBolus.amount > 0)
// .bolusDelivered(lastPumpBolus.amount)
// .carbsDelivered(detailedBolusInfo.carbs);
} finally {
// pump.activity = null;
// MainApp.bus().post(new EventComboPumpUpdateGUI());
MainApp.bus().post(new EventRefreshOverview("Bolus"));
// cancelBolus = false;
this.bolusDeliveryType = BolusDeliveryType.Idle;
triggerUIChange();
}
}
@ -903,7 +784,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
this.bolusDeliveryType = BolusDeliveryType.CancelDelivery;
// if (isLoggingEnabled())
LOG.warn("MedtronicPumpPlugin::deliverBolus - Stop Bolus Delivery.");
// LOG.warn("MedtronicPumpPlugin::deliverBolus - Stop Bolus Delivery.");
}
@ -1183,6 +1064,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
gsonInstancePretty.toJson(lastPumpHistoryEntry));
medtronicHistoryData.setIsInInit(false);
medtronicHistoryData.setLastHistoryRecordTime(null);
// targetDate = lastPumpHistoryEntry.atechDateTime;
}
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.GetHistoryData,

View file

@ -180,7 +180,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
pumpResponse.getRawContent());
MedtronicDeviceType pumpModel = (MedtronicDeviceType)dataResponse;
boolean valid = pumpModel != MedtronicDeviceType.Unknown_Device;
boolean valid = (pumpModel != MedtronicDeviceType.Unknown_Device);
if (MedtronicUtil.getMedtronicPumpModel() == null && valid) {
MedtronicUtil.setMedtronicPumpModel(pumpModel);
}
LOG.debug("isDeviceReachable. PumpModel is {} - Valid: {} (rssi={})", pumpModel.name(), valid,
radioResponse.rssi);
@ -412,7 +416,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
public PumpHistoryResult getPumpHistory(PumpHistoryEntry lastEntry, LocalDateTime targetDate) {
PumpHistoryResult pumpTotalResult = new PumpHistoryResult(lastEntry, DateTimeUtil.toATechDate(targetDate));
PumpHistoryResult pumpTotalResult = new PumpHistoryResult(lastEntry, targetDate == null ? null
: DateTimeUtil.toATechDate(targetDate));
if (doWakeUpBeforeCommand)
wakeUp(receiverDeviceAwakeForMinutes, false);

View file

@ -6,9 +6,12 @@ import java.util.Map;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.annotations.Expose;
import info.nightscout.androidaps.plugins.PumpCommon.utils.ByteUtil;
import info.nightscout.androidaps.plugins.PumpCommon.utils.DateTimeUtil;
import info.nightscout.androidaps.plugins.PumpCommon.utils.HexDump;
import info.nightscout.androidaps.plugins.PumpCommon.utils.StringUtil;
@ -39,6 +42,7 @@ public abstract class MedtronicHistoryEntry implements MedtronicHistoryEntryInte
protected List<Byte> rawData;
protected static DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("dd.MM.yyyy HH:mm:ss");
public static final Logger LOG = LoggerFactory.getLogger(MedtronicHistoryEntry.class);
protected int[] sizes = new int[3];
@ -142,8 +146,12 @@ public abstract class MedtronicHistoryEntry implements MedtronicHistoryEntryInte
public String toString() {
StringBuilder sb = new StringBuilder();
if (this.DT == null) {
LOG.error("DT is null. RawData={}", ByteUtil.getHex(this.rawData));
}
sb.append(getToStringStart());
sb.append(", DT: " + StringUtil.getStringInLength(this.DT, 19));
sb.append(", DT: " + (this.DT == null ? "null" : StringUtil.getStringInLength(this.DT, 19)));
sb.append(", length=");
sb.append(getHeadLength());
sb.append(",");

View file

@ -187,11 +187,6 @@ public class MedtronicUITask {
}
public boolean haveData() {
return (returnData != null);
}
public void postProcess(MedtronicUIPostprocessor postprocessor) {
EventMedtronicDeviceStatusChange statusChange;

View file

@ -16,6 +16,7 @@ public class MedtronicConst {
public static final String PumpFrequency = PrefPrefix + "frequency";
public static final String MaxBolus = PrefPrefix + "max_bolus";
public static final String MaxBasal = PrefPrefix + "max_basal";
public static final String BolusDelay = PrefPrefix + "bolus_delay";
}
public class Statistics {

View file

@ -0,0 +1,29 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="info.nightscout.androidaps.plugins.Overview.Dialogs.MessageDialog"
android:paddingTop="15dp"
android:paddingBottom="15dp">
<TextView
android:id="@+id/overview_message_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:layout_gravity="center_horizontal" />
<Button
android:id="@+id/overview_message_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:text="@string/ok" />
</LinearLayout>

View file

@ -6,5 +6,5 @@
<item
android:id="@+id/rileylink_miScan"
app:showAsAction="ifRoom"
android:title="Scan"></item>
android:title="@string/rileylink_scanner_scan_scan"></item>
</menu>

View file

@ -1222,10 +1222,6 @@
<!-- Pump Abstract -->
<string name="pump_operation_not_supported_by_pump_driver">Operation not supported by pump and/or driver.</string>
<string name="pump_operation_not_yet_supported_by_pump">Operation not YET supported by pump.</string>
<string name="location_not_found_title">Location Is Not Enabled</string>
<string name="location_not_found_message">For Bluetooth discovery to work on newer devices, location must be enabled. AAPS does not track your location and it can be disabled after pairing is successful.</string>
<string name="location_yes">Enable</string>
<string name="location_no">No</string>
<!-- Medtronic (MDT) - Base -->
<string name="medtronic_name" translatable="false">Medtronic</string>
@ -1245,11 +1241,25 @@
<string name="medtronic_pump_encoding_4b6b_local">Local 4b6b Encoding</string>
<string name="medtronic_pump_encoding_4b6b_rileylink">RileyLink 4b6b Encoding</string>
<string name="rileylink_mac_address">RileyLink MAC Address</string>
<string name="medtronic_custom_action_wake_and_tune">Wake and Tune Up</string>
<!-- RL BLE Scanning -->
<string name="rileylink_scanner_scan_scan">SCAN</string>
<string name="rileylink_scanner_scan_stop">STOP</string>
<string name="rileylink_scanner_selected_device">Selected</string>
<string name="rileylink_scanner_scan">Scan</string>
<string name="rileylink_scanner_title">RileyLink Scan</string>
<string name="rileylink_scanner_scan_menu">Scan for RileyLink</string>
<string name="medtronic_custom_action_wake_and_tune">Wake and Tune Up</string>
<string name="rileylink_scanner_ble_not_supported">Bluetooth Low Energy not supported.</string>
<string name="rileylink_scanner_ble_not_enabled">Bluetooth not enabled.</string>
<string name="location_not_found_title">Location Is Not Enabled</string>
<string name="location_not_found_message">For Bluetooth discovery to work on newer devices, location must be enabled. AAPS does not track your location and it can be disabled after pairing is successful.</string>
<string name="location_yes">Enable</string>
<string name="location_no">No</string>
<string name="rileylink_scanner_scanning">Scanning</string>
<string name="rileylink_scanner_scanning_finished">Scanning finished</string>
<string name="rileylink_scanner_scanning_error">Scanning error: %1$d</string>
<!-- RL Status Page -->
<string name="rileylink_settings_tab1">Settings</string>
@ -1295,6 +1305,7 @@
<string name="rileylink_target_device_medtronic">Medtronic Pump</string>
<string name="rileylink_target_device_omnipod">Omnipod</string>
<!-- MDT Errors -->
<string name="medtronic_errors">Errors</string>
<string name="medtronic_error_serial_not_set">Serial # not set.</string>
@ -1334,7 +1345,7 @@
<string name="medtronic_pump_status_sleeping">Sleeping</string>
<!-- <string name="medtronic_cmd_profile_not_set">Remote Basal profile setting is not supported. Please modify Basal profile on your pump manually.</string> -->
<string name="medtronic_cmd_cancel_bolus_not_supported">You cancelled Bolus, after it was already sent to Pump. Since Medtronic Pumps don&#44;t support cancel, you need to get Pump and put it into Suspend mode and then do Resume. Application will pick up changes, on next update.</string>
<string name="medtronic_cmd_cancel_bolus_not_supported">You cancelled Bolus, after it was already set on Pump. Since Medtronic Pump doesn\'t support cancel, you will need to manually cancel it. Put the Pump into Suspend mode and then do Resume (if you still want to cancel). Application will pick up changes, on next update (in less than 5 minutes).</string>
<string name="medtronic_cmd_cant_read_tbr">Could not read current TBR.</string>
<string name="medtronic_cmd_cant_cancel_tbr_stop_op">Could not cancel current TBR. Stopping operation.</string>
<string name="medtronic_cmd_set_profile_pattern_overflow">Profile set failed, because following patterns, have too big basal rate: %1$s</string>