Merge branch 'watchfaces' into dev

This commit is contained in:
AdrianLxM 2017-12-02 21:45:39 +01:00 committed by GitHub
commit 07c1084287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 298 additions and 53 deletions

View file

@ -75,6 +75,7 @@ android {
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "true"
buildConfigField "boolean", "G5UPLOADER", "false"
}
openloop {
dimension "standard"
@ -87,6 +88,7 @@ android {
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "false"
buildConfigField "boolean", "G5UPLOADER", "false"
}
pumpcontrol {
dimension "standard"
@ -99,6 +101,7 @@ android {
buildConfigField "boolean", "PUMPDRIVERS", "true"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "false"
buildConfigField "boolean", "G5UPLOADER", "false"
}
nsclient {
dimension "standard"
@ -111,6 +114,20 @@ android {
buildConfigField "boolean", "PUMPDRIVERS", "false"
buildConfigField "boolean", "NSCLIENTOLNY", "true"
buildConfigField "boolean", "CLOSEDLOOP", "false"
buildConfigField "boolean", "G5UPLOADER", "false"
}
g5uploader {
dimension "standard"
resValue "string", "app_name", "NSClient"
versionName version + "-nsclient"
manifestPlaceholders = [
appIcon: "@mipmap/yellowowl"
]
buildConfigField "boolean", "APS", "false"
buildConfigField "boolean", "PUMPDRIVERS", "false"
buildConfigField "boolean", "NSCLIENTOLNY", "false"
buildConfigField "boolean", "CLOSEDLOOP", "false"
buildConfigField "boolean", "G5UPLOADER", "true"
}
}
}
@ -161,7 +178,7 @@ dependencies {
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
compile(name: 'android-edittext-validator-v1.3.4-mod', ext: 'aar')
compile ('com.google.android:flexbox:0.3.0') {
compile('com.google.android:flexbox:0.3.0') {
exclude group: 'com.android.support'
}
compile('io.socket:socket.io-client:0.8.3') {

View file

@ -75,6 +75,8 @@
<action android:name="com.eveningoutpost.dexdrip.NS_EMULATOR" />
<!-- Receiver from glimp -->
<action android:name="it.ct.glicemia.ACTION_GLUCOSE_MEASURED" />
<!-- Receiver from DexcomG5 -->
<action android:name="com.dexcom.cgm.DATA" />
</intent-filter>
</receiver>
<!-- Receiver keepalive, scheduled every 30 min -->

View file

@ -4,22 +4,23 @@ package info.nightscout.androidaps;
* Created by mike on 07.06.2016.
*/
public class Config {
public static int SUPPORTEDNSVERSION = 1000; // 0.10.00
public static int SUPPORTEDNSVERSION = 1002; // 0.10.00
// MAIN FUCTIONALITY
public static final boolean APS = BuildConfig.APS;
// PLUGINS
public static final boolean NSCLIENT = BuildConfig.NSCLIENTOLNY;
public static final boolean G5UPLOADER = BuildConfig.G5UPLOADER;
public static final boolean DANAR = true && BuildConfig.PUMPDRIVERS;
public static final boolean DANAR = BuildConfig.PUMPDRIVERS;
public static final boolean ACTION = !BuildConfig.NSCLIENTOLNY;
public static final boolean VIRTUALPUMP = !BuildConfig.NSCLIENTOLNY;
public static final boolean MDI = !BuildConfig.NSCLIENTOLNY;
public static final boolean OTHERPROFILES = !BuildConfig.NSCLIENTOLNY;
public static final boolean SAFETY = !BuildConfig.NSCLIENTOLNY;
public static final boolean ACTION = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static final boolean VIRTUALPUMP = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static final boolean MDI = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static final boolean OTHERPROFILES = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static final boolean SAFETY = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY;
public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static final boolean detailedLog = true;

View file

@ -61,4 +61,5 @@ public class Constants {
// Pump
public static final int PUMP_MAX_CONNECTION_TIME_IN_SECONDS = 60 - 1;
public static final int MIN_WATCHDOG_INTERVAL_IN_SECONDS = 12 * 60;
}

View file

@ -369,7 +369,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
case R.id.nav_about:
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setTitle(getString(R.string.app_name) + " " + BuildConfig.VERSION);
if (Config.NSCLIENT)
if (Config.NSCLIENT|| Config.G5UPLOADER)
builder.setIcon(R.mipmap.yellowowl);
else
builder.setIcon(R.mipmap.blueowl);

View file

@ -64,6 +64,7 @@ import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
@ -144,13 +145,16 @@ public class MainApp extends Application {
pluginsList.add(TreatmentsPlugin.getPlugin());
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin());
if (!Config.NSCLIENT)
if (!Config.NSCLIENT && !Config.G5UPLOADER)
pluginsList.add(SourceXdripPlugin.getPlugin());
if (!Config.G5UPLOADER)
pluginsList.add(SourceNSClientPlugin.getPlugin());
if (!Config.NSCLIENT)
if (!Config.NSCLIENT && !Config.G5UPLOADER)
pluginsList.add(SourceMM640gPlugin.getPlugin());
if (!Config.NSCLIENT)
if (!Config.NSCLIENT && !Config.G5UPLOADER)
pluginsList.add(SourceGlimpPlugin.getPlugin());
if (!Config.NSCLIENT)
pluginsList.add(SourceDexcomG5Plugin.getPlugin());
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
pluginsList.add(FoodPlugin.getPlugin());

View file

@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
import info.nightscout.utils.LocaleHelper;
@ -126,15 +127,16 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(id);
addPreferencesFromResource(R.xml.pref_advanced);
} else {
if (!Config.NSCLIENT) {
if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResource(R.xml.pref_password);
}
addPreferencesFromResource(R.xml.pref_age);
addPreferencesFromResource(R.xml.pref_language);
if (!Config.NSCLIENT) {
if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResource(R.xml.pref_quickwizard);
}
addPreferencesFromResourceIfEnabled(SourceDexcomG5Plugin.getPlugin(), PluginBase.BGSOURCE);
addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginBase.GENERAL);
addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginBase.CONSTRAINTS);
if (Config.APS) {
@ -147,7 +149,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResourceIfEnabled(SensitivityWeightedAveragePlugin.getPlugin(), PluginBase.SENSITIVITY);
addPreferencesFromResourceIfEnabled(SensitivityOref0Plugin.getPlugin(), PluginBase.SENSITIVITY);
if (!Config.NSCLIENT) {
if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResource(R.xml.pref_profile);
}
@ -165,14 +167,16 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
}
}
if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResourceIfEnabled(VirtualPumpPlugin.getPlugin(), PluginBase.PUMP);
}
addPreferencesFromResourceIfEnabled(InsulinOrefFreePeakPlugin.getPlugin(), PluginBase.INSULIN);
addPreferencesFromResourceIfEnabled(NSClientInternalPlugin.getPlugin(), PluginBase.GENERAL);
addPreferencesFromResourceIfEnabled(SmsCommunicatorPlugin.getPlugin(), PluginBase.GENERAL);
if (!Config.NSCLIENT) {
if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResource(R.xml.pref_others);
}
addPreferencesFromResource(R.xml.pref_advanced);

View file

@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRNSHistorySync;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
import info.nightscout.androidaps.plugins.SourceDexcomG5.SourceDexcomG5Plugin;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
@ -38,6 +39,7 @@ import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
import info.nightscout.androidaps.receivers.DataReceiver;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
import info.nightscout.utils.BundleLogger;
import info.nightscout.utils.NSUpload;
import info.nightscout.utils.SP;
@ -48,6 +50,7 @@ public class DataService extends IntentService {
boolean nsClientEnabled = true;
boolean mm640gEnabled = false;
boolean glimpEnabled = false;
boolean dexcomG5Enabled = false;
public DataService() {
super("DataService");
@ -64,21 +67,31 @@ public class DataService extends IntentService {
nsClientEnabled = false;
mm640gEnabled = false;
glimpEnabled = false;
dexcomG5Enabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceNSClientPlugin.class)) {
xDripEnabled = false;
nsClientEnabled = true;
mm640gEnabled = false;
glimpEnabled = false;
dexcomG5Enabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceMM640gPlugin.class)) {
xDripEnabled = false;
nsClientEnabled = false;
mm640gEnabled = true;
glimpEnabled = false;
dexcomG5Enabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceGlimpPlugin.class)) {
xDripEnabled = false;
nsClientEnabled = false;
mm640gEnabled = false;
glimpEnabled = true;
dexcomG5Enabled = false;
} else if (ConfigBuilderPlugin.getActiveBgSource().getClass().equals(SourceDexcomG5Plugin.class)) {
xDripEnabled = false;
nsClientEnabled = false;
mm640gEnabled = false;
glimpEnabled = false;
dexcomG5Enabled = true;
}
boolean isNSProfile = ConfigBuilderPlugin.getActiveProfileInterface().getClass().equals(NSProfilePlugin.class);
@ -99,6 +112,10 @@ public class DataService extends IntentService {
if (glimpEnabled) {
handleNewDataFromGlimp(intent);
}
} else if (Intents.DEXCOMG5_BG.equals(action)) {
if (dexcomG5Enabled) {
handleNewDataFromDexcomG5(intent);
}
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
// always handle SGV if NS-Client is the source
if (nsClientEnabled) {
@ -187,6 +204,37 @@ public class DataService extends IntentService {
MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP");
}
private void handleNewDataFromDexcomG5(Intent intent) {
// onHandleIntent Bundle{ data => [{"m_time":1511939180,"m_trend":"NotComputable","m_value":335}]; android.support.content.wakelockid => 95; }Bundle
Bundle bundle = intent.getExtras();
if (bundle == null) return;
BgReading bgReading = new BgReading();
String data = bundle.getString("data");
log.debug("Received Dexcom Data", data);
try {
JSONArray jsonArray = new JSONArray(data);
log.debug("Received Dexcom Data size:" + jsonArray.length());
for(int i = 0; i < jsonArray.length(); i++) {
JSONObject json = jsonArray.getJSONObject(i);
bgReading.value = json.getInt("m_value");
bgReading.direction = json.getString("m_trend");
bgReading.date = json.getLong("m_time") * 1000L;
bgReading.raw = 0;
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5");
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
NSUpload.uploadBg(bgReading);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
private void handleNewDataFromMM640g(Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle == null) return;

View file

@ -45,4 +45,6 @@ public interface Intents {
String ACTION_REMOTE_CALIBRATION = "com.eveningoutpost.dexdrip.NewCalibration";
String GLIMP_BG = "it.ct.glicemia.ACTION_GLUCOSE_MEASURED";
String DEXCOMG5_BG = "com.dexcom.cgm.DATA";
}

View file

@ -96,7 +96,9 @@ public class BgReading implements DataPointWithLabelInterface {
direction.compareTo("NOT COMPUTABLE") == 0 ||
direction.compareTo("OUT_OF_RANGE") == 0 ||
direction.compareTo("OUT OF RANGE") == 0 ||
direction.compareTo("NONE") == 0) {
direction.compareTo("NONE") == 0 ||
direction.compareTo("NotComputable") == 0
) {
return true;
} else {
return false;

View file

@ -343,7 +343,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
}
// ------------------- BgReading handling -----------------------
public void createIfNotExists(BgReading bgReading, String from) {
public boolean createIfNotExists(BgReading bgReading, String from) {
try {
bgReading.date = roundDateToSec(bgReading.date);
BgReading old = getDaoBgReadings().queryForId(bgReading.date);
@ -351,18 +351,20 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
getDaoBgReadings().create(bgReading);
log.debug("BG: New record from: " + from + " " + bgReading.toString());
scheduleBgChange();
return;
return true;
}
if (!old.isEqual(bgReading)) {
log.debug("BG: Similiar found: " + old.toString());
old.copyFrom(bgReading);
getDaoBgReadings().update(old);
log.debug("BG: Updating record from: " + from + " " + old.toString());
log.debug("BG: Updating record from: " + from + " New data: " + old.toString());
scheduleBgChange();
return;
return false;
}
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return false;
}
private static void scheduleBgChange() {

View file

@ -93,6 +93,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
ConfigBuilderPlugin.getCommandQueue().extendedBolus(finalInsulin, finalDurationInMinutes, new Callback() {
@Override
public void run() {
if (!result.success) {
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
@ -100,6 +101,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
}
});
Answers.getInstance().logCustom(new CustomEvent("ExtendedBolus"));
}

View file

@ -14,6 +14,7 @@ import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ProfileStore;
@ -104,7 +105,7 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
butonsLayout.setVisibility(View.VISIBLE);
}
if (BuildConfig.NSCLIENTOLNY)
if (Config.NSCLIENT || Config.G5UPLOADER)
statsLayout.setVisibility(View.GONE); // visible on overview
updateGUI();

View file

@ -67,7 +67,7 @@ public class CareportalPlugin implements PluginBase {
@Override
public boolean showInList(int type) {
return !Config.NSCLIENT;
return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override

View file

@ -77,7 +77,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
@Override
public boolean isVisibleInTabs(int type) {
return type == CONSTRAINTS && fragmentVisible && !BuildConfig.NSCLIENTOLNY;
return type == CONSTRAINTS && fragmentVisible && !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override

View file

@ -122,7 +122,7 @@ public class NSClientInternalPlugin implements PluginBase {
@Override
public boolean showInList(int type) {
return !Config.NSCLIENT;
return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override

View file

@ -198,9 +198,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
View view;
if (MainApp.sResources.getBoolean(R.bool.isTablet) && BuildConfig.NSCLIENTOLNY) {
if (MainApp.sResources.getBoolean(R.bool.isTablet) && (Config.NSCLIENT || Config.G5UPLOADER)) {
view = inflater.inflate(R.layout.overview_fragment_nsclient_tablet, container, false);
} else if (BuildConfig.NSCLIENTOLNY) {
} else if (Config.NSCLIENT || Config.G5UPLOADER) {
view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false);
shorttextmode = true;
} else if (smallHeight || landscape) {
@ -975,7 +975,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units, units));
tempTargetView.setVisibility(View.VISIBLE);
}
if (Config.NSCLIENT && tempTarget == null) {
if ((Config.NSCLIENT || Config.G5UPLOADER) && tempTarget == null) {
tempTargetView.setVisibility(View.GONE);
}
@ -1026,7 +1026,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (activeTemp != null) {
basalText = activeTemp.toStringFull() + " ";
}
if (Config.NSCLIENT)
if (Config.NSCLIENT || Config.G5UPLOADER)
basalText += "(" + DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + " U/h)";
else if (pump.getPumpDescription().isTempBasalCapable) {
basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)";

View file

@ -72,12 +72,12 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
@Override
public boolean isEnabled(int type) {
return type == PROFILE && (Config.NSCLIENT || fragmentEnabled);
return type == PROFILE && (Config.NSCLIENT || Config.G5UPLOADER|| fragmentEnabled);
}
@Override
public boolean isVisibleInTabs(int type) {
return type == PROFILE && (Config.NSCLIENT || fragmentVisible);
return type == PROFILE && (Config.NSCLIENT || Config.G5UPLOADER|| fragmentVisible);
}
@Override
@ -92,7 +92,7 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
@Override
public boolean showInList(int type) {
return !Config.NSCLIENT;
return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override

View file

@ -124,8 +124,8 @@ public class DanaRHistoryActivity extends Activity {
statusView.setVisibility(View.GONE);
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP);
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginBase.PUMP);
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP);
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginBase.PUMP);
// Types

View file

@ -674,7 +674,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
return result;
}
boolean connectionOK = danaRSService.extendedBolus(insulin, durationInHalfHours);
if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAbsoluteRate - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = true;
result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);

View file

@ -166,7 +166,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override
public boolean isFakingTempsByExtendedBoluses() {
return Config.NSCLIENT && fromNSAreCommingFakedExtendedBoluses;
return (Config.NSCLIENT || Config.G5UPLOADER) && fromNSAreCommingFakedExtendedBoluses;
}
@Override
@ -196,7 +196,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
@Override
public void connect(String reason) {
if (!BuildConfig.NSCLIENTOLNY)
if (!Config.NSCLIENT && !Config.G5UPLOADER)
NSUpload.uploadDeviceStatus();
lastDataTime = new Date();
}

View file

@ -0,0 +1,84 @@
package info.nightscout.androidaps.plugins.SourceDexcomG5;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.BgSourceInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
/**
* Created by mike on 28.11.2017.
*/
public class SourceDexcomG5Plugin implements PluginBase, BgSourceInterface {
private boolean fragmentEnabled = false;
private static SourceDexcomG5Plugin plugin = null;
public static SourceDexcomG5Plugin getPlugin() {
if (plugin == null)
plugin = new SourceDexcomG5Plugin();
return plugin;
}
@Override
public String getFragmentClass() {
return null;
}
@Override
public int getType() {
return PluginBase.BGSOURCE;
}
@Override
public String getName() {
return MainApp.instance().getString(R.string.DexcomG5);
}
@Override
public String getNameShort() {
// use long name as fallback (no tabs)
return getName();
}
@Override
public boolean isEnabled(int type) {
return Config.G5UPLOADER || type == BGSOURCE && fragmentEnabled;
}
@Override
public boolean isVisibleInTabs(int type) {
return false;
}
@Override
public boolean canBeHidden(int type) {
return true;
}
@Override
public boolean hasFragment() {
return false;
}
@Override
public boolean showInList(int type) {
return !Config.G5UPLOADER;
}
@Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
if (type == BGSOURCE) this.fragmentEnabled = fragmentEnabled;
}
@Override
public void setFragmentVisible(int type, boolean fragmentVisible) {
}
@Override
public int getPreferencesId() {
return R.xml.pref_dexcomg5;
}
}

View file

@ -108,7 +108,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override
public boolean showInList(int type) {
return !Config.NSCLIENT;
return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override

View file

@ -113,7 +113,7 @@ public class StatuslinePlugin implements PluginBase {
@Override
public boolean showInList(int type) {
return !Config.NSCLIENT;
return !Config.NSCLIENT && !Config.G5UPLOADER;
}
@Override

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.queue;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.os.PowerManager;
import android.os.SystemClock;
@ -16,6 +17,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.queue.events.EventQueueChanged;
import info.nightscout.utils.SP;
/**
* Created by mike on 09.11.2017.
@ -61,9 +63,28 @@ public class QueueThread extends Thread {
MainApp.bus().post(new EventDismissBolusprogressIfRunning(new PumpEnactResult()));
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
pump.stopConnecting();
//BLUETOOTH-WATCHDOG
boolean watchdog = SP.getBoolean(R.string.key_btwatchdog, false);
long last_watchdog = SP.getLong(R.string.key_btwatchdog_lastbark, 0l);
watchdog = watchdog && System.currentTimeMillis() - last_watchdog > (Constants.MIN_WATCHDOG_INTERVAL_IN_SECONDS * 1000);
if(watchdog) {
log.debug("BT watchdog - toggeling the phonest bluetooth");
//write time
SP.putLong(R.string.key_btwatchdog_lastbark, System.currentTimeMillis());
//toggle BT
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.disable();
SystemClock.sleep(1000);
mBluetoothAdapter.enable();
SystemClock.sleep(1000);
//start over again once after watchdog barked
connectionStartTime = System.currentTimeMillis();
} else {
queue.clear();
return;
}
}
if (!pump.isConnected()) {
log.debug("State: connect");

View file

@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@ -81,7 +82,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0l) < System.currentTimeMillis();
if (SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), true)
if (Config.APS && SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), true)
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !ConfigBuilderPlugin.getActiveLoop().isDisconnected()) {
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
n.soundId = R.raw.alarm;

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.ProfileSwitch;
@ -383,6 +384,30 @@ public class NSUpload {
DbLogger.dbAdd(intent, data.toString());
}
public static void uploadBg(BgReading reading) {
Context context = MainApp.instance().getApplicationContext();
Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd");
bundle.putString("collection", "entries");
JSONObject data = new JSONObject();
try {
data.put("device", "AndroidAPS-DexcomG5");
data.put("date", reading.date);
data.put("dateString", DateUtil.toISOString(reading.date));
data.put("sgv", reading.value);
data.put("direction", reading.direction);
data.put("type", "sgv");
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
bundle.putString("data", data.toString());
Intent intent = new Intent(Intents.ACTION_DATABASE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
DbLogger.dbAdd(intent, data.toString());
}
public static void uploadAppStart() {
if (SP.getBoolean(R.string.key_ns_logappstartedevent, true)) {
Context context = MainApp.instance().getApplicationContext();

View file

@ -65,8 +65,12 @@ public class SP {
}
static public long getLong(int resourceID, Long defaultValue) {
try {
return sharedPreferences.getLong(MainApp.sResources.getString(resourceID), defaultValue);
} catch (Exception e) {
return SafeParse.stringToLong(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
}
}
static public long getLong(String key, Long defaultValue) {
try {

View file

@ -124,6 +124,16 @@
android:title="@string/do_not_track_profile_switch"
android:summary="@string/do_not_track_profile_switch_summary"/>
</PreferenceCategory>
<PreferenceCategory
android:title="@string/bluetooth">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_btwatchdog"
android:title="@string/btwatchdog_title"
android:summary="@string/btwatchdog_summary"/>
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="danar"
android:title="@string/dexcomg5_upload">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_dexcomg5_nsupload"
android:title="@string/dexcomg5_nsupload_title" />
</PreferenceCategory>
</PreferenceScreen>