public synchronized static void doKeepAlive(Ob1G5CollectionService parent, RxBleConnection connection, Runnable runnable) { if (connection == null) return; connection.writeCharacteristic(Authentication, nn(new KeepAliveTxMessage(60).byteSequence)) .timeout(2, TimeUnit.SECONDS) .subscribe( characteristicValue -> { UserError.Log.d(TAG, "Sent keep-alive " + ((runnable != null) ? "Running runnable chain" : "")); if (runnable != null) { runnable.run(); } throw new OperationSuccess("keep-alive runnable complete"); }, throwable -> { if (!(throwable instanceof OperationSuccess)) { UserError.Log.e(TAG, "Got error sending keepalive: " + throwable); } }); }
public synchronized static void doKeepAlive(Ob1G5CollectionService parent, RxBleConnection connection, Runnable runnable) { if (connection == null) return; connection.writeCharacteristic(Authentication, nn(new KeepAliveTxMessage(60).byteSequence)) .timeout(2, TimeUnit.SECONDS) .subscribe( characteristicValue -> { UserError.Log.d(TAG, "Sent keep-alive " + ((runnable != null) ? "Running runnable chain" : "")); if (runnable != null) { runnable.run(); } throw new OperationSuccess("keep-alive runnable complete"); }, throwable -> { if (!(throwable instanceof OperationSuccess)) { UserError.Log.e(TAG, "Got error sending keepalive: " + throwable); } }); }
public synchronized static void doKeepAlive(Ob1G5CollectionService parent, RxBleConnection connection, Runnable runnable) { if (connection == null) return; connection.writeCharacteristic(Authentication, nn(new KeepAliveTxMessage(60).byteSequence)) .timeout(2, TimeUnit.SECONDS) .subscribe( characteristicValue -> { UserError.Log.d(TAG, "Sent keep-alive " + ((runnable != null) ? "Running runnable chain" : "")); if (runnable != null) { runnable.run(); } throw new OperationSuccess("keep-alive runnable complete"); }, throwable -> { if (!(throwable instanceof OperationSuccess)) { UserError.Log.e(TAG, "Got error sending keepalive: " + throwable); } }); }
@SuppressLint("CheckResult") public static boolean doReset(Ob1G5CollectionService parent, RxBleConnection connection) { if (connection == null) return false; parent.msg("Hard Resetting Transmitter"); connection.writeCharacteristic(Control, nn(new ResetTxMessage().byteSequence)) .subscribe(characteristicValue -> { if (d) UserError.Log.d(TAG, "Wrote ResetTxMessage request!!"); parent.msg("Hard Reset Sent"); }, throwable -> { parent.msg("Hard Reset maybe Failed"); UserError.Log.e(TAG, "Failed to write ResetTxMessage: " + throwable); if (throwable instanceof BleGattCharacteristicException) { final int status = ((BleGattCharacteristicException) throwable).getStatus(); UserError.Log.e(TAG, "Got status message: " + BluetoothServices.getStatusName(status)); } }); return true; }
@SuppressLint("CheckResult") public static boolean doReset(Ob1G5CollectionService parent, RxBleConnection connection) { if (connection == null) return false; parent.msg("Hard Resetting Transmitter"); connection.writeCharacteristic(Control, nn(new ResetTxMessage().byteSequence)) .subscribe(characteristicValue -> { if (d) UserError.Log.d(TAG, "Wrote ResetTxMessage request!!"); parent.msg("Hard Reset Sent"); }, throwable -> { parent.msg("Hard Reset maybe Failed"); UserError.Log.e(TAG, "Failed to write ResetTxMessage: " + throwable); if (throwable instanceof BleGattCharacteristicException) { final int status = ((BleGattCharacteristicException) throwable).getStatus(); UserError.Log.e(TAG, "Got status message: " + BluetoothServices.getStatusName(status)); } }); return true; }
@SuppressLint("CheckResult") public static boolean doReset(Ob1G5CollectionService parent, RxBleConnection connection) { if (connection == null) return false; parent.msg("Hard Resetting Transmitter"); connection.writeCharacteristic(Control, nn(new ResetTxMessage().byteSequence)) .subscribe(characteristicValue -> { if (d) UserError.Log.d(TAG, "Wrote ResetTxMessage request!!"); parent.msg("Hard Reset Sent"); }, throwable -> { parent.msg("Hard Reset maybe Failed"); UserError.Log.e(TAG, "Failed to write ResetTxMessage: " + throwable); if (throwable instanceof BleGattCharacteristicException) { final int status = ((BleGattCharacteristicException) throwable).getStatus(); UserError.Log.e(TAG, "Got status message: " + BluetoothServices.getStatusName(status)); } }); return true; }
connection.writeCharacteristic(Authentication, nn(new KeepAliveTxMessage(60).byteSequence)) .subscribe( characteristicValue -> { parent.instantCreateBondIfAllowed(); speakSlowly(); connection.writeCharacteristic(Authentication, nn(new BondRequestTxMessage().byteSequence)) .subscribe( bondRequestValue -> {
connection.writeCharacteristic(Authentication, nn(new KeepAliveTxMessage(60).byteSequence)) .subscribe( characteristicValue -> { parent.instantCreateBondIfAllowed(); speakSlowly(); connection.writeCharacteristic(Authentication, nn(new BondRequestTxMessage().byteSequence)) .subscribe( bondRequestValue -> {
connection.writeCharacteristic(Authentication, nn(new KeepAliveTxMessage(60).byteSequence)) .subscribe( characteristicValue -> { parent.instantCreateBondIfAllowed(); speakSlowly(); connection.writeCharacteristic(Authentication, nn(new BondRequestTxMessage().byteSequence)) .subscribe( bondRequestValue -> {
@SuppressLint("CheckResult") private static void disconnectNow(Ob1G5CollectionService parent, RxBleConnection connection) { // tell device to disconnect now UserError.Log.d(TAG, "Disconnect NOW: " + JoH.dateTimeText(JoH.tsl())); speakSlowly(); connection.writeCharacteristic(Control, nn(new DisconnectTxMessage().byteSequence)) .timeout(2, TimeUnit.SECONDS) // .observeOn(Schedulers.newThread()) // .subscribeOn(Schedulers.newThread()) .subscribe(disconnectValue -> { if (d) UserError.Log.d(TAG, "Wrote disconnect request"); parent.changeState(Ob1G5CollectionService.STATE.CLOSE); throw new OperationSuccess("Requested Disconnect"); }, throwable -> { if (!(throwable instanceof OperationSuccess)) { UserError.Log.d(TAG, "Disconnect NOW failure: " + JoH.dateTimeText(JoH.tsl())); if (throwable instanceof BleDisconnectedException) { UserError.Log.d(TAG, "Failed to write DisconnectTxMessage as already disconnected: " + throwable); } else { UserError.Log.e(TAG, "Failed to write DisconnectTxMessage: " + throwable); } parent.changeState(Ob1G5CollectionService.STATE.CLOSE); } }); UserError.Log.d(TAG, "Disconnect NOW exit: " + JoH.dateTimeText(JoH.tsl())); }
@SuppressLint("CheckResult") private static void disconnectNow(Ob1G5CollectionService parent, RxBleConnection connection) { // tell device to disconnect now UserError.Log.d(TAG, "Disconnect NOW: " + JoH.dateTimeText(JoH.tsl())); speakSlowly(); connection.writeCharacteristic(Control, nn(new DisconnectTxMessage().byteSequence)) .timeout(2, TimeUnit.SECONDS) // .observeOn(Schedulers.newThread()) // .subscribeOn(Schedulers.newThread()) .subscribe(disconnectValue -> { if (d) UserError.Log.d(TAG, "Wrote disconnect request"); parent.changeState(Ob1G5CollectionService.STATE.CLOSE); throw new OperationSuccess("Requested Disconnect"); }, throwable -> { if (!(throwable instanceof OperationSuccess)) { UserError.Log.d(TAG, "Disconnect NOW failure: " + JoH.dateTimeText(JoH.tsl())); if (throwable instanceof BleDisconnectedException) { UserError.Log.d(TAG, "Failed to write DisconnectTxMessage as already disconnected: " + throwable); } else { UserError.Log.e(TAG, "Failed to write DisconnectTxMessage: " + throwable); } parent.changeState(Ob1G5CollectionService.STATE.CLOSE); } }); UserError.Log.d(TAG, "Disconnect NOW exit: " + JoH.dateTimeText(JoH.tsl())); }
@SuppressLint("CheckResult") private static void disconnectNow(Ob1G5CollectionService parent, RxBleConnection connection) { // tell device to disconnect now UserError.Log.d(TAG, "Disconnect NOW: " + JoH.dateTimeText(JoH.tsl())); speakSlowly(); connection.writeCharacteristic(Control, nn(new DisconnectTxMessage().byteSequence)) .timeout(2, TimeUnit.SECONDS) // .observeOn(Schedulers.newThread()) // .subscribeOn(Schedulers.newThread()) .subscribe(disconnectValue -> { if (d) UserError.Log.d(TAG, "Wrote disconnect request"); parent.changeState(Ob1G5CollectionService.STATE.CLOSE); throw new OperationSuccess("Requested Disconnect"); }, throwable -> { if (!(throwable instanceof OperationSuccess)) { UserError.Log.d(TAG, "Disconnect NOW failure: " + JoH.dateTimeText(JoH.tsl())); if (throwable instanceof BleDisconnectedException) { UserError.Log.d(TAG, "Failed to write DisconnectTxMessage as already disconnected: " + throwable); } else { UserError.Log.e(TAG, "Failed to write DisconnectTxMessage: " + throwable); } parent.changeState(Ob1G5CollectionService.STATE.CLOSE); } }); UserError.Log.d(TAG, "Disconnect NOW exit: " + JoH.dateTimeText(JoH.tsl())); }
connection.writeCharacteristic(Authentication, nn(authRequest.byteSequence)) .subscribe( characteristicValue -> {
connection.writeCharacteristic(Authentication, nn(authRequest.byteSequence)) .subscribe( characteristicValue -> {
reprocessTxMessage(unit.msg); if (unit.retry < 5 && JoH.msSince(unit.timestamp) < HOUR_IN_MS * 8) { connection.writeCharacteristic(Control, nn(unit.msg.byteSequence)) .timeout(2, TimeUnit.SECONDS) .subscribe(value -> {
reprocessTxMessage(unit.msg); if (unit.retry < 5 && JoH.msSince(unit.timestamp) < HOUR_IN_MS * 8) { connection.writeCharacteristic(Control, nn(unit.msg.byteSequence)) .timeout(2, TimeUnit.SECONDS) .subscribe(value -> {
reprocessTxMessage(unit.msg); if (unit.retry < 5 && JoH.msSince(unit.timestamp) < HOUR_IN_MS * 8) { connection.writeCharacteristic(Control, nn(unit.msg.byteSequence)) .timeout(2, TimeUnit.SECONDS) .subscribe(value -> {
UserError.Log.d(TAG, "Transmitter trying auth challenge"); connection.writeCharacteristic(Authentication, nn(new BaseAuthChallengeTxMessage(challengeHash).byteSequence)) .subscribe( challenge_value -> {
UserError.Log.d(TAG, "Transmitter trying auth challenge"); connection.writeCharacteristic(Authentication, nn(new BaseAuthChallengeTxMessage(challengeHash).byteSequence)) .subscribe( challenge_value -> {
UserError.Log.d(TAG, "Transmitter trying auth challenge"); connection.writeCharacteristic(Authentication, nn(new BaseAuthChallengeTxMessage(challengeHash).byteSequence)) .subscribe( challenge_value -> {