Search in sources :

Example 16 with StatusItem

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

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 17 with StatusItem

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

the class LibreReceiver method megaStatus.

public static List<StatusItem> megaStatus() {
    final List<StatusItem> l = new ArrayList<>();
    final Sensor sensor = Sensor.currentSensor();
    if (sensor != null) {
        l.add(new StatusItem("Libre2 Sensor", sensor.uuid + "\nStart: " + DateFormat.format("dd.MM.yyyy kk:mm", sensor.started_at)));
    }
    String lastReading = "";
    try {
        lastReading = DateFormat.format("dd.MM.yyyy kk:mm:ss", last_reading).toString();
        l.add(new StatusItem("Last Reading", lastReading));
    } catch (Exception e) {
        Log.e(TAG, "Error readlast: " + e);
    }
    if (get_engineering_mode()) {
        l.add(new StatusItem("Last Calc.", libre_calc_doku));
    }
    if (Pref.getBooleanDefaultFalse("Libre2_showSensors")) {
        l.add(new StatusItem("Sensors", Libre2Sensors()));
    }
    return l;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) ArrayList(java.util.ArrayList) Sensor(com.eveningoutpost.dexdrip.Models.Sensor)

Example 18 with StatusItem

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

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

Example 19 with StatusItem

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

the class RollCall method megaStatus.

// data for MegaStatus
public static List<StatusItem> megaStatus() {
    if (indexed == null)
        loadIndex();
    GcmActivity.requestRollCall();
    // TODO sort data
    final boolean engineering = Home.get_engineering_mode();
    final boolean desert_sync = DesertSync.isEnabled();
    final String our_wifi_ssid = desert_sync ? wifiString() : "";
    final List<StatusItem> lf = new ArrayList<>();
    for (Map.Entry entry : indexed.entrySet()) {
        final RollCall rc = (RollCall) entry.getValue();
        // TODO refactor with stringbuilder
        lf.add(new StatusItem(rc.role + (desert_sync ? rc.getRemoteWifiIndicate(our_wifi_ssid) : "") + (engineering ? ("\n" + JoH.niceTimeSince(rc.last_seen) + " ago") : ""), rc.bestName() + (desert_sync ? rc.getRemoteIpStatus() : "") + (engineering && rc.batteryValid() ? ("\n" + rc.battery + "%") : "") + (engineering && rc.bridgeBatteryValid() ? (" " + rc.bridge_battery + "%") : "")));
    }
    Collections.sort(lf, new Comparator<StatusItem>() {

        public int compare(StatusItem left, StatusItem right) {
            // descending sort ignore second line
            int val = right.name.replaceFirst("\n.*$", "").compareTo(left.name.replaceFirst("\n.*$", ""));
            // ascending sort
            if (val == 0)
                val = left.value.compareTo(right.value);
            return val;
        }
    });
    return new ArrayList<>(lf);
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) ArrayList(java.util.ArrayList) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with StatusItem

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

the class TidepoolStatus method megaStatus.

// data for MegaStatus
public static List<StatusItem> megaStatus() {
    final KeyStore keyStore = FastStore.getInstance();
    final List<StatusItem> l = new ArrayList<>();
    // TODO needs generic message format string
    l.add(new StatusItem("Tidepool Synced to", niceTimeScalar(msSince(UploadChunk.getLastEnd())) + " ago"));
    final String status = keyStore.getS(TidepoolUploader.STATUS_KEY);
    if (!JoH.emptyString(status)) {
        l.add(new StatusItem("Tidepool Status", status));
    }
    return l;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) ArrayList(java.util.ArrayList) KeyStore(com.eveningoutpost.dexdrip.store.KeyStore)

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