Skip to content
Snippets Groups Projects
Commit a0dcbfce authored by Lennart Goedhart's avatar Lennart Goedhart
Browse files
parents 8c3e3d0f e9a19af3
No related branches found
No related tags found
No related merge requests found
import org.ajoberstar.grgit.Grgit
buildscript { buildscript {
repositories { repositories {
maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.fabric.io/public' }
...@@ -6,6 +8,7 @@ buildscript { ...@@ -6,6 +8,7 @@ buildscript {
dependencies { dependencies {
classpath 'io.fabric.tools:gradle:1.21.6' classpath 'io.fabric.tools:gradle:1.21.6'
classpath 'io.realm:realm-gradle-plugin:1.1.0' classpath 'io.realm:realm-gradle-plugin:1.1.0'
classpath 'org.ajoberstar:grgit:1.5.0'
} }
} }
plugins { plugins {
...@@ -23,8 +26,25 @@ apply plugin: 'io.fabric' ...@@ -23,8 +26,25 @@ apply plugin: 'io.fabric'
apply plugin: 'realm-android' apply plugin: 'realm-android'
def gitVersion() { def gitVersion() {
def process = ['sh', '-c', 'git tag -l | grep -c ".*" -'].execute().text.trim() // current dir is <your proj>/app, so it's likely that all your git repo files are in the dir
return process.toInteger() + 1 // above.
ext.repo = Grgit.open(project.file('..'))
// should result in the same value as running
// git tag -l | wc -l or git tag -l | grep -c ".*" -
def numOfTags = ext.repo.tag.list().size()
return numOfTags
}
def gitCommitId() {
//def process = ['sh', '-c', 'git tag -l | grep -c ".*" -'].execute().text.trim()
//return process.toInteger() + 1
//return 42
// current dir is <your proj>/app, so it's likely that all your git repo files are in the dir
// above.
ext.repo = Grgit.open(project.file('..'))
return ext.repo.log().first().id.substring(0, 7)
} }
def getBugfenderApiKey() { def getBugfenderApiKey() {
...@@ -47,7 +67,7 @@ android { ...@@ -47,7 +67,7 @@ android {
applicationId "info.nightscout.android" applicationId "info.nightscout.android"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 23 targetSdkVersion 23
versionName project.properties['version'] versionName project.properties['version'] + "/" + gitCommitId()
versionCode gitVersion() versionCode gitVersion()
buildConfigField "String", "BUGFENDER_API_KEY", getBugfenderApiKey() buildConfigField "String", "BUGFENDER_API_KEY", getBugfenderApiKey()
} }
......
...@@ -15,7 +15,6 @@ import android.hardware.usb.UsbManager; ...@@ -15,7 +15,6 @@ import android.hardware.usb.UsbManager;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.SystemClock;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.TaskStackBuilder; import android.support.v4.app.TaskStackBuilder;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
...@@ -305,7 +304,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc ...@@ -305,7 +304,7 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
} }
private void startCgmService() { private void startCgmService() {
startCgmService(System.currentTimeMillis()); startCgmService(System.currentTimeMillis() + 1000);
} }
private void startCgmService(long initialPoll) { private void startCgmService(long initialPoll) {
...@@ -524,8 +523,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc ...@@ -524,8 +523,6 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
private class RefreshDisplayRunnable implements Runnable { private class RefreshDisplayRunnable implements Runnable {
@Override @Override
public void run() { public void run() {
Log.d(TAG, "NOW " + new Date(System.currentTimeMillis()).toString());
// UI elements - TODO do these need to be members? // UI elements - TODO do these need to be members?
TextView textViewBg = (TextView) findViewById(R.id.textview_bg); TextView textViewBg = (TextView) findViewById(R.id.textview_bg);
TextView textViewBgTime = (TextView) findViewById(R.id.textview_bg_time); TextView textViewBgTime = (TextView) findViewById(R.id.textview_bg_time);
...@@ -630,11 +627,9 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc ...@@ -630,11 +627,9 @@ public class MainActivity extends AppCompatActivity implements OnSharedPreferenc
return; return;
} }
long nextPoll = pumpStatusData.getEventDate().getTime() + MedtronicCnlIntentService.POLL_GRACE_PERIOD_MS + MedtronicCnlIntentService.POLL_PERIOD_MS; long nextPoll = pumpStatusData.getEventDate().getTime() + pumpStatusData.getPumpTimeOffset()
+ MedtronicCnlIntentService.POLL_GRACE_PERIOD_MS + MedtronicCnlIntentService.POLL_PERIOD_MS;
startCgmService(nextPoll); startCgmService(nextPoll);
Log.d(TAG, "Local time " + new Date());
Log.d(TAG, "Last event was " + new Date(pumpStatusData.getEventDate().getTime()));
Log.d(TAG, "Next Poll at " + new Date(nextPoll).toString());
// Delete invalid or old records from Realm // Delete invalid or old records from Realm
// TODO - show an error message if the valid records haven't been uploaded // TODO - show an error message if the valid records haven't been uploaded
......
...@@ -214,8 +214,10 @@ public class MedtronicCnlIntentService extends IntentService { ...@@ -214,8 +214,10 @@ public class MedtronicCnlIntentService extends IntentService {
long pumpTime = cnlReader.getPumpTime().getTime(); long pumpTime = cnlReader.getPumpTime().getTime();
long pumpOffset = pumpTime - System.currentTimeMillis(); long pumpOffset = pumpTime - System.currentTimeMillis();
Log.d(TAG, "Time offset between pump and device: " + pumpOffset + " millis.");
// TODO - send ACTION to MainActivity to show offset between pump and uploader. // TODO - send ACTION to MainActivity to show offset between pump and uploader.
pumpRecord.setPumpTimeOffset(pumpOffset);
pumpRecord.setPumpDate(new Date(pumpTime - pumpOffset)); pumpRecord.setPumpDate(new Date(pumpTime - pumpOffset));
cnlReader.getPumpStatus(pumpRecord, pumpOffset); cnlReader.getPumpStatus(pumpRecord, pumpOffset);
activePump.getPumpHistory().add(pumpRecord); activePump.getPumpHistory().add(pumpRecord);
......
...@@ -3,6 +3,7 @@ package info.nightscout.android.model.medtronicNg; ...@@ -3,6 +3,7 @@ package info.nightscout.android.model.medtronicNg;
import java.util.Date; import java.util.Date;
import io.realm.RealmObject; import io.realm.RealmObject;
import io.realm.annotations.Ignore;
import io.realm.annotations.Index; import io.realm.annotations.Index;
/** /**
...@@ -38,6 +39,9 @@ public class PumpStatusEvent extends RealmObject { ...@@ -38,6 +39,9 @@ public class PumpStatusEvent extends RealmObject {
private boolean recentBolusWizard; // Whether a bolus wizard has been run recently private boolean recentBolusWizard; // Whether a bolus wizard has been run recently
private int bolusWizardBGL; // in mg/dL. 0 means no recent bolus wizard reading. private int bolusWizardBGL; // in mg/dL. 0 means no recent bolus wizard reading.
@Ignore
private long pumpTimeOffset; // millis the pump is ahead
@Index @Index
private boolean uploaded = false; private boolean uploaded = false;
...@@ -249,6 +253,14 @@ public class PumpStatusEvent extends RealmObject { ...@@ -249,6 +253,14 @@ public class PumpStatusEvent extends RealmObject {
this.recentBolusWizard = recentBolusWizard; this.recentBolusWizard = recentBolusWizard;
} }
public long getPumpTimeOffset() {
return pumpTimeOffset;
}
public void setPumpTimeOffset(long pumpTimeOffset) {
this.pumpTimeOffset = pumpTimeOffset;
}
public enum CGM_TREND { public enum CGM_TREND {
NONE, NONE,
DOUBLE_UP, DOUBLE_UP,
......
...@@ -31,7 +31,6 @@ import java.util.regex.Pattern; ...@@ -31,7 +31,6 @@ import java.util.regex.Pattern;
import info.nightscout.android.R; import info.nightscout.android.R;
import info.nightscout.android.medtronic.MainActivity; import info.nightscout.android.medtronic.MainActivity;
import info.nightscout.android.medtronic.service.MedtronicCnlIntentService;
import info.nightscout.android.model.medtronicNg.PumpStatusEvent; import info.nightscout.android.model.medtronicNg.PumpStatusEvent;
import info.nightscout.android.upload.nightscout.serializer.EntriesSerializer; import info.nightscout.android.upload.nightscout.serializer.EntriesSerializer;
import io.realm.Realm; import io.realm.Realm;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment