Java Code Examples for com.eveningoutpost.dexdrip.Home#toaststatic()

The following examples show how to use com.eveningoutpost.dexdrip.Home#toaststatic() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Treatments.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static Treatments fromJSON(String json) {
    try {
        return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(json, Treatments.class);
    } catch (Exception e) {
        Log.d(TAG, "Got exception parsing treatment json: " + e.toString());
        Home.toaststatic("Error on treatment, probably decryption key mismatch");
        return null;
    }
}
 
Example 2
Source File: Treatments.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static Treatments fromJSON(String json) {
    try {
        return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(json, Treatments.class);
    } catch (Exception e) {
        Log.d(TAG, "Got exception parsing treatment json: " + e.toString());
        Home.toaststatic("Error on treatment, probably decryption key mismatch");
        return null;
    }
}
 
Example 3
Source File: Treatments.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static Treatments fromJSON(String json) {
    try {
        return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(json, Treatments.class);
    } catch (Exception e) {
        Log.d(TAG, "Got exception parsing treatment json: " + e.toString());
        Home.toaststatic("Error on treatment, probably decryption key mismatch");
        return null;
    }
}
 
Example 4
Source File: Treatments.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static Treatments fromJSON(String json) {
    try {
        return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(json, Treatments.class);
    } catch (Exception e) {
        Log.d(TAG, "Got exception parsing treatment json: " + e.toString());
        Home.toaststatic("Error on treatment, probably decryption key mismatch");
        return null;
    }
}
 
Example 5
Source File: blueReader.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static byte[] decodeblueReaderPacket(byte[] buffer, int len) {
    int cmdFound = 0;
    long timestamp = new Date().getTime();
    String bufferstring;
    //Log.w(TAG, "Packet: " + bufferstring);
    if (buffer == null) {
        Log.e(TAG, "null buffer passed to decodeblueReaderPacket");
        return null;
    } else {
        bufferstring=new String(buffer);
    }
    if (bufferstring.startsWith("not ready for") ) { //delete the trans_failed, because its normal only if the bluereader could not read the sensor.
        counterHibernated++;
        Log.e(TAG, "Found blueReader in a ugly State (" + counterHibernated + "/3), send hibernate to reset! If this does not help in the next 5 Minutes, then turn the bluereader manually off and on!");
        if (counterHibernated > 2) {
            Log.wtf(TAG, "Ugly state not resolveable. Bluereader will be shut down! Please restart it!");
            Home.toaststatic("BlueReader ugly state not resolveable, bluereader will be shut down. Please restart it!");
            if (!Pref.getBooleanDefaultFalse("blueReader_suppressuglystatemsg")) {
                Notifications.RiseDropAlert(xdrip.getAppContext(),true,"BlueReader Alarm", xdrip.getAppContext().getString(R.string.bluereaderuglystate),1);
            }
            return shutdown;
        } else {
            Home.toaststatic("Found blueReader in a ugly State, send hibernate to reset!");
            return goHybernate; //send hard hibernate, because blueReader is in a ugly state
        }
    } else if (bufferstring.startsWith("IDR")){
        Log.i(TAG, bufferstring);
        PersistentStore.setString("blueReaderFirmware", bufferstring );
        tempVers=Pattern.compile(".*\\|blue(.*)-.*").matcher(bufferstring);
        tempVers.find();
        PersistentStore.setDouble("blueReaderFirmwareValue",Double.parseDouble(tempVers.group(1)));
        Log.i(TAG, "bluereader-Firmware-Version: " + tempVers);
        if (BgReading.last() == null || BgReading.last().timestamp + (4 * 60 * 1000) < System.currentTimeMillis()) {
            return requestValue;
        } else {
            return null;
        }
    } else if (bufferstring.startsWith("WAKE")) {
        Log.d (TAG, "blueReader was set to wakeup-mode manually...");
        return null;
    } else if (bufferstring.startsWith("ECHO")) {
        Log.d (TAG, "blueReader was set to Echo-Mode manually...");
        return null;
    } else if (bufferstring.startsWith("NFC READY")) {
        Log.d (TAG, "blueReader notice that NFC is active...");
        return null;
    } else if (bufferstring.startsWith("NFC_DISABLED")) {
        Log.d (TAG, "blueReader notice that NFC is now hibernated...");
        return null;
    } else if (bufferstring.startsWith("HYBERNATE SUCCESS")) {
        Log.i (TAG, "blueReader notice that NFC is now really hibernated...");
        if (counterHibernated > 0) {
            Log.w (TAG,"Found hibernation after wrong read. Resend read-command...");
            return requestValue;
        } else {
            return null;
        }
    } else if (bufferstring.startsWith("-r 0:")) {
        Log.d (TAG, "blueReader sends an unknown reaction: '" + bufferstring + "'");
        return null;
    } else if (bufferstring.startsWith("TRANS_FAILED")) {
        Log.w (TAG, "Attention: check position of blueReader on the sensor, as it was not able to read!");
        Home.toaststatic(xdrip.getAppContext().getString(R.string.bluereader_position));
        return null;
    } else if (bufferstring.startsWith("battery: ")) {
        if (BgReading.last() == null || BgReading.last().timestamp + (4 * 60 * 1000) < System.currentTimeMillis()) {
            return requestValue;
        }
    } else {
        counterHibernated = 0;
        processNewTransmitterData(TransmitterData.create(buffer, len, timestamp), timestamp);
        // check for shutdown blueReader if Battery is too low
        if (Pref.getBooleanDefaultFalse("blueReader_turn_off")) {
            if (Pref.getInt("blueReader_turn_off_value",5) > Pref.getInt("bridge_battery",100)) {
                Log.w (TAG, "blueReader will be turn off, as the battery is lower then " + Pref.getInt("blueReader_turn_off_value",5) +"%");
                Home.toaststatic(xdrip.getAppContext().getString(R.string.bluereaderoff) + Pref.getInt("blueReader_turn_off_value",5) +"%");
                return shutdown;
            }
        }
    }

    return null;
}
 
