use of com.eveningoutpost.dexdrip.G5Model.VersionRequest1RxMessage in project xDrip by NightscoutFoundation.
the class Ob1G5CollectionService method megaStatus.
// data for MegaStatus
public static List<StatusItem> megaStatus() {
// needed if we have not passed through local INIT state
init_tx_id();
final List<StatusItem> l = new ArrayList<>();
l.add(new StatusItem("Phone Service State", lastState, JoH.msSince(lastStateUpdated) < 300000 ? (lastState.startsWith("Got data") ? Highlight.GOOD : NORMAL) : (isWatchRunning() ? Highlight.GOOD : CRITICAL)));
if (last_scan_started > 0) {
final long scanning_time = JoH.msSince(last_scan_started);
l.add(new StatusItem("Time scanning", JoH.niceTimeScalar(scanning_time), scanning_time > Constants.MINUTE_IN_MS * 5 ? (scanning_time > Constants.MINUTE_IN_MS * 10 ? BAD : NOTICE) : NORMAL));
}
if (lastScanError != null) {
l.add(new StatusItem("Scan Error", lastScanError, BAD));
}
if ((lastSensorStatus != null)) {
l.add(new StatusItem("Sensor Status", lastSensorStatus, lastSensorState != Ok ? NOTICE : NORMAL));
}
if (hardResetTransmitterNow) {
l.add(new StatusItem("Hard Reset", "Attempting - please wait", Highlight.CRITICAL));
}
if (transmitterID != null) {
l.add(new StatusItem("Sensor Device", transmitterID + ((transmitterMAC != null && Home.get_engineering_mode()) ? "\n" + transmitterMAC : "")));
}
if (static_connection_state != null) {
l.add(new StatusItem("Bluetooth Link", static_connection_state));
}
if (static_last_connected > 0) {
l.add(new StatusItem("Last Connected", JoH.niceTimeScalar(JoH.msSince(static_last_connected)) + " ago"));
}
if ((!lastState.startsWith("Service Stopped")) && (!lastState.startsWith("Not running")))
l.add(new StatusItem("Brain State", state.getString() + (error_count > 1 ? " Errors: " + error_count : ""), error_count > 1 ? NOTICE : error_count > 4 ? BAD : NORMAL));
if (lastUsableGlucosePacketTime != 0) {
if (JoH.msSince(lastUsableGlucosePacketTime) < Constants.MINUTE_IN_MS * 15) {
l.add(new StatusItem("G5 Algorithm", "Data Received " + JoH.hourMinuteString(lastUsableGlucosePacketTime), Highlight.GOOD));
}
}
final int queueSize = Ob1G5StateMachine.queueSize();
if (queueSize > 0) {
l.add(new StatusItem("Queue Items", "(" + queueSize + ") " + Ob1G5StateMachine.getFirstQueueItemName()));
}
if (max_wakeup_jitter > 5000) {
l.add(new StatusItem("Slowest Wakeup ", JoH.niceTimeScalar(max_wakeup_jitter), max_wakeup_jitter > Constants.SECOND_IN_MS * 10 ? CRITICAL : NOTICE));
}
if (JoH.buggy_samsung) {
l.add(new StatusItem("Buggy Samsung", "Using workaround", max_wakeup_jitter < TOLERABLE_JITTER ? Highlight.GOOD : BAD));
}
final String tx_id = getTransmitterID();
if (Pref.getBooleanDefaultFalse("wear_sync") && Pref.getBooleanDefaultFalse("enable_wearG5")) {
l.add(new StatusItem("Watch Service State", lastStateWatch));
if (static_last_timestamp_watch > 0) {
l.add(new StatusItem("Watch got Glucose", JoH.niceTimeSince(static_last_timestamp_watch) + " ago"));
}
}
final String sensorCode = getCurrentSensorCode();
if (sensorCode != null) {
if (usingG6()) {
l.add(new StatusItem("Calibration Code", sensorCode));
}
}
l.add(new StatusItem("Preemptive restarts", (Pref.getBooleanDefaultFalse("ob1_g5_preemptive_restart") ? "Enabled" : "Disabled") + (Ob1G5StateMachine.useExtendedTimeTravel() ? " (extended)" : "")));
final VersionRequest1RxMessage vr1 = (VersionRequest1RxMessage) Ob1G5StateMachine.getFirmwareXDetails(tx_id, 1);
final VersionRequest2RxMessage vr2 = (VersionRequest2RxMessage) Ob1G5StateMachine.getFirmwareXDetails(tx_id, 2);
try {
if (vr1 != null) {
l.add(new StatusItem("Firmware Version", vr1.firmware_version_string, FirmwareCapability.isG6Rev2(vr1.firmware_version_string) ? NOTICE : NORMAL));
// l.add(new StatusItem("Build Version", "" + vr1.build_version));
if (vr1.version_code != 3) {
l.add(new StatusItem("Compat Version", "" + vr1.version_code, Highlight.BAD));
}
if (vr1.max_runtime_days != 110 && vr1.max_runtime_days != 112) {
l.add(new StatusItem("Transmitter Life", "" + vr1.max_runtime_days + " " + gs(R.string.days)));
}
}
} catch (Exception e) {
// TODO add message?
}
try {
if (vr2 != null) {
if (vr2.typicalSensorDays != 10 && vr2.typicalSensorDays != 7) {
l.add(new StatusItem("Sensor Period", vr2.typicalSensorDays, Highlight.NOTICE));
}
// l.add(new StatusItem("Feature mask", vr2.featureBits));
}
} catch (Exception e) {
//
}
// firmware hardware details
final VersionRequestRxMessage vr = (VersionRequestRxMessage) Ob1G5StateMachine.getFirmwareXDetails(tx_id, 0);
try {
if ((vr != null) && (vr.firmware_version_string.length() > 0)) {
if (Home.get_engineering_mode()) {
if (vr1 != null && !vr.firmware_version_string.equals(vr1.firmware_version_string)) {
l.add(new StatusItem("2nd Firmware Version", vr.firmware_version_string, FirmwareCapability.isG6Rev2(vr.firmware_version_string) ? NOTICE : NORMAL));
}
if (vr1 != null && !vr.bluetooth_firmware_version_string.equals(vr1.firmware_version_string)) {
l.add(new StatusItem("Bluetooth Version", vr.bluetooth_firmware_version_string));
}
l.add(new StatusItem("Other Version", vr.other_firmware_version));
// l.add(new StatusItem("Hardware Version", vr.hardwarev));
if (vr.asic != 61440 && vr.asic != 16705 && vr.asic != 243 && vr.asic != 74)
l.add(new StatusItem("ASIC", vr.asic, NOTICE));
}
}
} catch (NullPointerException e) {
l.add(new StatusItem("Version", "Information corrupted", BAD));
}
// battery details
final BatteryInfoRxMessage bt = Ob1G5StateMachine.getBatteryDetails(tx_id);
long last_battery_query = PersistentStore.getLong(G5_BATTERY_FROM_MARKER + tx_id);
if (getBatteryStatusNow) {
l.add(new StatusItem("Battery Status Request Queued", "Will attempt to read battery status on next sensor reading", NOTICE, "long-press", new Runnable() {
@Override
public void run() {
getBatteryStatusNow = false;
}
}));
}
if (JoH.quietratelimit("update-g5-battery-warning", 10)) {
updateBatteryWarningLevel();
}
if (vr1 != null && Home.get_engineering_mode()) {
l.add(new StatusItem("Shelf Life", "" + vr1.inactive_days + " / " + vr1.max_inactive_days));
}
final int timekeeperDays = DexTimeKeeper.getTransmitterAgeInDays(tx_id);
if ((bt != null) && (last_battery_query > 0)) {
l.add(new StatusItem("Battery Last queried", JoH.niceTimeSince(last_battery_query) + " " + "ago", NORMAL, "long-press", new Runnable() {
@Override
public void run() {
getBatteryStatusNow = true;
}
}));
if (vr != null) {
final String battery_status = TransmitterStatus.getBatteryLevel(vr.status).toString();
if (!battery_status.equals("OK"))
l.add(new StatusItem("Transmitter Status", battery_status, BAD));
}
// TODO use string builder instead of ternary for days
l.add(new StatusItem("Transmitter Days", ((bt.runtime > -1) ? bt.runtime : "") + ((timekeeperDays > -1) ? ((FirmwareCapability.isTransmitterG6Rev2(tx_id) ? " " : " / ") + timekeeperDays) : "") + ((last_transmitter_timestamp > 0) ? " / " + JoH.qs((double) last_transmitter_timestamp / 86400, 1) : "")));
l.add(new StatusItem("Voltage A", bt.voltagea, bt.voltagea < LOW_BATTERY_WARNING_LEVEL ? BAD : NORMAL));
l.add(new StatusItem("Voltage B", bt.voltageb, bt.voltageb < (LOW_BATTERY_WARNING_LEVEL - 10) ? BAD : NORMAL));
l.add(new StatusItem("Resistance", bt.resist, bt.resist > 1400 ? BAD : (bt.resist > 1000 ? NOTICE : (bt.resist > 750 ? NORMAL : Highlight.GOOD))));
if (vr != null && !FirmwareCapability.isG6Rev2(vr.firmware_version_string)) {
l.add(new StatusItem("Temperature", bt.temperature + " \u2103"));
}
}
return l;
}
use of com.eveningoutpost.dexdrip.G5Model.VersionRequest1RxMessage in project xDrip by NightscoutFoundation.
the class Ob1G5CollectionService method handleUnknownFirmwareClick.
private static void handleUnknownFirmwareClick() {
UserError.Log.d(TAG, "handleUnknownFirmwareClick()");
if (UpdateActivity.testAndSetNightly(true)) {
val vr1 = (VersionRequest1RxMessage) Ob1G5StateMachine.getFirmwareXDetails(getTransmitterID(), 1);
UserError.Log.d(TAG, "Starting feedback activity");
xdrip.getAppContext().startActivity(new Intent(xdrip.getAppContext(), SendFeedBack.class).putExtra("generic_text", "Automated Report of unknown firmware version\n" + vr1.toString()).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
}
use of com.eveningoutpost.dexdrip.G5Model.VersionRequest1RxMessage in project xDrip-plus by jamorham.
the class Ob1G5CollectionService method handleUnknownFirmwareClick.
private static void handleUnknownFirmwareClick() {
UserError.Log.d(TAG, "handleUnknownFirmwareClick()");
if (UpdateActivity.testAndSetNightly(true)) {
val vr1 = (VersionRequest1RxMessage) Ob1G5StateMachine.getFirmwareXDetails(getTransmitterID(), 1);
UserError.Log.d(TAG, "Starting feedback activity");
xdrip.getAppContext().startActivity(new Intent(xdrip.getAppContext(), SendFeedBack.class).putExtra("generic_text", "Automated Report of unknown firmware version\n" + vr1.toString()).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
}
use of com.eveningoutpost.dexdrip.G5Model.VersionRequest1RxMessage in project xDrip-plus by jamorham.
the class Ob1G5CollectionService method megaStatus.
// data for MegaStatus
public static List<StatusItem> megaStatus() {
// needed if we have not passed through local INIT state
init_tx_id();
final List<StatusItem> l = new ArrayList<>();
l.add(new StatusItem("Phone Service State", lastState, JoH.msSince(lastStateUpdated) < 300000 ? (lastState.startsWith("Got data") ? Highlight.GOOD : NORMAL) : (isWatchRunning() ? Highlight.GOOD : CRITICAL)));
if (last_scan_started > 0) {
final long scanning_time = JoH.msSince(last_scan_started);
l.add(new StatusItem("Time scanning", JoH.niceTimeScalar(scanning_time), scanning_time > Constants.MINUTE_IN_MS * 5 ? (scanning_time > Constants.MINUTE_IN_MS * 10 ? BAD : NOTICE) : NORMAL));
}
if (lastScanError != null) {
l.add(new StatusItem("Scan Error", lastScanError, BAD));
}
if ((lastSensorStatus != null)) {
l.add(new StatusItem("Sensor Status", lastSensorStatus, lastSensorState != Ok ? NOTICE : NORMAL));
}
if (hardResetTransmitterNow) {
l.add(new StatusItem("Hard Reset", "Attempting - please wait", Highlight.CRITICAL));
}
if (transmitterID != null) {
l.add(new StatusItem("Sensor Device", transmitterID + ((transmitterMAC != null && Home.get_engineering_mode()) ? "\n" + transmitterMAC : "")));
}
if (static_connection_state != null) {
l.add(new StatusItem("Bluetooth Link", static_connection_state));
}
if (static_last_connected > 0) {
l.add(new StatusItem("Last Connected", JoH.niceTimeScalar(JoH.msSince(static_last_connected)) + " ago"));
}
if ((!lastState.startsWith("Service Stopped")) && (!lastState.startsWith("Not running")))
l.add(new StatusItem("Brain State", state.getString() + (error_count > 1 ? " Errors: " + error_count : ""), error_count > 1 ? NOTICE : error_count > 4 ? BAD : NORMAL));
if (lastUsableGlucosePacketTime != 0) {
if (JoH.msSince(lastUsableGlucosePacketTime) < Constants.MINUTE_IN_MS * 15) {
l.add(new StatusItem("G5 Algorithm", "Data Received " + JoH.hourMinuteString(lastUsableGlucosePacketTime), Highlight.GOOD));
}
}
final int queueSize = Ob1G5StateMachine.queueSize();
if (queueSize > 0) {
l.add(new StatusItem("Queue Items", "(" + queueSize + ") " + Ob1G5StateMachine.getFirstQueueItemName()));
}
if (max_wakeup_jitter > 5000) {
l.add(new StatusItem("Slowest Wakeup ", JoH.niceTimeScalar(max_wakeup_jitter), max_wakeup_jitter > Constants.SECOND_IN_MS * 10 ? CRITICAL : NOTICE));
}
if (JoH.buggy_samsung) {
l.add(new StatusItem("Buggy Samsung", "Using workaround", max_wakeup_jitter < TOLERABLE_JITTER ? Highlight.GOOD : BAD));
}
final String tx_id = getTransmitterID();
if (Pref.getBooleanDefaultFalse("wear_sync") && Pref.getBooleanDefaultFalse("enable_wearG5")) {
l.add(new StatusItem("Watch Service State", lastStateWatch));
if (static_last_timestamp_watch > 0) {
l.add(new StatusItem("Watch got Glucose", JoH.niceTimeSince(static_last_timestamp_watch) + " ago"));
}
}
final String sensorCode = getCurrentSensorCode();
if (sensorCode != null) {
if (usingG6()) {
l.add(new StatusItem("Calibration Code", sensorCode));
}
}
l.add(new StatusItem("Preemptive restarts", (Pref.getBooleanDefaultFalse("ob1_g5_preemptive_restart") ? "Enabled" : "Disabled") + (Ob1G5StateMachine.useExtendedTimeTravel() ? " (extended)" : "")));
final VersionRequest1RxMessage vr1 = (VersionRequest1RxMessage) Ob1G5StateMachine.getFirmwareXDetails(tx_id, 1);
final VersionRequest2RxMessage vr2 = (VersionRequest2RxMessage) Ob1G5StateMachine.getFirmwareXDetails(tx_id, 2);
try {
if (vr1 != null) {
l.add(new StatusItem("Firmware Version", vr1.firmware_version_string, FirmwareCapability.isG6Rev2(vr1.firmware_version_string) ? NOTICE : NORMAL));
// l.add(new StatusItem("Build Version", "" + vr1.build_version));
if (vr1.version_code != 3) {
l.add(new StatusItem("Compat Version", "" + vr1.version_code, Highlight.BAD));
}
if (vr1.max_runtime_days != 110 && vr1.max_runtime_days != 112) {
l.add(new StatusItem("Transmitter Life", "" + vr1.max_runtime_days + " " + gs(R.string.days)));
}
}
} catch (Exception e) {
// TODO add message?
}
try {
if (vr2 != null) {
if (vr2.typicalSensorDays != 10 && vr2.typicalSensorDays != 7) {
l.add(new StatusItem("Sensor Period", vr2.typicalSensorDays, Highlight.NOTICE));
}
// l.add(new StatusItem("Feature mask", vr2.featureBits));
}
} catch (Exception e) {
//
}
// firmware hardware details
final VersionRequestRxMessage vr = (VersionRequestRxMessage) Ob1G5StateMachine.getFirmwareXDetails(tx_id, 0);
try {
if ((vr != null) && (vr.firmware_version_string.length() > 0)) {
if (Home.get_engineering_mode()) {
if (vr1 != null && !vr.firmware_version_string.equals(vr1.firmware_version_string)) {
l.add(new StatusItem("2nd Firmware Version", vr.firmware_version_string, FirmwareCapability.isG6Rev2(vr.firmware_version_string) ? NOTICE : NORMAL));
}
if (vr1 != null && !vr.bluetooth_firmware_version_string.equals(vr1.firmware_version_string)) {
l.add(new StatusItem("Bluetooth Version", vr.bluetooth_firmware_version_string));
}
l.add(new StatusItem("Other Version", vr.other_firmware_version));
// l.add(new StatusItem("Hardware Version", vr.hardwarev));
if (vr.asic != 61440 && vr.asic != 16705 && vr.asic != 243 && vr.asic != 74)
l.add(new StatusItem("ASIC", vr.asic, NOTICE));
}
}
} catch (NullPointerException e) {
l.add(new StatusItem("Version", "Information corrupted", BAD));
}
// battery details
final BatteryInfoRxMessage bt = Ob1G5StateMachine.getBatteryDetails(tx_id);
long last_battery_query = PersistentStore.getLong(G5_BATTERY_FROM_MARKER + tx_id);
if (getBatteryStatusNow) {
l.add(new StatusItem("Battery Status Request Queued", "Will attempt to read battery status on next sensor reading", NOTICE, "long-press", new Runnable() {
@Override
public void run() {
getBatteryStatusNow = false;
}
}));
}
if (JoH.quietratelimit("update-g5-battery-warning", 10)) {
updateBatteryWarningLevel();
}
if (vr1 != null && Home.get_engineering_mode()) {
l.add(new StatusItem("Shelf Life", "" + vr1.inactive_days + " / " + vr1.max_inactive_days));
}
final int timekeeperDays = DexTimeKeeper.getTransmitterAgeInDays(tx_id);
if ((bt != null) && (last_battery_query > 0)) {
l.add(new StatusItem("Battery Last queried", JoH.niceTimeSince(last_battery_query) + " " + "ago", NORMAL, "long-press", new Runnable() {
@Override
public void run() {
getBatteryStatusNow = true;
}
}));
if (vr != null) {
final String battery_status = TransmitterStatus.getBatteryLevel(vr.status).toString();
if (!battery_status.equals("OK"))
l.add(new StatusItem("Transmitter Status", battery_status, BAD));
}
// TODO use string builder instead of ternary for days
l.add(new StatusItem("Transmitter Days", ((bt.runtime > -1) ? bt.runtime : "") + ((timekeeperDays > -1) ? ((FirmwareCapability.isTransmitterG6Rev2(tx_id) ? " " : " / ") + timekeeperDays) : "") + ((last_transmitter_timestamp > 0) ? " / " + JoH.qs((double) last_transmitter_timestamp / 86400, 1) : "")));
l.add(new StatusItem("Voltage A", bt.voltagea, bt.voltagea < LOW_BATTERY_WARNING_LEVEL ? BAD : NORMAL));
l.add(new StatusItem("Voltage B", bt.voltageb, bt.voltageb < (LOW_BATTERY_WARNING_LEVEL - 10) ? BAD : NORMAL));
l.add(new StatusItem("Resistance", bt.resist, bt.resist > 1400 ? BAD : (bt.resist > 1000 ? NOTICE : (bt.resist > 750 ? NORMAL : Highlight.GOOD))));
if (vr != null && !FirmwareCapability.isG6Rev2(vr.firmware_version_string)) {
l.add(new StatusItem("Temperature", bt.temperature + " \u2103"));
}
}
return l;
}
Aggregations