// Path: core/src/main/java/com/nightscout/core/utils/GlucoseReading.java
// public class GlucoseReading {
//     private int valueMgdl;
// 
//     public GlucoseReading(float value, GlucoseUnit units) {
//         this.valueMgdl = (units == GlucoseUnit.MGDL) ?
//                 Math.round(value) : Math.round(value * Constants.MMOL_L_TO_MG_DL);
//     }
// 
//     public float asMmol() {
//         return valueMgdl * Constants.MG_DL_TO_MMOL_L;
//     }
// 
//     public String asMmolStr() {
//         return String.format("%.1f", asMmol());
//     }
// 
//     public int asMgdl() {
//         return valueMgdl;
//     }
// 
//     public String asMgdlStr() {
//         return String.valueOf(valueMgdl);
//     }
// 
//     public float as(GlucoseUnit units) {
//         return (units == GlucoseUnit.MGDL) ? asMgdl() : asMmol();
//     }
// 
//     public String asStr(GlucoseUnit units) {
//         return (units == GlucoseUnit.MGDL) ? asMgdlStr() : asMmolStr();
//     }
// 
//     public GlucoseReading subtract(GlucoseReading reading) {
//         return new GlucoseReading(valueMgdl - reading.asMgdl(), GlucoseUnit.MGDL);
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         GlucoseReading that = (GlucoseReading) o;
// 
//         if (valueMgdl != that.valueMgdl) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return valueMgdl;
//     }
// }


import android.content.Context;
import android.util.Log;
import com.getpebble.android.kit.PebbleKit;
import com.getpebble.android.kit.util.PebbleDictionary;
import com.nightscout.android.drivers.AndroidUploaderDevice;
import com.nightscout.core.dexcom.TrendArrow;
import com.nightscout.core.model.GlucoseUnit;
import com.nightscout.core.utils.GlucoseReading;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import java.util.UUID;
    };

    public Pebble(Context context) {
        this.context = context;
        currentReading = null;
        init();
    }

    public void close() {
        context.unregisterReceiver(dataReceiver);
    }

    public PebbleDictionary buildDictionary(TrendArrow trend, String bgValue, int recordTime, int uploaderTimeSec,
                                            String delta, String uploaderBattery, String name) {
        PebbleDictionary dictionary = new PebbleDictionary();
        dictionary.addString(ICON_KEY, String.valueOf(trend.ordinal()));
        dictionary.addString(BG_KEY, bgValue);
        dictionary.addUint32(RECORD_TIME_KEY, recordTime);
        dictionary.addUint32(PHONE_TIME_KEY, uploaderTimeSec);
        dictionary.addString(BG_DELTA_KEY, delta);
        dictionary.addString(UPLOADER_BATTERY_KEY, uploaderBattery);
        // TODO does this need to be set every time?
        dictionary.addString(NAME_KEY, name);
        return dictionary;
    }

    public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTime, Context cntx) {
        sendDownload(reading, trend, recordTime, cntx, false);
    }

// Path: core/src/main/java/com/nightscout/core/utils/GlucoseReading.java
// public class GlucoseReading {
//     private int valueMgdl;
// 
//     public GlucoseReading(float value, GlucoseUnit units) {
//         this.valueMgdl = (units == GlucoseUnit.MGDL) ?
//                 Math.round(value) : Math.round(value * Constants.MMOL_L_TO_MG_DL);
//     }
// 
//     public float asMmol() {
//         return valueMgdl * Constants.MG_DL_TO_MMOL_L;
//     }
// 
//     public String asMmolStr() {
//         return String.format("%.1f", asMmol());
//     }
// 
//     public int asMgdl() {
//         return valueMgdl;
//     }
// 
//     public String asMgdlStr() {
//         return String.valueOf(valueMgdl);
//     }
// 
//     public float as(GlucoseUnit units) {
//         return (units == GlucoseUnit.MGDL) ? asMgdl() : asMmol();
//     }
// 
//     public String asStr(GlucoseUnit units) {
//         return (units == GlucoseUnit.MGDL) ? asMgdlStr() : asMmolStr();
//     }
// 
//     public GlucoseReading subtract(GlucoseReading reading) {
//         return new GlucoseReading(valueMgdl - reading.asMgdl(), GlucoseUnit.MGDL);
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         GlucoseReading that = (GlucoseReading) o;
// 
//         if (valueMgdl != that.valueMgdl) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return valueMgdl;
//     }
// }


// Path: app/src/main/java/com/nightscout/android/wearables/Pebble.java
import android.content.Context;
import android.util.Log;
import com.getpebble.android.kit.PebbleKit;
import com.getpebble.android.kit.util.PebbleDictionary;
import com.nightscout.android.drivers.AndroidUploaderDevice;
import com.nightscout.core.dexcom.TrendArrow;
import com.nightscout.core.model.GlucoseUnit;
import com.nightscout.core.utils.GlucoseReading;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import java.util.UUID;

    };

    public Pebble(Context context) {
        this.context = context;
        currentReading = null;
        init();
    }

    public void close() {
        context.unregisterReceiver(dataReceiver);
    }

    public PebbleDictionary buildDictionary(TrendArrow trend, String bgValue, int recordTime, int uploaderTimeSec,
                                            String delta, String uploaderBattery, String name) {
        PebbleDictionary dictionary = new PebbleDictionary();
        dictionary.addString(ICON_KEY, String.valueOf(trend.ordinal()));
        dictionary.addString(BG_KEY, bgValue);
        dictionary.addUint32(RECORD_TIME_KEY, recordTime);
        dictionary.addUint32(PHONE_TIME_KEY, uploaderTimeSec);
        dictionary.addString(BG_DELTA_KEY, delta);
        dictionary.addString(UPLOADER_BATTERY_KEY, uploaderBattery);
        // TODO does this need to be set every time?
        dictionary.addString(NAME_KEY, name);
        return dictionary;
    }

    public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTime, Context cntx) {
        sendDownload(reading, trend, recordTime, cntx, false);
    }

    public void sendDownload(GlucoseReading reading, TrendArrow trend, long recordTime, Context cntx, boolean resend) {