Example 6
Source File: blueReader.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public static byte[] decodeblueReaderPacket(byte[] buffer, int len) {
    int cmdFound = 0;
    long timestamp = new Date().getTime();
    String bufferstring;
    //Log.w(TAG, "Packet: " + bufferstring);
    if (buffer == null) {
        Log.e(TAG, "null buffer passed to decodeblueReaderPacket");
        return null;
    } else {
        bufferstring=new String(buffer);
    }
    if (bufferstring.startsWith("not ready for") ) { //delete the trans_failed, because its normal only if the bluereader could not read the sensor.
        counterHibernated++;
        Log.e(TAG, "Found blueReader in a ugly State (" + counterHibernated + "/3), send hibernate to reset! If this does not help in the next 5 Minutes, then turn the bluereader manually off and on!");
        if (counterHibernated > 2) {
            Log.wtf(TAG, "Ugly state not resolveable. Bluereader will be shut down! Please restart it!");
            Home.toaststatic("BlueReader ugly state not resolveable, bluereader will be shut down. Please restart it!");
            if (!Pref.getBooleanDefaultFalse("blueReader_suppressuglystatemsg")) {
                Notifications.RiseDropAlert(xdrip.getAppContext(),true,"BlueReader Alarm", xdrip.getAppContext().getString(R.string.bluereaderuglystate),1);
            }
            return shutdown;
        } else {
            Home.toaststatic("Found blueReader in a ugly State, send hibernate to reset!");
            return goHybernate; //send hard hibernate, because blueReader is in a ugly state
        }
    } else if (bufferstring.startsWith("IDR")){
        Log.i(TAG, bufferstring);
        PersistentStore.setString("blueReaderFirmware", bufferstring );
        tempVers=Pattern.compile(".*\\|blue(.*)-.*").matcher(bufferstring);
        tempVers.find();
        PersistentStore.setDouble("blueReaderFirmwareValue",Double.parseDouble(tempVers.group(1)));
        Log.i(TAG, "bluereader-Firmware-Version: " + tempVers);
        if (BgReading.last() == null || BgReading.last().timestamp + (4 * 60 * 1000) < System.currentTimeMillis()) {
            return requestValue;
        } else {
            return null;
        }
    } else if (bufferstring.startsWith("WAKE")) {
        Log.d (TAG, "blueReader was set to wakeup-mode manually...");
        return null;
    } else if (bufferstring.startsWith("ECHO")) {
        Log.d (TAG, "blueReader was set to Echo-Mode manually...");
        return null;
    } else if (bufferstring.startsWith("NFC READY")) {
        Log.d (TAG, "blueReader notice that NFC is active...");
        return null;
    } else if (bufferstring.startsWith("NFC_DISABLED")) {
        Log.d (TAG, "blueReader notice that NFC is now hibernated...");
        return null;
    } else if (bufferstring.startsWith("HYBERNATE SUCCESS")) {
        Log.i (TAG, "blueReader notice that NFC is now really hibernated...");
        if (counterHibernated > 0) {
            Log.w (TAG,"Found hibernation after wrong read. Resend read-command...");
            return requestValue;
        } else {
            return null;
        }
    } else if (bufferstring.startsWith("-r 0:")) {
        Log.d (TAG, "blueReader sends an unknown reaction: '" + bufferstring + "'");
        return null;
    } else if (bufferstring.startsWith("TRANS_FAILED")) {
        Log.w (TAG, "Attention: check position of blueReader on the sensor, as it was not able to read!");
        Home.toaststatic(xdrip.getAppContext().getString(R.string.bluereader_position));
        return null;
    } else if (bufferstring.startsWith("battery: ")) {
        if (BgReading.last() == null || BgReading.last().timestamp + (4 * 60 * 1000) < System.currentTimeMillis()) {
            return requestValue;
        }
    } else {
        counterHibernated = 0;
        processNewTransmitterData(TransmitterData.create(buffer, len, timestamp), timestamp);
        // check for shutdown blueReader if Battery is too low
        if (Pref.getBooleanDefaultFalse("blueReader_turn_off")) {
            if (Pref.getInt("blueReader_turn_off_value",5) > Pref.getInt("bridge_battery",100)) {
                Log.w (TAG, "blueReader will be turn off, as the battery is lower then " + Pref.getInt("blueReader_turn_off_value",5) +"%");
                Home.toaststatic(xdrip.getAppContext().getString(R.string.bluereaderoff) + Pref.getInt("blueReader_turn_off_value",5) +"%");
                return shutdown;
            }
        }
    }

    return null;
}
 
