Search in sources :

Example 1 with BytesGenerator

use of com.eveningoutpost.dexdrip.utils.BytesGenerator in project xDrip by NightscoutFoundation.

the class BlueJayService method setTime.

public void setTime() {
    new QueueMe().setGenerator(new BytesGenerator() {

        @Override
        public byte[] produce() {
            timeOutbound = new SetTimeTx();
            return timeOutbound.getBytes();
        }
    }).setDescription("Set time").expireInSeconds(30).setProcessor(new ReplyProcessor(I.connection) {

        @Override
        public void process(byte[] bytes) {
            final SetTimeTx reply = new SetTimeTx(bytes);
            UserError.Log.d(TAG, "Time Process callback: " + JoH.bytesToHex(bytes));
            getInfo().parseSetTime(reply, timeOutbound);
            UserError.Log.d(TAG, "Time difference with watch: " + ((timeOutbound.getTimestamp() - reply.getTimestamp()) / 1000d));
        }
    }).queue();
}
Also used : BytesGenerator(com.eveningoutpost.dexdrip.utils.BytesGenerator) SetTimeTx(com.eveningoutpost.dexdrip.watch.thinjam.messages.SetTimeTx) ReplyProcessor(com.eveningoutpost.dexdrip.utils.bt.ReplyProcessor)

Example 2 with BytesGenerator

use of com.eveningoutpost.dexdrip.utils.BytesGenerator in project xDrip-plus by jamorham.

the class BlueJayService method setTime.

public void setTime() {
    new QueueMe().setGenerator(new BytesGenerator() {

        @Override
        public byte[] produce() {
            timeOutbound = new SetTimeTx();
            return timeOutbound.getBytes();
        }
    }).setDescription("Set time").expireInSeconds(30).setProcessor(new ReplyProcessor(I.connection) {

        @Override
        public void process(byte[] bytes) {
            final SetTimeTx reply = new SetTimeTx(bytes);
            UserError.Log.d(TAG, "Time Process callback: " + JoH.bytesToHex(bytes));
            getInfo().parseSetTime(reply, timeOutbound);
            UserError.Log.d(TAG, "Time difference with watch: " + ((timeOutbound.getTimestamp() - reply.getTimestamp()) / 1000d));
        }
    }).queue();
}
Also used : BytesGenerator(com.eveningoutpost.dexdrip.utils.BytesGenerator) SetTimeTx(com.eveningoutpost.dexdrip.watch.thinjam.messages.SetTimeTx) ReplyProcessor(com.eveningoutpost.dexdrip.utils.bt.ReplyProcessor)

Aggregations

BytesGenerator (com.eveningoutpost.dexdrip.utils.BytesGenerator)2 ReplyProcessor (com.eveningoutpost.dexdrip.utils.bt.ReplyProcessor)2 SetTimeTx (com.eveningoutpost.dexdrip.watch.thinjam.messages.SetTimeTx)2