use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip by NightscoutFoundation.
the class Mdns method megaStatus.
// data for MegaStatus
public static List<StatusItem> megaStatus(final Context context) {
Mdns.superFastResolve("dummyentry1234");
final List<StatusItem> l = new ArrayList<>();
// l.add(new StatusItem());
l.add(new StatusItem("Local Network", StatusItem.Highlight.NORMAL));
for (final Map.Entry<String, LookUpInfo> entry : iplookup.entrySet()) {
final long status_time = entry.getValue().received;
if (JoH.msSince(status_time) < Constants.HOUR_IN_MS) {
l.add(new StatusItem(entry.getValue().prettyName().replaceFirst(" ", "\n"), entry.getValue().address + ((status_time != 0) ? ("\n" + JoH.niceTimeSince(status_time) + " " + "ago").replaceFirst("[0-9]+ second", "second") : ""), StatusItem.Highlight.NORMAL, "long-press", new Runnable() {
@Override
public void run() {
// TODO: probe port 50005?
final String receiver_list = Pref.getStringDefaultBlank("wifi_recievers_addresses").trim().toLowerCase();
final String new_receiver = entry.getKey().toLowerCase() + ".local" + ":50005";
if (!receiver_list.contains(entry.getKey().toLowerCase() + ".local")) {
// add item
final DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case DialogInterface.BUTTON_POSITIVE:
String new_receiver_list = (receiver_list.length() > 0) ? receiver_list + "," + new_receiver : new_receiver;
UserError.Log.d(TAG, "Updating receiver list to: " + new_receiver_list);
Pref.setString("wifi_recievers_addresses", new_receiver_list);
JoH.static_toast_long("Added receiver: " + JoH.ucFirst(entry.getKey()));
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Add " + JoH.ucFirst(entry.getKey()) + " to list of receivers?");
builder.setMessage("Is this device running a collector?\n\n" + entry.getKey() + ".local can be automatically added to list of receivers").setPositiveButton("Add", dialogClickListener).setNegativeButton(gs(R.string.no), dialogClickListener).show();
} else {
// remove item
final DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case DialogInterface.BUTTON_POSITIVE:
String new_receiver_list = receiver_list.replace(new_receiver, "").replace(",,", ",").replaceFirst(",$", "").replaceFirst("^,", "");
UserError.Log.d(TAG, "Updating receiver list to: " + new_receiver_list);
Pref.setString("wifi_recievers_addresses", new_receiver_list);
JoH.static_toast_long("Removed receiver: " + JoH.ucFirst(entry.getKey()));
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Remove " + JoH.ucFirst(entry.getKey()) + " from list of receivers?");
builder.setPositiveButton("Remove", dialogClickListener).setNegativeButton(gs(R.string.no), dialogClickListener).show();
}
}
}));
}
}
if (l.size() > 1) {
if (JoH.quietratelimit("mdns-check-showcase", 5)) {
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
startupInfo(context);
}
}, 1500);
}
return l;
} else {
return new ArrayList<>();
}
}
use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.
the class DoNothingService method megaStatus.
public static List<StatusItem> megaStatus() {
final List<StatusItem> l = new ArrayList<>();
if (GcmActivity.cease_all_activity) {
l.add(new StatusItem("SYNC DISABLED", Pref.getBooleanDefaultFalse("disable_all_sync") ? "By preference option" : (InstalledApps.isGooglePlayInstalled(xdrip.getAppContext()) ? "Not by preference option" : "By missing Google Play services"), StatusItem.Highlight.CRITICAL));
}
if (Home.get_master()) {
l.add(new StatusItem("Service State", "We are the Master"));
} else {
l.add(new StatusItem("Service State", lastState));
updateLastBg();
if (last_bg != null) {
l.add(new StatusItem("Glucose Data", JoH.niceTimeSince(last_bg.timestamp) + " ago"));
}
if (wakeUpErrors > 0) {
l.add(new StatusItem("Slow Wake up", JoH.niceTimeScalar(wake_time_difference)));
l.add(new StatusItem("Wake Up Errors", wakeUpErrors));
}
if (max_wake_time_difference > 0) {
l.add(new StatusItem("Slowest Wake up", JoH.niceTimeScalar(max_wake_time_difference)));
}
if (JoH.buggy_samsung) {
l.add(new StatusItem("Buggy Samsung", "Using workaround", max_wake_time_difference < TOLERABLE_JITTER ? StatusItem.Highlight.GOOD : BAD));
}
if (nextWakeUpTime != -1) {
l.add(new StatusItem("Next Wake up: ", JoH.niceTimeTill(nextWakeUpTime)));
}
}
return l;
}
use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip by NightscoutFoundation.
the class WifiCollectionService method megaStatus.
// data for MegaStatus
public static List<StatusItem> megaStatus(Context context) {
final List<StatusItem> l = new ArrayList<>();
l.add(new StatusItem("IP Collector Service", lastState));
l.add(new StatusItem("Next poll", JoH.niceTimeTill(PersistentStore.getLong(WIFI_COLLECTION_WAKEUP))));
if (max_wakeup_jitter > 2000) {
l.add(new StatusItem("Wakeup jitter", JoH.niceTimeScalar(max_wakeup_jitter), max_wakeup_jitter > TOLERABLE_JITTER ? StatusItem.Highlight.BAD : StatusItem.Highlight.NORMAL));
}
if (JoH.buggy_samsung) {
l.add(new StatusItem("Buggy Samsung", "Using workaround", max_wakeup_jitter < TOLERABLE_JITTER ? StatusItem.Highlight.GOOD : StatusItem.Highlight.BAD));
}
if (DexCollectionType.hasLibre()) {
l.addAll(LibreWifiReader.megaStatus());
} else {
l.addAll(WixelReader.megaStatus());
}
final int bridgeBattery = Pref.getInt("parakeet_battery", 0);
if (bridgeBattery > 0) {
l.add(new StatusItem("Parakeet Battery", bridgeBattery + "%", bridgeBattery < 50 ? bridgeBattery < 40 ? StatusItem.Highlight.BAD : StatusItem.Highlight.NOTICE : StatusItem.Highlight.GOOD));
}
l.addAll(Mdns.megaStatus(context));
return l;
}
use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip by NightscoutFoundation.
the class MedtrumCollectionService method megaStatus.
// Mega Status
public static List<StatusItem> megaStatus() {
if (lastAnnex == null) {
lastAnnex = com.eveningoutpost.dexdrip.cgm.medtrum.Medtrum.getLastAdvertAnnex();
// add some advert only marker
}
final List<StatusItem> l = new ArrayList<>();
l.add(new StatusItem("Phone Service State", lastState));
if (!JoH.emptyString(lastErrorState)) {
l.add(new StatusItem("Error", lastErrorState, BAD));
}
if (lastAnnex != null) {
l.add(new StatusItem("Battery", lastAnnex.getBatteryPercent() + "%"));
if (lastAnnex.charging) {
l.add(new StatusItem("Charging", lastAnnex.charged ? "Charged" : "On charge"));
}
l.add(new StatusItem("Sensor State", lastAnnex.getState().getDescription(), lastAnnex.getState() == Ok ? GOOD : NORMAL));
if (lastAnnex.getState() == SensorState.WarmingUp1) {
l.add(new StatusItem("Warm up", "Initial warm up", StatusItem.Highlight.NOTICE));
} else if (lastAnnex.getState() == SensorState.WarmingUp2) {
final long warmupMinsLeft = ((2 * HOUR_IN_MS) - lastAnnex.getSensorAgeInMs()) / Constants.MINUTE_IN_MS;
if (warmupMinsLeft > -1 && warmupMinsLeft < 121) {
l.add(new StatusItem("Warmup left", warmupMinsLeft + " mins", StatusItem.Highlight.NOTICE));
}
}
if (lastAnnex.getSensorAgeInMs() > 0) {
l.add(new StatusItem("Sensor Age", lastAnnex.getNiceSensorAge()));
}
if (lastAnnex.sensorGood) {
l.add(new StatusItem("Sensor", "Good", GOOD));
// } else {
// if (lastAnnex.getState() == Ok) {
// l.add(new StatusItem("Sensor", "Ok", StatusItem.Highlight.NORMAL));
// }
}
if (lastAnnex.sensorError) {
l.add(new StatusItem("Sensor Error", "Error", BAD));
}
if (lastAnnex.sensorFail) {
l.add(new StatusItem("Sensor Fail", "FAILED", CRITICAL));
}
if (lastAnnex.calibrationErrorA) {
l.add(new StatusItem("Calibration Error", "Error A", BAD));
}
if (lastAnnex.calibrationErrorB) {
l.add(new StatusItem("Calibration Error", "Error B", BAD));
}
final Pair<Long, Integer> calibration = Medtrum.getCalibration();
if (calibration != null) {
l.add(new StatusItem("Blood test", BgGraphBuilder.unitized_string_with_units_static(calibration.second) + " @ " + JoH.hourMinuteString(calibration.first), StatusItem.Highlight.NOTICE));
}
if (serial != 0) {
final int version = Medtrum.getVersion(serial);
l.add(new StatusItem("Serial", "" + serial));
if (version > 0) {
final String versionString = "v" + (JoH.qs(version / 100d, 2));
l.add(new StatusItem("Firmware", versionString));
}
}
if (lastAnnex.getState() == Ok || lastAnnex.getState() == SensorState.NotCalibrated) {
l.add(new StatusItem("Slope", JoH.qs(lastAnnex.calibrationSlope / 1000d, 3) + " (" + JoH.qs(1d / (lastAnnex.calibrationSlope / 1000d), 2) + ")"));
l.add(new StatusItem("Intercept", lastAnnex.calibrationIntercept));
l.add(new StatusItem("Raw Data", lastAnnex.sensorRaw));
}
if (lastAnnex.getState() == Ok) {
l.add(new StatusItem("Last Glucose", BgGraphBuilder.unitized_string_with_units_static(lastAnnex.calculatedGlucose()) + (lastAnnex.recent() ? "" : " @ " + JoH.niceTimeScalarShort(JoH.msSince(lastAnnex.created))), lastAnnex.recent() ? NORMAL : StatusItem.Highlight.NOTICE));
}
if (retry_time != 0) {
l.add(new StatusItem("Wake up in", JoH.niceTimeScalar(msTill(retry_time))));
}
if (failover_time != 0) {
l.add(new StatusItem("System check in", JoH.niceTimeScalar(msTill(failover_time))));
}
if (Home.get_engineering_mode()) {
l.add(new StatusItem("Brain State", state.getString()));
l.add(new StatusItem("Last Interaction", JoH.niceTimeScalar(msSince(lastInteractionTime))));
l.add(new StatusItem("Last Wake Up", JoH.niceTimeScalar(msSince(last_wake_up_time))));
}
} else {
l.add(new StatusItem("Status Information", "Nothing Yet", StatusItem.Highlight.NOTICE));
}
return l;
}
use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip by NightscoutFoundation.
the class DesertComms method megaStatus.
// megastatus
// data for MegaStatus
public static List<StatusItem> megaStatus() {
final List<StatusItem> l = new ArrayList<>();
if (Home.get_follower()) {
if (emptyString(getOasisIP())) {
l.add(new StatusItem("Desert Master", "Not known yet - needs QR code scan?"));
} else {
l.add(new StatusItem("Desert Master", getOasisIP(), RouteTools.reachable(getOasisIP()) ? StatusItem.Highlight.NORMAL : StatusItem.Highlight.BAD));
}
if (Home.get_engineering_mode()) {
l.add(new StatusItem("Desert Backup", getOasisBackupIP()));
l.add(new StatusItem("Our IP", RouteTools.getBestInterfaceAddress()));
}
}
return l;
}
Aggregations