added git HEAD and version to pump status and logs

This commit is contained in:
Milos Kozak 2016-11-08 19:10:25 +01:00
parent 94a7033e0c
commit a2d4f22bd7
4 changed files with 30 additions and 0 deletions

View file

@ -14,6 +14,26 @@ repositories {
maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.fabric.io/public' }
} }
def generateGitBuild = { ->
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append('"')
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always'
standardOutput = stdout
}
String commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
} catch (ignored) {
return "NoGitSystemAvailable";
}
stringBuilder.append('-')
stringBuilder.append((new Date()).format('yyyy.MM.dd'))
stringBuilder.append('"')
return stringBuilder.toString()
}
android { android {
compileSdkVersion 23 compileSdkVersion 23
@ -25,6 +45,7 @@ android {
targetSdkVersion 23 targetSdkVersion 23
versionCode 1020 versionCode 1020
versionName "1.0.20" versionName "1.0.20"
buildConfigField "String", "BUILDVERSION", generateGitBuild()
} }
lintOptions { lintOptions {
disable 'MissingTranslation' disable 'MissingTranslation'

View file

@ -54,6 +54,9 @@ public class MainApp extends Application {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
Fabric.with(this, new Crashlytics()); Fabric.with(this, new Crashlytics());
Crashlytics.setString("BUILDVERSION", BuildConfig.BUILDVERSION);
log.info("Version: " + BuildConfig.VERSION_NAME);
log.info("BuildVersion: " + BuildConfig.BUILDVERSION);
sBus = new Bus(ThreadEnforcer.ANY); sBus = new Bus(ThreadEnforcer.ANY);
sInstance = this; sInstance = this;

View file

@ -20,6 +20,7 @@ import java.text.DateFormat;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -592,6 +593,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
battery.put("percent", getDanaRPump().batteryRemaining); battery.put("percent", getDanaRPump().batteryRemaining);
status.put("status", "normal"); status.put("status", "normal");
status.put("timestamp", DateUtil.toISOString(getDanaRPump().lastConnection)); status.put("timestamp", DateUtil.toISOString(getDanaRPump().lastConnection));
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
extended.put("PumpIOB", getDanaRPump().iob); extended.put("PumpIOB", getDanaRPump().iob);
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString()); extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount); extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);

View file

@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -330,9 +331,11 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
JSONObject pump = new JSONObject(); JSONObject pump = new JSONObject();
JSONObject battery = new JSONObject(); JSONObject battery = new JSONObject();
JSONObject status = new JSONObject(); JSONObject status = new JSONObject();
JSONObject extended = new JSONObject();
try { try {
battery.put("percent", batteryPercent); battery.put("percent", batteryPercent);
status.put("status", "normal"); status.put("status", "normal");
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
TempBasal tb; TempBasal tb;
if ((tb = getTempBasal()) != null) { if ((tb = getTempBasal()) != null) {
status.put("tempbasalpct", tb.percent); status.put("tempbasalpct", tb.percent);
@ -343,6 +346,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
pump.put("battery", battery); pump.put("battery", battery);
pump.put("status", status); pump.put("status", status);
pump.put("extended", extended);
pump.put("reservoir", reservoirInUnits); pump.put("reservoir", reservoirInUnits);
pump.put("clock", DateUtil.toISOString(new Date())); pump.put("clock", DateUtil.toISOString(new Date()));
} catch (JSONException e) { } catch (JSONException e) {