use of com.eveningoutpost.dexdrip.watch.thinjam.messages.SetTimeTx 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();
}
use of com.eveningoutpost.dexdrip.watch.thinjam.messages.SetTimeTx in project xDrip by NightscoutFoundation.
the class BlueJayService method sendTime.
// Not using packet queue due to reactive time sensitive nature
private void sendTime() {
final String func = "SetTime";
final SetTimeTx outbound = new SetTimeTx();
UserError.Log.d(TAG, "Outbound: " + bytesToHex(outbound.getBytes()));
I.connection.writeCharacteristic(THINJAM_WRITE, outbound.getBytes()).subscribe(response -> {
SetTimeTx reply = new SetTimeTx(response);
if (D)
UserError.Log.d(TAG, func + " response: " + bytesToHex(response) + " " + reply.toS());
UserError.Log.e(TAG, "Time difference with watch: " + ((outbound.getTimestamp() - reply.getTimestamp()) / 1000d));
changeNextState();
}, throwable -> {
UserError.Log.e(TAG, "Failed to write " + func + " request: " + throwable);
if (throwable instanceof BleGattCharacteristicException) {
final int status = ((BleGattCharacteristicException) throwable).getStatus();
UserError.Log.e(TAG, "Got status message: " + Helper.getStatusName(status));
} else {
UserError.Log.d(TAG, "Throwable in " + func + " " + throwable);
if (throwable instanceof BleCharacteristicNotFoundException) {
UserError.Log.d(TAG, "Assuming wrong firmware version");
changeNextState();
} else {
changeState(CLOSE);
}
}
});
}
use of com.eveningoutpost.dexdrip.watch.thinjam.messages.SetTimeTx 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();
}
use of com.eveningoutpost.dexdrip.watch.thinjam.messages.SetTimeTx in project xDrip-plus by jamorham.
the class BlueJayService method sendTime.
// Not using packet queue due to reactive time sensitive nature
private void sendTime() {
final String func = "SetTime";
final SetTimeTx outbound = new SetTimeTx();
UserError.Log.d(TAG, "Outbound: " + bytesToHex(outbound.getBytes()));
I.connection.writeCharacteristic(THINJAM_WRITE, outbound.getBytes()).subscribe(response -> {
SetTimeTx reply = new SetTimeTx(response);
if (D)
UserError.Log.d(TAG, func + " response: " + bytesToHex(response) + " " + reply.toS());
UserError.Log.e(TAG, "Time difference with watch: " + ((outbound.getTimestamp() - reply.getTimestamp()) / 1000d));
changeNextState();
}, throwable -> {
UserError.Log.e(TAG, "Failed to write " + func + " request: " + throwable);
if (throwable instanceof BleGattCharacteristicException) {
final int status = ((BleGattCharacteristicException) throwable).getStatus();
UserError.Log.e(TAG, "Got status message: " + Helper.getStatusName(status));
} else {
UserError.Log.d(TAG, "Throwable in " + func + " " + throwable);
if (throwable instanceof BleCharacteristicNotFoundException) {
UserError.Log.d(TAG, "Assuming wrong firmware version");
changeNextState();
} else {
changeState(CLOSE);
}
}
});
}
Aggregations