Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into dev
This commit is contained in:
commit
f25334273a
6 changed files with 48 additions and 5 deletions
|
@ -61,4 +61,5 @@ public class Constants {
|
||||||
|
|
||||||
// Pump
|
// Pump
|
||||||
public static final int PUMP_MAX_CONNECTION_TIME_IN_SECONDS = 60 - 1;
|
public static final int PUMP_MAX_CONNECTION_TIME_IN_SECONDS = 60 - 1;
|
||||||
|
public static final int MIN_WATCHDOG_INTERVAL_IN_SECONDS = 12 * 60;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.queue;
|
package info.nightscout.androidaps.queue;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.SystemClock;
|
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.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.11.2017.
|
* Created by mike on 09.11.2017.
|
||||||
|
@ -61,8 +63,27 @@ public class QueueThread extends Thread {
|
||||||
MainApp.bus().post(new EventDismissBolusprogressIfRunning(new PumpEnactResult()));
|
MainApp.bus().post(new EventDismissBolusprogressIfRunning(new PumpEnactResult()));
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.connectiontimedout)));
|
||||||
pump.stopConnecting();
|
pump.stopConnecting();
|
||||||
queue.clear();
|
|
||||||
return;
|
//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()) {
|
if (!pump.isConnected()) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
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;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
@ -81,7 +82,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
|
boolean alarmTimeoutExpired = lastConnection.getTime() + pumpUnreachableThreshold() < System.currentTimeMillis();
|
||||||
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0l) < 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()) {
|
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !ConfigBuilderPlugin.getActiveLoop().isDisconnected()) {
|
||||||
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
||||||
n.soundId = R.raw.alarm;
|
n.soundId = R.raw.alarm;
|
||||||
|
|
|
@ -65,7 +65,11 @@ public class SP {
|
||||||
}
|
}
|
||||||
|
|
||||||
static public long getLong(int resourceID, Long defaultValue) {
|
static public long getLong(int resourceID, Long defaultValue) {
|
||||||
return SafeParse.stringToLong(sharedPreferences.getString(MainApp.sResources.getString(resourceID), defaultValue.toString()));
|
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) {
|
static public long getLong(String key, Long defaultValue) {
|
||||||
|
|
|
@ -772,10 +772,16 @@
|
||||||
<string name="key_missed_bg_readings_threshold" translatable="false">missed_bg_readings_threshold</string>
|
<string name="key_missed_bg_readings_threshold" translatable="false">missed_bg_readings_threshold</string>
|
||||||
<string name="urgent_alarm">Urgent Alarm</string>
|
<string name="urgent_alarm">Urgent Alarm</string>
|
||||||
<string name="info">INFO</string>
|
<string name="info">INFO</string>
|
||||||
|
<string name="key_btwatchdog" translatable="false">bt_watchdog</string>
|
||||||
|
<string name="key_btwatchdog_lastbark" translatable="false">bt_watchdog_last</string>
|
||||||
|
<string name="bluetooth">Bluetooth</string>
|
||||||
|
<string name="btwatchdog_title">BT Watchdog</string>
|
||||||
|
<string name="btwatchdog_summary">Switches off the phone\'s bluetooth for one second if no connection to the pump is possible. This may help on some phones where the bluetooth stack freezes.</string>
|
||||||
<string name="DexcomG5">DexcomG5 App (patched)</string>
|
<string name="DexcomG5">DexcomG5 App (patched)</string>
|
||||||
<string name="dexcomg5_nsupload_title">Upload BG data to NS</string>
|
<string name="dexcomg5_nsupload_title">Upload BG data to NS</string>
|
||||||
<string name="key_dexcomg5_nsupload">dexcomg5_nsupload</string>
|
<string name="key_dexcomg5_nsupload">dexcomg5_nsupload</string>
|
||||||
<string name="dexcomg5_upload">G5 upload settings</string>
|
<string name="dexcomg5_upload">G5 upload settings</string>
|
||||||
<string name="customapp">Customized APK for download</string>
|
<string name="customapp">Customized APK for download</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,16 @@
|
||||||
android:title="@string/do_not_track_profile_switch"
|
android:title="@string/do_not_track_profile_switch"
|
||||||
android:summary="@string/do_not_track_profile_switch_summary"/>
|
android:summary="@string/do_not_track_profile_switch_summary"/>
|
||||||
</PreferenceCategory>
|
</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>
|
</PreferenceScreen>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Reference in a new issue