use of com.eveningoutpost.dexdrip.watch.thinjam.messages.BaseTx in project xDrip by NightscoutFoundation.
the class BlueJayAsset method processAssetRequest.
private static void processAssetRequest(final BlueJayService service, final int assetid) {
UserError.Log.d(TAG, "Processing: " + assetid);
final byte[] bytes = getAssetBytes(assetid);
if (bytes == null) {
UserError.Log.d(TAG, "Cannot get asset bytes");
Inevitable.task("try next asset", 1000, () -> BlueJayAsset.processAssetQueue(service));
return;
}
int assetlength = bytes.length;
final BaseTx packet = new DefineWindowTx((byte) 0x80, (byte) 0, (byte) (assetid >> 8), (byte) (assetlength >> 8), (byte) (assetid & 0xff), (byte) (assetlength & 0xff), (byte) 0, (byte) 0);
val queueMe = service.queueGenericCommand(packet.getBytes(), "asset window: (assetid: " + assetid + " len: " + assetlength + ")", null, service.getARInstance(new ReplyProcessor(service.getI().connection) {
@Override
public void process(byte[] response) {
if (D)
UserError.Log.d(TAG, "Wrote asset request request: " + bytesToHex(response));
if (packet.responseOk(response)) {
UserError.Log.d(TAG, "Request success - sending bulk");
service.queueBufferForAssetStorage(assetid, bytes);
service.doThinJamQueue();
} else {
UserError.Log.d(TAG, "Define Window failed: " + packet.responseText(response));
}
}
}));
UserError.Log.d(TAG, "Queued define window: " + queueMe.toString());
}
use of com.eveningoutpost.dexdrip.watch.thinjam.messages.BaseTx in project xDrip by NightscoutFoundation.
the class BlueJayService method runQueueItem.
// TJ protocol queue items
private synchronized void runQueueItem(final ThinJamItem item) {
UserError.Log.d(TAG, "Running queue item queued: " + item.queuedTimestamp);
if (item.width > 0) {
final BaseTx packet = new DefineWindowTx((byte) 1, (byte) item.windowType, (byte) item.x, (byte) item.y, (byte) item.width, (byte) item.height, (byte) 0, (byte) item.colourEffect);
queueGenericCommand(packet.getBytes(), "define window: (" + item.windowType + ") " + item.x + "," + item.y + " w:" + item.width + " h:" + item.height, null, getARInstance(new ReplyProcessor(I.connection) {
@Override
public void process(byte[] response) {
if (D)
UserError.Log.d(TAG, "Wrote qui record request request: " + bytesToHex(response));
if (packet.responseOk(response)) {
requestBulk(item);
} else {
UserError.Log.d(TAG, "Define Window failed: " + packet.responseText(response));
}
}
}));
} else {
// is not a window request - is flash write
requestBulk(item);
}
}
use of com.eveningoutpost.dexdrip.watch.thinjam.messages.BaseTx in project xDrip-plus by jamorham.
the class BlueJayAsset method processAssetRequest.
private static void processAssetRequest(final BlueJayService service, final int assetid) {
UserError.Log.d(TAG, "Processing: " + assetid);
final byte[] bytes = getAssetBytes(assetid);
if (bytes == null) {
UserError.Log.d(TAG, "Cannot get asset bytes");
Inevitable.task("try next asset", 1000, () -> BlueJayAsset.processAssetQueue(service));
return;
}
int assetlength = bytes.length;
final BaseTx packet = new DefineWindowTx((byte) 0x80, (byte) 0, (byte) (assetid >> 8), (byte) (assetlength >> 8), (byte) (assetid & 0xff), (byte) (assetlength & 0xff), (byte) 0, (byte) 0);
val queueMe = service.queueGenericCommand(packet.getBytes(), "asset window: (assetid: " + assetid + " len: " + assetlength + ")", null, service.getARInstance(new ReplyProcessor(service.getI().connection) {
@Override
public void process(byte[] response) {
if (D)
UserError.Log.d(TAG, "Wrote asset request request: " + bytesToHex(response));
if (packet.responseOk(response)) {
UserError.Log.d(TAG, "Request success - sending bulk");
service.queueBufferForAssetStorage(assetid, bytes);
service.doThinJamQueue();
} else {
UserError.Log.d(TAG, "Define Window failed: " + packet.responseText(response));
}
}
}));
UserError.Log.d(TAG, "Queued define window: " + queueMe.toString());
}
use of com.eveningoutpost.dexdrip.watch.thinjam.messages.BaseTx in project xDrip-plus by jamorham.
the class BlueJayService method runQueueItem.
// TJ protocol queue items
private synchronized void runQueueItem(final ThinJamItem item) {
UserError.Log.d(TAG, "Running queue item queued: " + item.queuedTimestamp);
if (item.width > 0) {
final BaseTx packet = new DefineWindowTx((byte) 1, (byte) item.windowType, (byte) item.x, (byte) item.y, (byte) item.width, (byte) item.height, (byte) 0, (byte) item.colourEffect);
queueGenericCommand(packet.getBytes(), "define window: (" + item.windowType + ") " + item.x + "," + item.y + " w:" + item.width + " h:" + item.height, null, getARInstance(new ReplyProcessor(I.connection) {
@Override
public void process(byte[] response) {
if (D)
UserError.Log.d(TAG, "Wrote qui record request request: " + bytesToHex(response));
if (packet.responseOk(response)) {
requestBulk(item);
} else {
UserError.Log.d(TAG, "Define Window failed: " + packet.responseText(response));
}
}
}));
} else {
// is not a window request - is flash write
requestBulk(item);
}
}
Aggregations