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' }
}
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 {
compileSdkVersion 23
@ -25,6 +45,7 @@ android {
targetSdkVersion 23
versionCode 1020
versionName "1.0.20"
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}
lintOptions {
disable 'MissingTranslation'

View file

@ -54,6 +54,9 @@ public class MainApp extends Application {
public void onCreate() {
super.onCreate();
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);
sInstance = this;

View file

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

View file

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