Example 7
Source File: blueReader.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static byte[] decodeblueReaderPacket(byte[] buffer, int len) {
    int cmdFound = 0;
    long timestamp = new Date().getTime();
    String bufferstring;
    //Log.w(TAG, "Packet: " + bufferstring);
    if (buffer == null) {
        Log.e(TAG, "null buffer passed to decodeblueReaderPacket");
        return null;
    } else {
        bufferstring=new String(buffer);
    }
    if (bufferstring.startsWith("not ready for") ) { //delete the trans_failed, because its normal only if the bluereader could not read the sensor.
        counterHibernated++;
        Log.e(TAG, "Found blueReader in a ugly State (" + counterHibernated + "/3), send hibernate to reset! If this does not help in the next 5 Minutes, then turn the bluereader manually off and on!");
        if (counterHibernated > 2) {
            Log.wtf(TAG, "Ugly state not resolveable. Bluereader will be shut down! Please restart it!");
            Home.toaststatic("BlueReader ugly state not resolveable, bluereader will be shut down. Please restart it!");
            if (!Pref.getBooleanDefaultFalse("blueReader_suppressuglystatemsg")) {
                Notifications.RiseDropAlert(xdrip.getAppContext(),true,"BlueReader Alarm", xdrip.getAppContext().getString(R.string.bluereaderuglystate),1);
            }
            return shutdown;
        } else {
            Home.toaststatic("Found blueReader in a ugly State, send hibernate to reset!");
            return goHybernate; //send hard hibernate, because blueReader is in a ugly state
        }
    } else if (bufferstring.startsWith("IDR")){
        Log.i(TAG, bufferstring);
        PersistentStore.setString("blueReaderFirmware", bufferstring );
        tempVers=Pattern.compile(".*\\|blue(.*)-.*").matcher(bufferstring);
        tempVers.find();
        PersistentStore.setDouble("blueReaderFirmwareValue",Double.parseDouble(tempVers.group(1)));
        Log.i(TAG, "bluereader-Firmware-Version: " + tempVers);
        if (BgReading.last() == null || BgReading.last().timestamp + (4 * 60 * 1000) < System.currentTimeMillis()) {
            return requestValue;
        } else {
            return null;
        }
    } else if (bufferstring.startsWith("WAKE")) {
        Log.d (TAG, "blueReader was set to wakeup-mode manually...");
        return null;
    } else if (bufferstring.startsWith("ECHO")) {
        Log.d (TAG, "blueReader was set to Echo-Mode manually...");
        return null;
    } else if (bufferstring.startsWith("NFC READY")) {
        Log.d (TAG, "blueReader notice that NFC is active...");
        return null;
    } else if (bufferstring.startsWith("NFC_DISABLED")) {
        Log.d (TAG, "blueReader notice that NFC is now hibernated...");
        return null;
    } else if (bufferstring.startsWith("HYBERNATE SUCCESS")) {
        Log.i (TAG, "blueReader notice that NFC is now really hibernated...");
        if (counterHibernated > 0) {
            Log.w (TAG,"Found hibernation after wrong read. Resend read-command...");
            return requestValue;
        } else {
            return null;
        }
    } else if (bufferstring.startsWith("-r 0:")) {
        Log.d (TAG, "blueReader sends an unknown reaction: '" + bufferstring + "'");
        return null;
    } else if (bufferstring.startsWith("TRANS_FAILED")) {
        Log.w (TAG, "Attention: check position of blueReader on the sensor, as it was not able to read!");
        Home.toaststatic(xdrip.getAppContext().getString(R.string.bluereader_position));
        return null;
    } else if (bufferstring.startsWith("battery: ")) {
        if (BgReading.last() == null || BgReading.last().timestamp + (4 * 60 * 1000) < System.currentTimeMillis()) {
            return requestValue;
        }
    } else {
        counterHibernated = 0;
        processNewTransmitterData(TransmitterData.create(buffer, len, timestamp), timestamp);
        // check for shutdown blueReader if Battery is too low
        if (Pref.getBooleanDefaultFalse("blueReader_turn_off")) {
            if (Pref.getInt("blueReader_turn_off_value",5) > Pref.getInt("bridge_battery",100)) {
                Log.w (TAG, "blueReader will be turn off, as the battery is lower then " + Pref.getInt("blueReader_turn_off_value",5) +"%");
                Home.toaststatic(xdrip.getAppContext().getString(R.string.bluereaderoff) + Pref.getInt("blueReader_turn_off_value",5) +"%");
                return shutdown;
            }
        }
    }

    return null;
}
 
Example 8
Source File: blueReader.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public static byte[] decodeblueReaderPacket(byte[] buffer, int len) {
    int cmdFound = 0;
    long timestamp = new Date().getTime();
    String bufferstring;
    //Log.w(TAG, "Packet: " + bufferstring);
    if (buffer == null) {
        Log.e(TAG, "null buffer passed to decodeblueReaderPacket");
        return null;
    } else {
        bufferstring=new String(buffer);
    }
    if (bufferstring.startsWith("not ready for") ) { //delete the trans_failed, because its normal only if the bluereader could not read the sensor.
        counterHibernated++;
        Log.e(TAG, "Found blueReader in a ugly State (" + counterHibernated + "/3), send hibernate to reset! If this does not help in the next 5 Minutes, then turn the bluereader manually off and on!");
        if (counterHibernated > 2) {
            Log.wtf(TAG, "Ugly state not resolveable. Bluereader will be shut down! Please restart it!");
            Home.toaststatic("BlueReader ugly state not resolveable, bluereader will be shut down. Please restart it!");
            if (!Pref.getBooleanDefaultFalse("blueReader_suppressuglystatemsg")) {
                Notifications.RiseDropAlert(xdrip.getAppContext(),true,"BlueReader Alarm", xdrip.getAppContext().getString(R.string.bluereaderuglystate),1);
            }
            return shutdown;
        } else {
            Home.toaststatic("Found blueReader in a ugly State, send hibernate to reset!");
            return goHybernate; //send hard hibernate, because blueReader is in a ugly state
        }
    } else if (bufferstring.startsWith("IDR")){
        Log.i(TAG, bufferstring);
        PersistentStore.setString("blueReaderFirmware", bufferstring );
        tempVers=Pattern.compile(".*\\|blue(.*)-.*").matcher(bufferstring);
        tempVers.find();
        PersistentStore.setDouble("blueReaderFirmwareValue",Double.parseDouble(tempVers.group(1)));
        Log.i(TAG, "bluereader-Firmware-Version: " + tempVers);
        if (BgReading.last() == null || BgReading.last().timestamp + (4 * 60 * 1000) < System.currentTimeMillis()) {
            return requestValue;
        } else {
            return null;
        }
    } else if (bufferstring.startsWith("WAKE")) {
        Log.d (TAG, "blueReader was set to wakeup-mode manually...");
        return null;
    } else if (bufferstring.startsWith("ECHO")) {
        Log.d (TAG, "blueReader was set to Echo-Mode manually...");
        return null;
    } else if (bufferstring.startsWith("NFC READY")) {
        Log.d (TAG, "blueReader notice that NFC is active...");
        return null;
    } else if (bufferstring.startsWith("NFC_DISABLED")) {
        Log.d (TAG, "blueReader notice that NFC is now hibernated...");
        return null;
    } else if (bufferstring.startsWith("HYBERNATE SUCCESS")) {
        Log.i (TAG, "blueReader notice that NFC is now really hibernated...");
        if (counterHibernated > 0) {
            Log.w (TAG,"Found hibernation after wrong read. Resend read-command...");
            return requestValue;
        } else {
            return null;
        }
    } else if (bufferstring.startsWith("-r 0:")) {
        Log.d (TAG, "blueReader sends an unknown reaction: '" + bufferstring + "'");
        return null;
    } else if (bufferstring.startsWith("TRANS_FAILED")) {
        Log.w (TAG, "Attention: check position of blueReader on the sensor, as it was not able to read!");
        Home.toaststatic(xdrip.getAppContext().getString(R.string.bluereader_position));
        return null;
    } else if (bufferstring.startsWith("battery: ")) {
        if (BgReading.last() == null || BgReading.last().timestamp + (4 * 60 * 1000) < System.currentTimeMillis()) {
            return requestValue;
        }
    } else {
        counterHibernated = 0;
        processNewTransmitterData(TransmitterData.create(buffer, len, timestamp), timestamp);
        // check for shutdown blueReader if Battery is too low
        if (Pref.getBooleanDefaultFalse("blueReader_turn_off")) {
            if (Pref.getInt("blueReader_turn_off_value",5) > Pref.getInt("bridge_battery",100)) {
                Log.w (TAG, "blueReader will be turn off, as the battery is lower then " + Pref.getInt("blueReader_turn_off_value",5) +"%");
                Home.toaststatic(xdrip.getAppContext().getString(R.string.bluereaderoff) + Pref.getInt("blueReader_turn_off_value",5) +"%");
                return shutdown;
            }
        }
    }

    return null;
}