Search in sources :

Example 1 with VersionRequestRxMessage

use of com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage in project xDrip by NightscoutFoundation.

the class G5CollectionService method megaStatus.

/* public static void setWatchStatus(DataMap dataMap) {
        lastStateWatch = dataMap.getString("lastState", "");
        static_last_timestamp_watch = dataMap.getLong("timestamp", 0);
    }

    public static DataMap getWatchStatus() {
        DataMap dataMap = new DataMap();
        dataMap.putString("lastState", lastState);
        dataMap.putLong("timestamp", static_last_timestamp);
        return dataMap;
    }*/
// data for MegaStatus
public static List<StatusItem> megaStatus() {
    final List<StatusItem> l = new ArrayList<>();
    l.add(new StatusItem("Phone Service State", lastState));
    if (static_last_timestamp > 0) {
        l.add(new StatusItem("Phone got Glucose", JoH.niceTimeSince(static_last_timestamp) + " ago"));
    }
    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 tx_id = Pref.getStringDefaultBlank("dex_txid");
    l.add(new StatusItem("Transmitter ID", tx_id));
    // get firmware details
    VersionRequestRxMessage vr = getFirmwareDetails(tx_id);
    if ((vr != null) && (vr.firmware_version_string.length() > 0)) {
        l.add(new StatusItem("Firmware Version", vr.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));
        // TODO color code
        if (vr.asic != 61440)
            l.add(new StatusItem("ASIC", vr.asic, StatusItem.Highlight.NOTICE));
    }
    BatteryInfoRxMessage bt = 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", StatusItem.Highlight.NOTICE, "long-press", new Runnable() {

            @Override
            public void run() {
                getBatteryStatusNow = false;
            }
        }));
    }
    if ((bt != null) && (last_battery_query > 0)) {
        l.add(new StatusItem("Battery Last queried", JoH.niceTimeSince(last_battery_query) + " " + "ago", StatusItem.Highlight.NORMAL, "long-press", new Runnable() {

            @Override
            public void run() {
                getBatteryStatusNow = true;
            }
        }));
        l.add(new StatusItem("Transmitter Status", TransmitterStatus.getBatteryLevel(vr.status).toString()));
        l.add(new StatusItem("Transmitter Days", bt.runtime + ((last_transmitter_timestamp > 0) ? " / " + JoH.qs((double) last_transmitter_timestamp / 86400, 1) : "")));
        l.add(new StatusItem("Voltage A", bt.voltagea, bt.voltagea < 300 ? StatusItem.Highlight.BAD : StatusItem.Highlight.NORMAL));
        l.add(new StatusItem("Voltage B", bt.voltageb, bt.voltageb < 290 ? StatusItem.Highlight.BAD : StatusItem.Highlight.NORMAL));
        l.add(new StatusItem("Resistance", bt.resist, bt.resist > 1400 ? StatusItem.Highlight.BAD : (bt.resist > 1000 ? StatusItem.Highlight.NOTICE : (bt.resist > 750 ? StatusItem.Highlight.NORMAL : StatusItem.Highlight.GOOD))));
        l.add(new StatusItem("Temperature", bt.temperature + " \u2103"));
    }
    return l;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) BatteryInfoRxMessage(com.eveningoutpost.dexdrip.G5Model.BatteryInfoRxMessage) ArrayList(java.util.ArrayList) VersionRequestRxMessage(com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage)

Example 2 with VersionRequestRxMessage

use of com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage 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;
}
Also used : VersionRequest1RxMessage(com.eveningoutpost.dexdrip.G5Model.VersionRequest1RxMessage) ArrayList(java.util.ArrayList) VersionRequest2RxMessage(com.eveningoutpost.dexdrip.G5Model.VersionRequest2RxMessage) SpannableString(android.text.SpannableString) BleGattCallbackTimeoutException(com.polidea.rxandroidble2.exceptions.BleGattCallbackTimeoutException) BleScanException(com.polidea.rxandroidble2.exceptions.BleScanException) VersionRequestRxMessage(com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage) StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) BatteryInfoRxMessage(com.eveningoutpost.dexdrip.G5Model.BatteryInfoRxMessage)

Example 3 with VersionRequestRxMessage

use of com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage 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;
}
Also used : VersionRequest1RxMessage(com.eveningoutpost.dexdrip.G5Model.VersionRequest1RxMessage) ArrayList(java.util.ArrayList) VersionRequest2RxMessage(com.eveningoutpost.dexdrip.G5Model.VersionRequest2RxMessage) SpannableString(android.text.SpannableString) BleGattCallbackTimeoutException(com.polidea.rxandroidble2.exceptions.BleGattCallbackTimeoutException) BleScanException(com.polidea.rxandroidble2.exceptions.BleScanException) VersionRequestRxMessage(com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage) StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) BatteryInfoRxMessage(com.eveningoutpost.dexdrip.G5Model.BatteryInfoRxMessage)

Example 4 with VersionRequestRxMessage

use of com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage in project xDrip-plus by jamorham.

the class G5CollectionService method megaStatus.

/* public static void setWatchStatus(DataMap dataMap) {
        lastStateWatch = dataMap.getString("lastState", "");
        static_last_timestamp_watch = dataMap.getLong("timestamp", 0);
    }

    public static DataMap getWatchStatus() {
        DataMap dataMap = new DataMap();
        dataMap.putString("lastState", lastState);
        dataMap.putLong("timestamp", static_last_timestamp);
        return dataMap;
    }*/
// data for MegaStatus
public static List<StatusItem> megaStatus() {
    final List<StatusItem> l = new ArrayList<>();
    l.add(new StatusItem("Phone Service State", lastState));
    if (static_last_timestamp > 0) {
        l.add(new StatusItem("Phone got Glucose", JoH.niceTimeSince(static_last_timestamp) + " ago"));
    }
    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 tx_id = Pref.getStringDefaultBlank("dex_txid");
    l.add(new StatusItem("Transmitter ID", tx_id));
    // get firmware details
    VersionRequestRxMessage vr = getFirmwareDetails(tx_id);
    if ((vr != null) && (vr.firmware_version_string.length() > 0)) {
        l.add(new StatusItem("Firmware Version", vr.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));
        // TODO color code
        if (vr.asic != 61440)
            l.add(new StatusItem("ASIC", vr.asic, StatusItem.Highlight.NOTICE));
    }
    BatteryInfoRxMessage bt = 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", StatusItem.Highlight.NOTICE, "long-press", new Runnable() {

            @Override
            public void run() {
                getBatteryStatusNow = false;
            }
        }));
    }
    if ((bt != null) && (last_battery_query > 0)) {
        l.add(new StatusItem("Battery Last queried", JoH.niceTimeSince(last_battery_query) + " " + "ago", StatusItem.Highlight.NORMAL, "long-press", new Runnable() {

            @Override
            public void run() {
                getBatteryStatusNow = true;
            }
        }));
        l.add(new StatusItem("Transmitter Status", TransmitterStatus.getBatteryLevel(vr.status).toString()));
        l.add(new StatusItem("Transmitter Days", bt.runtime + ((last_transmitter_timestamp > 0) ? " / " + JoH.qs((double) last_transmitter_timestamp / 86400, 1) : "")));
        l.add(new StatusItem("Voltage A", bt.voltagea, bt.voltagea < 300 ? StatusItem.Highlight.BAD : StatusItem.Highlight.NORMAL));
        l.add(new StatusItem("Voltage B", bt.voltageb, bt.voltageb < 290 ? StatusItem.Highlight.BAD : StatusItem.Highlight.NORMAL));
        l.add(new StatusItem("Resistance", bt.resist, bt.resist > 1400 ? StatusItem.Highlight.BAD : (bt.resist > 1000 ? StatusItem.Highlight.NOTICE : (bt.resist > 750 ? StatusItem.Highlight.NORMAL : StatusItem.Highlight.GOOD))));
        l.add(new StatusItem("Temperature", bt.temperature + " \u2103"));
    }
    return l;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) BatteryInfoRxMessage(com.eveningoutpost.dexdrip.G5Model.BatteryInfoRxMessage) ArrayList(java.util.ArrayList) VersionRequestRxMessage(com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage)

Aggregations

BatteryInfoRxMessage (com.eveningoutpost.dexdrip.G5Model.BatteryInfoRxMessage)4 VersionRequestRxMessage (com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage)4 StatusItem (com.eveningoutpost.dexdrip.UtilityModels.StatusItem)4 ArrayList (java.util.ArrayList)4 SpannableString (android.text.SpannableString)2 VersionRequest1RxMessage (com.eveningoutpost.dexdrip.G5Model.VersionRequest1RxMessage)2 VersionRequest2RxMessage (com.eveningoutpost.dexdrip.G5Model.VersionRequest2RxMessage)2 BleGattCallbackTimeoutException (com.polidea.rxandroidble2.exceptions.BleGattCallbackTimeoutException)2 BleScanException (com.polidea.rxandroidble2.exceptions.BleScanException)2