Search in sources :

Example 1 with GlucoseTx

use of com.eveningoutpost.dexdrip.watch.thinjam.messages.GlucoseTx in project xDrip by NightscoutFoundation.

the class BlueJayService method sendGlucose.

public void sendGlucose() {
    val last = BgReading.last();
    if (last != null && msSince(last.timestamp) < Constants.HOUR_IN_MS) {
        val info = BlueJayInfo.getInfo(BlueJay.getMac());
        if (Math.abs(info.lastReadingTime - last.timestamp) > Constants.MINUTE_IN_MS * 3) {
            val glucoseTx = new GlucoseTx(last);
            if (glucoseTx.isValid()) {
                val item = new QueueMe().setBytes(glucoseTx.getBytes()).expireInSeconds(60).setDescription("Glucose to watch");
                item.setProcessor(new AuthReplyProcessor(new ReplyProcessor(I.connection) {

                    @Override
                    public void process(byte[] bytes) {
                        UserError.Log.d(TAG, "Glucose Incoming reply processor: " + HexDump.dumpHexString(bytes));
                        info.displayUpdated();
                    }
                }).setTag(item));
                item.queue();
                doQueue();
            } else {
                UserError.Log.d(TAG, "GlucoseTX wasn't valid so not sending.");
            }
        } else {
            UserError.Log.d(TAG, "Watch already has recent reading");
        // watch reading too close to the reading we were going to send
        }
    }
}
Also used : lombok.val(lombok.val) GlucoseTx(com.eveningoutpost.dexdrip.watch.thinjam.messages.GlucoseTx) ReplyProcessor(com.eveningoutpost.dexdrip.utils.bt.ReplyProcessor)

Example 2 with GlucoseTx

use of com.eveningoutpost.dexdrip.watch.thinjam.messages.GlucoseTx in project xDrip-plus by jamorham.

the class BlueJayService method sendGlucose.

public void sendGlucose() {
    val last = BgReading.last();
    if (last != null && msSince(last.timestamp) < Constants.HOUR_IN_MS) {
        val info = BlueJayInfo.getInfo(BlueJay.getMac());
        if (Math.abs(info.lastReadingTime - last.timestamp) > Constants.MINUTE_IN_MS * 3) {
            val glucoseTx = new GlucoseTx(last);
            if (glucoseTx.isValid()) {
                val item = new QueueMe().setBytes(glucoseTx.getBytes()).expireInSeconds(60).setDescription("Glucose to watch");
                item.setProcessor(new AuthReplyProcessor(new ReplyProcessor(I.connection) {

                    @Override
                    public void process(byte[] bytes) {
                        UserError.Log.d(TAG, "Glucose Incoming reply processor: " + HexDump.dumpHexString(bytes));
                        info.displayUpdated();
                    }
                }).setTag(item));
                item.queue();
                doQueue();
            } else {
                UserError.Log.d(TAG, "GlucoseTX wasn't valid so not sending.");
            }
        } else {
            UserError.Log.d(TAG, "Watch already has recent reading");
        // watch reading too close to the reading we were going to send
        }
    }
}
Also used : lombok.val(lombok.val) GlucoseTx(com.eveningoutpost.dexdrip.watch.thinjam.messages.GlucoseTx) ReplyProcessor(com.eveningoutpost.dexdrip.utils.bt.ReplyProcessor)

Aggregations

ReplyProcessor (com.eveningoutpost.dexdrip.utils.bt.ReplyProcessor)2 GlucoseTx (com.eveningoutpost.dexdrip.watch.thinjam.messages.GlucoseTx)2 lombok.val (lombok.val)2