Skip to content
Snippets Groups Projects
Commit a89be295 authored by Lennart Goedhart's avatar Lennart Goedhart Committed by GitHub
Browse files

Merge pull request #143 from pazaan/release/v0.5.1

Release/v0.5.1
parents 7693b97b 10b50651
No related branches found
No related tags found
No related merge requests found
Showing
with 458 additions and 112 deletions
......@@ -115,6 +115,7 @@ dependencies {
compile 'com.android.support:cardview-v7:25.3.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.mikepenz:google-material-typeface:2.2.0.1.original@aar'
compile 'com.mikepenz:ionicons-typeface:2.0.1.3@aar'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.bugfender.sdk:android:0.7.2'
compile 'com.jjoe64:graphview:4.0.1'
......
......@@ -30,11 +30,14 @@ import android.support.v7.app.NotificationCompat;
import android.support.v7.view.menu.ActionMenuItemView;
import android.support.v7.widget.Toolbar;
import android.text.format.DateUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.TextView.BufferType;
import android.widget.Toast;
......@@ -96,11 +99,23 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
private SharedPreferences prefs = null;
private PumpInfo mActivePump;
private TextView mTextViewLog; // This will eventually move to a status page.
private ScrollView mScrollView;
private GraphView mChart;
private Handler mUiRefreshHandler = new Handler();
private Runnable mUiRefreshRunnable = new RefreshDisplayRunnable();
private Realm mRealm;
private StatusMessageReceiver statusMessageReceiver = new StatusMessageReceiver();
private UsbReceiver usbReceiver = new UsbReceiver();
private BatteryReceiver batteryReceiver = new BatteryReceiver();
private DateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss", Locale.US);
protected void sendStatus(String message) {
Intent localIntent =
new Intent(MedtronicCnlIntentService.Constants.ACTION_STATUS_MESSAGE)
.putExtra(MedtronicCnlIntentService.Constants.EXTENDED_DATA, message);
LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);
}
/**
* calculate the next poll timestamp based on last svg event
......@@ -109,7 +124,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
* @return timestamp
*/
public static long getNextPoll(PumpStatusEvent pumpStatusData) {
long nextPoll = pumpStatusData.getSgvDate().getTime() + pumpStatusData.getPumpTimeOffset(),
long nextPoll = pumpStatusData.getSgvDate().getTime(),
now = System.currentTimeMillis(),
pollInterval = ConfigurationStore.getInstance().getPollInterval();
......@@ -198,9 +213,8 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
batteryIntentFilter.addAction(Intent.ACTION_BATTERY_LOW);
batteryIntentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
batteryIntentFilter.addAction(Intent.ACTION_BATTERY_OKAY);
registerReceiver(new BatteryReceiver(), batteryIntentFilter);
registerReceiver(batteryReceiver, batteryIntentFilter);
UsbReceiver usbReceiver = new UsbReceiver();
IntentFilter usbIntentFilter = new IntentFilter();
usbIntentFilter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
usbIntentFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
......@@ -285,7 +299,8 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
finish();
} else if (drawerItem.equals(itemGetNow)) {
// It was triggered by user so start reading of data now and not based on last poll.
startCgmService(0);
sendStatus("Requesting poll now...");
startCgmService(System.currentTimeMillis() + 1000);
} else if (drawerItem.equals(itemClearLog)) {
clearLogText();
} else if (drawerItem.equals(itemCheckForUpdate)) {
......@@ -298,12 +313,17 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
.build();
mTextViewLog = (TextView) findViewById(R.id.textview_log);
mScrollView = (ScrollView) findViewById(R.id.scrollView);
mScrollView.setSmoothScrollingEnabled(true);
mChart = (GraphView) findViewById(R.id.chart);
// disable scrolling at the moment
mChart.getViewport().setScalable(false);
mChart.getViewport().setScrollable(false);
mChart.getViewport().setYAxisBoundsManual(true);
mChart.getViewport().setMinY(80);
mChart.getViewport().setMaxY(120);
mChart.getViewport().setXAxisBoundsManual(true);
final long now = System.currentTimeMillis(),
left = now - chartZoom * 60 * 60 * 1000;
......@@ -363,8 +383,9 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
startCgmService();
startDisplayRefreshLoop();
statusStartup();
startCgmService();
}
@Override
......@@ -419,11 +440,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
}
private void refreshDisplay() {
cancelDisplayRefreshLoop();
startDisplayRefreshLoop();
}
private void clearLogText() {
statusMessageReceiver.clearMessages();
}
......@@ -444,8 +460,23 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
.start();
}
private void statusStartup() {
sendStatus(MedtronicCnlIntentService.ICON_HEART + "Nightscout 600 Series Uploader");
sendStatus(MedtronicCnlIntentService.ICON_SETTING + "Poll interval: " + (configurationStore.getPollInterval() / 60000) +" minutes");
sendStatus(MedtronicCnlIntentService.ICON_SETTING + "Low battery poll interval: " + (configurationStore.getLowBatteryPollInterval() / 60000) +" minutes");
}
private void refreshDisplay() {
cancelDisplayRefreshLoop();
mUiRefreshHandler.post(mUiRefreshRunnable);;
}
private void refreshDisplay(int delay) {
cancelDisplayRefreshLoop();
mUiRefreshHandler.postDelayed(mUiRefreshRunnable, delay);
}
private void startDisplayRefreshLoop() {
mUiRefreshHandler.post(mUiRefreshRunnable);
refreshDisplay(50);
}
private void cancelDisplayRefreshLoop() {
......@@ -461,10 +492,15 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
RealmResults<PumpStatusEvent> results = mRealm.where(PumpStatusEvent.class)
.findAllSorted("eventDate", Sort.DESCENDING);
if (results.size() > 0) {
startCgmService(getNextPoll(results.first()) + delay);
long nextPoll = getNextPoll(results.first());
long pollInterval = results.first().getBatteryPercentage() > 25 ? ConfigurationStore.getInstance().getPollInterval() : ConfigurationStore.getInstance().getLowBatteryPollInterval();
if ((nextPoll - MedtronicCnlIntentService.POLL_GRACE_PERIOD_MS - results.first().getSgvDate().getTime()) <= pollInterval) {
startCgmService(nextPoll + delay);
sendStatus("Next poll due at: " + dateFormatter.format(nextPoll + delay));
return;
}
}
}
startCgmService(System.currentTimeMillis() + (delay == 0 ? 1000 : delay));
}
......@@ -518,16 +554,32 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
notificationManager.cancel(MainActivity.USB_DISCONNECT_NOFICATION_ID);
}
@Override
protected void onResume() {
Log.i(TAG, "onResume called");
super.onResume();
// Focus status log to most recent on returning to app
mScrollView.post(new Runnable() {
public void run() {
mScrollView.fullScroll(View.FOCUS_DOWN);
}
});
}
@Override
protected void onDestroy() {
Log.i(TAG, "onDestroy called");
super.onDestroy();
unregisterReceiver(usbReceiver);
unregisterReceiver(batteryReceiver);
PreferenceManager.getDefaultSharedPreferences(getBaseContext()).unregisterOnSharedPreferenceChangeListener(this);
cancelDisplayRefreshLoop();
if (!mRealm.isClosed()) {
mRealm.close();
}
if (!mEnableCgmService) {
stopCgmService();
}
......@@ -588,7 +640,12 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
if (activePumpMac != 0L && (mActivePump == null || !mActivePump.isValid() || mActivePump.getPumpMac() != activePumpMac)) {
if (mActivePump != null) {
// remove listener on old pump
mRealm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm sRealm) {
mActivePump.removeAllChangeListeners();
}
});
mActivePump = null;
}
......@@ -598,6 +655,11 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
.findFirst();
if (pump != null && pump.isValid()) {
// first change listener start can miss fresh data and not update until next poll, force a refresh now
RemoveOutdatedRecords();
refreshDisplay(1000);
mActivePump = pump;
mActivePump.addChangeListener(new RealmChangeListener<PumpInfo>() {
long lastQueryTS = 0;
......@@ -611,15 +673,27 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
lastQueryTS = pump.getLastQueryTS();
RemoveOutdatedRecords();
refreshDisplay(1000);
// TODO - handle isOffline in NightscoutUploadIntentService?
}
});
}
}
return mActivePump;
}
private void RemoveOutdatedRecords() {
// Delete invalid or old records from Realm
// TODO - show an error message if the valid records haven't been uploaded
final RealmResults<PumpStatusEvent> results =
mRealm.where(PumpStatusEvent.class)
.equalTo("sgv", 0)
.or()
.lessThan("eventDate", new Date(System.currentTimeMillis() - (24 * 60 * 60 * 1000)))
.lessThan("sgvDate", new Date(System.currentTimeMillis() - (24 * 60 * 60 * 1000)))
.findAll();
if (results.size() > 0) {
mRealm.executeTransaction(new Realm.Transaction() {
@Override
......@@ -630,18 +704,8 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
});
}
// TODO - handle isOffline in NightscoutUploadIntentService?
refreshDisplay();
}
});
}
}
return mActivePump;
}
public static String strFormatSGV(double sgvValue) {
ConfigurationStore configurationStore = ConfigurationStore.getInstance();
......@@ -660,6 +724,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
public static String renderTrendSymbol(PumpStatusEvent.CGM_TREND trend) {
// TODO - symbols used for trend arrow may vary per device, find a more robust solution
switch (trend) {
case DOUBLE_UP:
return "\u21c8";
......@@ -721,6 +786,15 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
mTextViewLog.setText(sb.toString(), BufferType.EDITABLE);
// auto scroll status log
if ((mScrollView.getChildAt(0).getBottom() < mScrollView.getHeight()) || ((mScrollView.getChildAt(0).getBottom() - mScrollView.getScrollY() - mScrollView.getHeight()) < (mScrollView.getHeight() / 3))) {
mScrollView.post(new Runnable() {
public void run() {
mScrollView.fullScroll(View.FOCUS_DOWN);
}
});
}
}
public void clearMessages() {
......@@ -735,6 +809,8 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
private class RefreshDisplayRunnable implements Runnable {
@Override
public void run() {
long nextRun = 60000L;
TextView textViewBg = (TextView) findViewById(R.id.textview_bg);
TextView textViewBgTime = (TextView) findViewById(R.id.textview_bg_time);
TextView textViewUnits = (TextView) findViewById(R.id.textview_units);
......@@ -754,6 +830,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
updateChart(mRealm.where(PumpStatusEvent.class)
.notEqualTo("sgv", 0)
.greaterThan("sgvDate", new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24))
.findAllSorted("sgvDate", Sort.ASCENDING));
......@@ -770,6 +847,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
sgvString = "\u2014"; // &mdash;
}
nextRun = 60000L - (System.currentTimeMillis() - pumpStatusData.getSgvDate().getTime()) % 60000L;
textViewBg.setText(sgvString);
textViewBgTime.setText(DateUtils.getRelativeTimeSpanString(pumpStatusData.getSgvDate().getTime()));
......@@ -807,8 +885,8 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
// Run myself again in 60 seconds;
mUiRefreshHandler.postDelayed(this, 60000L);
// Run myself again in 60 (or less) seconds;
mUiRefreshHandler.postDelayed(this, nextRun);
}
private void updateChart(RealmResults<PumpStatusEvent> results) {
......@@ -879,7 +957,12 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
paint.setColor(Color.YELLOW);
else
paint.setColor(Color.RED);
canvas.drawCircle(x, y, 3.6f, paint);
float dotSize = 3.0f;
if (chartZoom == 3) dotSize = 2.0f;
else if (chartZoom == 6) dotSize = 2.0f;
else if (chartZoom == 12) dotSize = 1.65f;
else if (chartZoom == 24) dotSize = 1.25f;
canvas.drawCircle(x, y, dipToPixels(getApplicationContext(), dotSize), paint);
}
});
......@@ -891,13 +974,28 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
}
}
// TODO - chart viewport needs rework as currently using a workaround to handle updating
// set viewport to latest SGV
long lastSGVTimestamp = (long) mChart.getSeries().get(0).getHighestValueX();
long min_x = (((lastSGVTimestamp + 150000 - (chartZoom * 60 * 60 * 1000)) / 60000) * 60000);
long max_x = lastSGVTimestamp + 90000;
if (!hasZoomedChart) {
mChart.getViewport().setMaxX(lastSGVTimestamp);
mChart.getViewport().setMinX(lastSGVTimestamp - chartZoom * 60 * 60 * 1000);
mChart.getViewport().setMinX(min_x);
mChart.getViewport().setMaxX(max_x);
}
if (entries.length > 0) {
((PointsGraphSeries) mChart.getSeries().get(0)).resetData(entries);
}
}
}
private static float dipToPixels(Context context, float dipValue) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics);
}
/**
......@@ -938,7 +1036,8 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
if (mEnableCgmService) {
clearDisconnectionNotification();
}
dataStore.clearAllCommsErrors();
sendStatus(MedtronicCnlIntentService.ICON_INFO + "Contour Next Link plugged in.");
if (hasUsbPermission()) {
// Give the USB a little time to warm up first
startCgmServiceDelayed(MedtronicCnlIntentService.USB_WARMUP_TIME_MS);
......@@ -950,6 +1049,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
Log.d(TAG, "USB unplugged");
if (mEnableCgmService) {
showDisconnectionNotification("USB Error", "Contour Next Link unplugged.");
sendStatus(MedtronicCnlIntentService.ICON_WARN + "USB error. Contour Next Link unplugged.");
}
} else if (MedtronicCnlIntentService.Constants.ACTION_NO_USB_PERMISSION.equals(action)) {
Log.d(TAG, "No permission to read the USB device.");
......
......@@ -40,10 +40,18 @@ public class MedtronicResponseMessage extends ContourNextLinkResponseMessage {
// Replace the encrypted bytes by their decrypted equivalent (same block size)
byte encryptedPayloadSize = payload[56];
if (encryptedPayloadSize == 0) {
throw new EncryptionException( "Could not decrypt Medtronic Message (encryptedPayloadSize == 0)" );
}
ByteBuffer encryptedPayload = ByteBuffer.allocate(encryptedPayloadSize);
encryptedPayload.put(payload, 57, encryptedPayloadSize);
byte[] decryptedPayload = decrypt(pumpSession.getKey(), pumpSession.getIV(), encryptedPayload.array());
if (decryptedPayload == null) {
throw new EncryptionException( "Could not decrypt Medtronic Message (decryptedPayload == null)" );
}
// Now that we have the decrypted payload, rewind the mPayload, and overwrite the bytes
// TODO - because this messes up the existing CCITT, do we want to have a separate buffer for the decrypted payload?
// Should be fine provided we check the CCITT first...
......
......@@ -42,6 +42,10 @@ public class PumpStatusRequestMessage extends MedtronicSendMessageRequestMessage
}
// Read the 0x80
byte[] payload = readMessage(mDevice);
// if pump sends an unexpected response get the next response as pump can resend or send out of sequence and this avoids comms errors
if (payload.length < 0x9C) {
payload = readMessage(mDevice);
}
// clear unexpected incoming messages
clearMessage(mDevice);
......
......@@ -191,12 +191,18 @@ public class PumpStatusResponseMessage extends MedtronicSendMessageResponseMessa
pumpRecord.setLowSuspendActive(lowSuspendActive);
// Recent Bolus Wizard BGL
pumpRecord.setRecentBolusWizard(recentBolusWizard);
// there is a BolusWizard usage & the IOB increased
if (activeInsulin > DataStore.getInstance().getLastPumpStatus().getActiveInsulin()) {
if (bolusWizardBGL > 0
&& (DataStore.getInstance().getLastPumpStatus().getSgvDate().getTime() - System.currentTimeMillis() > 15 * 60 * 1000
|| (DataStore.getInstance().getLastBolusWizardBGL() != bolusWizardBGL
&& DataStore.getInstance().getLastPumpStatus().getBolusWizardBGL() != bolusWizardBGL)
)
) {
pumpRecord.setRecentBolusWizard(true);
pumpRecord.setBolusWizardBGL(bolusWizardBGL); // In mg/DL
} else {
pumpRecord.setRecentBolusWizard(false);
pumpRecord.setBolusWizardBGL(0); // In mg/DL
}
DataStore.getInstance().setLastBolusWizardBGL(bolusWizardBGL);
}
}
......@@ -37,6 +37,10 @@ public class PumpTimeRequestMessage extends MedtronicSendMessageRequestMessage<P
}
// Read the 0x80
byte[] payload = readMessage(mDevice);
// if pump sends an unexpected response get the next response as pump can resend or send out of sequence and this avoids comms errors
if (payload.length < 0x49) {
payload = readMessage(mDevice);
}
// Pump sends additional 0x80 message when not using EHSM, lets clear this and any unexpected incoming messages
clearMessage(mDevice);
......
......@@ -3,6 +3,7 @@ package info.nightscout.android.medtronic.message;
import info.nightscout.android.medtronic.MedtronicCnlSession;
import info.nightscout.android.medtronic.exception.ChecksumException;
import info.nightscout.android.medtronic.exception.EncryptionException;
import info.nightscout.android.medtronic.exception.UnexpectedMessageException;
/**
* Created by volker on 10.12.2016.
......@@ -14,7 +15,7 @@ public class RequestLinkKeyRequestMessage extends ContourNextLinkBinaryRequestMe
}
@Override
protected RequestLinkKeyResponseMessage getResponse(byte[] payload) throws ChecksumException, EncryptionException {
protected RequestLinkKeyResponseMessage getResponse(byte[] payload) throws ChecksumException, EncryptionException, UnexpectedMessageException {
return new RequestLinkKeyResponseMessage(mPumpSession, payload);
}
}
package info.nightscout.android.medtronic.message;
import android.util.Log;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import info.nightscout.android.medtronic.MedtronicCnlSession;
import info.nightscout.android.medtronic.exception.ChecksumException;
import info.nightscout.android.medtronic.exception.EncryptionException;
import info.nightscout.android.medtronic.exception.UnexpectedMessageException;
/**
* Created by lgoedhart on 10/05/2016.
*/
public class RequestLinkKeyResponseMessage extends MedtronicResponseMessage {
private static final String TAG = RequestLinkKeyResponseMessage.class.getSimpleName();
private byte[] key;
protected RequestLinkKeyResponseMessage(MedtronicCnlSession pumpSession, byte[] payload) throws EncryptionException, ChecksumException {
protected RequestLinkKeyResponseMessage(MedtronicCnlSession pumpSession, byte[] payload) throws EncryptionException, ChecksumException, UnexpectedMessageException {
super(pumpSession, payload);
if (this.encode().length < (0x57 - 4)) {
// Invalid message. Don't try and parse it
// TODO - deal with this more elegantly
Log.e(TAG, "Invalid message received for requestLinkKey");
throw new UnexpectedMessageException("Invalid message received for requestLinkKey, Contour Next Link is not paired with pump.");
}
ByteBuffer infoBuffer = ByteBuffer.allocate(55);
infoBuffer.order(ByteOrder.BIG_ENDIAN);
infoBuffer.put(this.encode(), 0x21, 55);
......
......@@ -53,7 +53,7 @@ public class MedtronicCnlAlarmManager {
cancelAlarm();
Log.d(TAG, "Alarm set to fire at " + new Date(millis));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
alarmManager.setAlarmClock(new AlarmManager.AlarmClockInfo(millis, null), pendingIntent);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// Android 5.0.0 + 5.0.1 (e.g. Galaxy S4) has a bug.
......@@ -66,8 +66,11 @@ public class MedtronicCnlAlarmManager {
// restarting the alarm after MedtronicCnlIntentService.POLL_PERIOD_MS from now
public static void restartAlarm() {
//setAlarmAfterMillis(MainActivity.pollInterval + MedtronicCnlIntentService.POLL_GRACE_PERIOD_MS);
setAlarmAfterMillis(ConfigurationStore.getInstance().getPollInterval()); // grace already accounted for when using current intent time to set default restart
// Due to potential of some versions of android to mangle alarms and clash with polling times
// the default alarm reset is set to POLL_PERIOD_MS + 60 seconds
// It's expected to trigger between polls if alarm has not been honored with a safe margin greater then
// the around 10 minutes that some OS versions force during sleep
setAlarmAfterMillis(MedtronicCnlIntentService.POLL_PERIOD_MS + 60000L); // grace already accounted for when using current intent time to set default restart
}
// Cancel the alarm.
......
package info.nightscout.android.utils;
import org.apache.commons.lang3.time.DateUtils;
import java.util.Date;
import info.nightscout.android.model.medtronicNg.PumpStatusEvent;
......@@ -16,7 +18,13 @@ public class DataStore {
private PumpStatusEvent lastPumpStatus;
private int uploaderBatteryLevel = 0;
private int unavailableSGVCount = 0;
private int lastBolusWizardBGL = 0;
private long activePumpMac = 0;
private int commsErrorCount = 0;
private int commsSuccessCount = 0;
private int commsConnectThreshold = 0;
private int commsSignalThreshold = 0;
private float commsUnavailableThreshold = 0;
private DataStore() {}
......@@ -26,7 +34,8 @@ public class DataStore {
// set some initial dummy values
PumpStatusEvent dummyStatus = new PumpStatusEvent();
dummyStatus.setSgvDate(new Date());
dummyStatus.setSgvDate(DateUtils.addDays(new Date(), -1));
dummyStatus.setSgv(0);
// bypass setter to avoid dealing with a real Realm object
instance.lastPumpStatus = dummyStatus;
......@@ -65,10 +74,19 @@ public class DataStore {
public void clearUnavailableSGVCount() {
this.unavailableSGVCount = 0;
}
public void setUnavailableSGVCount(int unavailableSGVCount) {
this.unavailableSGVCount = unavailableSGVCount;
}
public int getLastBolusWizardBGL() {
return lastBolusWizardBGL;
}
public void setLastBolusWizardBGL(int lastBolusWizardBGL) {
this.lastBolusWizardBGL = lastBolusWizardBGL;
}
public long getActivePumpMac() {
return activePumpMac;
}
......@@ -76,4 +94,81 @@ public class DataStore {
public void setActivePumpMac(long activePumpMac) {
this.activePumpMac = activePumpMac;
}
public int getCommsErrorCount() {
return commsErrorCount;
}
public int incCommsErrorCount() { return commsErrorCount++; }
public int decCommsErrorThreshold() {
if (commsErrorCount > 0) commsErrorCount--;
return commsErrorCount;}
public void clearCommsErrorCount() {
this.commsErrorCount = 0;
}
public int getCommsSuccessCount() {
return commsSuccessCount;
}
public int incCommsSuccessCount() { return commsSuccessCount++; }
public int decCommsSuccessCount() {
if (commsSuccessCount > 0) commsSuccessCount--;
return commsSuccessCount;}
public void clearCommsSuccessCount() {
this.commsSuccessCount = 0;
}
public int getCommsConnectThreshold() {
return commsConnectThreshold;
}
public int incCommsConnectThreshold() { return commsConnectThreshold++; }
public int decCommsConnectThreshold() {
if (commsConnectThreshold > 0) commsConnectThreshold--;
return commsConnectThreshold;}
public void clearCommsConnectThreshold() {
this.commsConnectThreshold = 0;
}
public int getCommsSignalThreshold() {
return commsSignalThreshold;
}
public int incCommsSignalThreshold() { return commsSignalThreshold++; }
public int decCommsSignalThreshold() {
if (commsSignalThreshold > 0) commsSignalThreshold--;
return commsSignalThreshold;}
public void clearCommsSignalThreshold() {
this.commsSignalThreshold = 0;
}
public float getCommsUnavailableThreshold() {
return commsUnavailableThreshold;
}
public float addCommsUnavailableThreshold(float value) {
commsUnavailableThreshold+= value;
if (commsUnavailableThreshold < 0) commsUnavailableThreshold = 0;
return commsUnavailableThreshold;}
public void clearCommsUnavailableThreshold() {
this.commsUnavailableThreshold = 0;
}
public void clearAllCommsErrors() {
this.commsErrorCount = 0;
this.commsSuccessCount = 0;
this.commsConnectThreshold = 0;
this.commsSignalThreshold = 0;
this.commsUnavailableThreshold = 0;
}
}
......@@ -59,8 +59,8 @@
android:textSize="70sp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:gravity="bottom|center_horizontal"
......@@ -135,7 +135,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
<com.mikepenz.iconics.view.IconicsTextView
android:id="@+id/textview_log"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
......
......@@ -3,7 +3,6 @@
<string-array name="poll_interval">
<item>5 min</item>
<item>10 min</item>
<item>12 min</item>
<item>15 min</item>
<item>20 min</item>
<item>30 min</item>
......@@ -14,7 +13,6 @@
<string-array name="poll_interval_millis">
<item>300000</item>
<item>600000</item>
<item>720000</item>
<item>900000</item>
<item>1200000</item>
<item>1800000</item>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment