Search in sources :

Example 26 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip by NightscoutFoundation.

the class DexCollectionService method megaStatus.

// data for MegaStatus
public static List<StatusItem> megaStatus() {
    final List<StatusItem> l = new ArrayList<>();
    final boolean forced_wear = Home.get_forced_wear();
    l.add(new StatusItem("Phone Service State", lastState + (forced_wear ? " (Watch Forced)" : "")));
    if (lastError != null) {
        l.add(new StatusItem("Last Error", lastError, StatusItem.Highlight.NOTICE, "long-press", () -> lastError = null));
    }
    l.add(new StatusItem("Bluetooth Device", JoH.ucFirst(getStateStr(mStaticState))));
    if (device != null) {
        l.add(new StatusItem("Device Mac Address", device.getAddress()));
    }
    if (Home.get_engineering_mode()) {
        l.add(new StatusItem("Active device connected", String.valueOf(ActiveBluetoothDevice.is_connected())));
        l.add(new StatusItem("Bluetooth GATT", String.valueOf(mBluetoothGatt)));
        String hint = "";
        if (mStatus == 133) {
            hint = " (restart device?)";
        }
        l.add(new StatusItem("Last status", String.valueOf(mStatus) + hint));
        BluetoothManager myBluetoothManager = (BluetoothManager) xdrip.getAppContext().getSystemService(Context.BLUETOOTH_SERVICE);
        if (myBluetoothManager != null) {
            for (BluetoothDevice bluetoothDevice : myBluetoothManager.getConnectedDevices(BluetoothProfile.GATT)) {
                l.add(new StatusItem("GATT device connected", bluetoothDevice.getAddress()));
            }
        }
    }
    if (mStaticState == STATE_CONNECTING) {
        final long connecting_ms = JoH.msSince(last_connect_request);
        l.add(new StatusItem("Connecting for", JoH.niceTimeScalar(connecting_ms)));
    }
    if (static_use_polling) {
        l.add(new StatusItem("Polling mode", ((last_poll_sent > 0) ? "Last poll: " + JoH.niceTimeSince(last_poll_sent) + " ago" : "Enabled")));
    }
    if (static_use_transmiter_pl_bluetooth) {
        l.add(new StatusItem("Hardware", "Transmiter PL"));
    }
    if (static_use_rfduino_bluetooth) {
        l.add(new StatusItem("Hardware", "Rfduino"));
    }
    if (static_use_blukon) {
        l.add(new StatusItem("Hardware", xdrip.getAppContext().getString(R.string.blukon)));
    }
    if (static_use_nrf && blueReader.isblueReader()) {
        l.add(new StatusItem("Hardware", "BlueReader"));
    }
    if (static_use_nrf && Tomato.isTomato()) {
        l.add(new StatusItem("Hardware", xdrip.getAppContext().getString(R.string.tomato)));
    }
    if (last_transmitter_Data != null) {
        l.add(new StatusItem("Glucose data from", JoH.niceTimeSince(last_transmitter_Data.timestamp) + " ago"));
    }
    if (last_battery_level > -1) {
        l.add(new StatusItem("Battery level", last_battery_level));
    }
    if (Pref.getBooleanDefaultFalse(PREF_DEX_COLLECTION_BONDING)) {
        if (bondedState != null) {
            l.add(new StatusItem("Bluetooth Pairing", (bondedState.length() > 0) ? "Bonded" : "Not bonded" + (bondingTries > 1 ? " (" + bondingTries + ")" : ""), (bondedState.length() > 0) ? StatusItem.Highlight.GOOD : StatusItem.Highlight.NOTICE, "long-press", new Runnable() {

                @Override
                public void run() {
                    Pref.setBoolean(PREF_DEX_COLLECTION_BONDING, false);
                    if (bondedState.length() > 0) {
                        JoH.static_toast_long("If you want to unbond use Android bluetooth system settings to Forget device");
                        bondedState = null;
                    }
                    new Thread(new Runnable() {

                        @Override
                        public void run() {
                            CollectionServiceStarter.restartCollectionService(xdrip.getAppContext());
                        }
                    }).start();
                }
            }));
        }
    } else {
        l.add(new StatusItem("Bluetooth Pairing", "Disabled, tap to enable", StatusItem.Highlight.NORMAL, "long-press", new Runnable() {

            @Override
            public void run() {
                Pref.setBoolean(PREF_DEX_COLLECTION_BONDING, true);
                JoH.static_toast_long("This probably only works on HM10/HM11 and blucon devices at the moment and takes a minute");
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        CollectionServiceStarter.restartCollectionService(xdrip.getAppContext());
                    }
                }).start();
            }
        }));
    }
    if (max_wakeup_jitter > 2000) {
        l.add(new StatusItem("Slowest wake up", JoH.niceTimeScalar(max_wakeup_jitter) + " late", max_wakeup_jitter > 61000 ? StatusItem.Highlight.CRITICAL : 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 (retry_time > 0)
        l.add(new StatusItem("Next Retry", JoH.niceTimeTill(retry_time), JoH.msTill(retry_time) < -2 ? StatusItem.Highlight.CRITICAL : StatusItem.Highlight.NORMAL));
    if (failover_time > 0)
        l.add(new StatusItem("Next Wake up", JoH.niceTimeTill(failover_time), JoH.msTill(failover_time) < -2 ? StatusItem.Highlight.CRITICAL : StatusItem.Highlight.NORMAL));
    if (Home.get_engineering_mode() && DexCollectionType.hasLibre()) {
        l.add(new StatusItem("Request Data", "Test for xBridgePlus protocol", immediateSend == null ? StatusItem.Highlight.NORMAL : StatusItem.Highlight.NOTICE, "long-press", new Runnable() {

            @Override
            public void run() {
                immediateSend = XbridgePlus.sendDataRequestPacket();
                // TODO quicker/cleaner restart
                CollectionServiceStarter.restartCollectionService(xdrip.getAppContext());
            }
        }));
    }
    if (Home.get_engineering_mode() && (static_last_hexdump != null)) {
        l.add(new StatusItem("Received Data", filterHexdump(static_last_hexdump)));
    }
    if (Home.get_engineering_mode() && (static_last_sent_hexdump != null)) {
        l.add(new StatusItem("Sent Data", filterHexdump(static_last_sent_hexdump)));
    }
    // WATCH
    if (forced_wear) {
        l.add(new StatusItem());
        l.add(new StatusItem("Watch Service State", lastStateWatch));
        l.add(new StatusItem("Bridge Device", JoH.ucFirst(getStateStr(mStaticStateWatch))));
        if ((last_transmitter_DataWatch != null) && (last_transmitter_DataWatch.timestamp > 0)) {
            l.add(new StatusItem("Watch Glucose data", JoH.niceTimeSince(last_transmitter_DataWatch.timestamp) + " ago"));
        }
        if (last_battery_level_watch > -1) {
            l.add(new StatusItem("Bridge Battery level", last_battery_level_watch));
        }
        if (retry_time_watch > 0)
            l.add(new StatusItem("Watch Next Retry", JoH.niceTimeTill(retry_time_watch)));
        if (failover_time_watch > 0)
            l.add(new StatusItem("Watch Wake up", JoH.niceTimeTill(failover_time_watch)));
        if (Home.get_engineering_mode() && (static_last_hexdump_watch != null) && (static_last_hexdump_watch.length() > 0)) {
            l.add(new StatusItem("Watch Received Data", filterHexdump(static_last_hexdump_watch)));
        }
        if (Home.get_engineering_mode() && (static_last_sent_hexdump_watch != null) && (static_last_sent_hexdump_watch.length() > 0)) {
            l.add(new StatusItem("Watch Sent Data", filterHexdump(static_last_sent_hexdump_watch)));
        }
    }
    // blueReader
    if (blueReader.isblueReader()) {
        l.add(new StatusItem("blueReader Battery", Pref.getInt("bridge_battery", 0) + "%"));
        l.add(new StatusItem("blueReader rest days", PersistentStore.getString("bridge_battery_days")));
        l.add(new StatusItem("blueReader Firmware", PersistentStore.getString("blueReaderFirmware")));
    }
    if (Tomato.isTomato()) {
        l.add(new StatusItem("Tomato Battery", PersistentStore.getString("Tomatobattery")));
        l.add(new StatusItem("Tomato Hardware", PersistentStore.getString("TomatoHArdware")));
        l.add(new StatusItem("Tomato Firmware", PersistentStore.getString("TomatoFirmware")));
        l.add(new StatusItem("Libre SN", PersistentStore.getString("LibreSN")));
    }
    if (Bubble.isBubble()) {
        l.add(new StatusItem("Bubble Battery", PersistentStore.getString("Bubblebattery")));
        l.add(new StatusItem("Bubble Hardware", PersistentStore.getString("BubbleHArdware")));
        l.add(new StatusItem("Bubble Firmware", PersistentStore.getString("BubbleFirmware")));
        l.add(new StatusItem("Libre SN", PersistentStore.getString("LibreSN")));
    }
    if (Atom.isAtom()) {
        l.add(new StatusItem("Atom Battery", PersistentStore.getString("Atombattery")));
        l.add(new StatusItem("Atom Hardware", PersistentStore.getString("AtomHArdware")));
        l.add(new StatusItem("Atom Firmware", PersistentStore.getString("AtomFirmware")));
        l.add(new StatusItem("Libre SN", PersistentStore.getString("LibreSN")));
    }
    if (static_use_blukon) {
        l.add(new StatusItem("Battery", Pref.getInt("bridge_battery", 0) + "%"));
        l.add(new StatusItem("Sensor age", JoH.qs(((double) Pref.getInt("nfc_sensor_age", 0)) / 1440, 1) + "d"));
        l.add(new StatusItem("Libre SN", PersistentStore.getString("LibreSN")));
    }
    return l;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) BluetoothDevice(android.bluetooth.BluetoothDevice) ActiveBluetoothDevice(com.eveningoutpost.dexdrip.Models.ActiveBluetoothDevice) BluetoothManager(android.bluetooth.BluetoothManager) ArrayList(java.util.ArrayList)

Example 27 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.

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;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) ArrayList(java.util.ArrayList)

Example 28 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.

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<>();
    }
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) HashMap(java.util.HashMap) Map(java.util.Map)

Example 29 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.

the class MiBandService method megaStatus.

// Mega Status
public static List<StatusItem> megaStatus() {
    final List<StatusItem> l = new ArrayList<>();
    final Inst II = Inst.get(MiBandService.class.getSimpleName());
    l.add(new StatusItem("Model", MiBand.getModel()));
    l.add(new StatusItem("Software version", MiBand.getVersion()));
    l.add(new StatusItem("Mac address", MiBand.getMac()));
    l.add(new StatusItem("Connected", II.isConnected ? gs(R.string.yes) : gs(R.string.no)));
    l.add(new StatusItem("Is authenticated", MiBand.isAuthenticated() ? gs(R.string.yes) : gs(R.string.no)));
    if (II.isConnected) {
        int levelInPercent = batteryInfo.getLevelInPercent();
        String levelInPercentText;
        if (levelInPercent == 1000)
            levelInPercentText = "Unknown";
        else
            levelInPercentText = levelInPercent + "%";
        l.add(new StatusItem("Battery", levelInPercentText));
    }
    if (II.wakeup_time != 0) {
        final long till = msTill(II.wakeup_time);
        if (till > 0)
            l.add(new StatusItem("Wake Up", niceTimeScalar(till)));
    }
    if (bgWakeupTime != 0) {
        final long till = msTill(bgWakeupTime);
        if (till > 0)
            l.add(new StatusItem("Next time update", niceTimeScalar(till)));
    }
    l.add(new StatusItem("State", II.state));
    final int qsize = II.getQueueSize();
    if (qsize > 0) {
        l.add(new StatusItem("Queue", qsize + " items"));
    }
    return l;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) ArrayList(java.util.ArrayList) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) SuppressLint(android.annotation.SuppressLint)

Example 30 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem 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)

Aggregations

StatusItem (com.eveningoutpost.dexdrip.UtilityModels.StatusItem)34 ArrayList (java.util.ArrayList)34 SpannableString (android.text.SpannableString)8 SuppressLint (android.annotation.SuppressLint)6 JoH.emptyString (com.eveningoutpost.dexdrip.Models.JoH.emptyString)6 BatteryInfoRxMessage (com.eveningoutpost.dexdrip.G5Model.BatteryInfoRxMessage)4 VersionRequestRxMessage (com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage)4 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 AlertDialog (android.app.AlertDialog)2 BluetoothDevice (android.bluetooth.BluetoothDevice)2 BluetoothManager (android.bluetooth.BluetoothManager)2 DialogInterface (android.content.DialogInterface)2 VersionRequest1RxMessage (com.eveningoutpost.dexdrip.G5Model.VersionRequest1RxMessage)2 VersionRequest2RxMessage (com.eveningoutpost.dexdrip.G5Model.VersionRequest2RxMessage)2 ActiveBluetoothDevice (com.eveningoutpost.dexdrip.Models.ActiveBluetoothDevice)2 Sensor (com.eveningoutpost.dexdrip.Models.Sensor)2 Highlight (com.eveningoutpost.dexdrip.UtilityModels.StatusItem.Highlight)2 KeyStore (com.eveningoutpost.dexdrip.store.KeyStore)2