@Override public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) { Log.e(TAG, "OnCharacteristic WRITE started: " + getUUIDName(characteristic.getUuid()) + " status: " + getStatusName(status)); //Log.e(TAG, "Write Status " + String.valueOf(status)); //Log.e(TAG, "Characteristic " + String.valueOf(characteristic.getUuid())); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processOnCharacteristicWrite(gatt, characteristic, status); } }); } else { processOnCharacteristicWrite(gatt, characteristic, status); } }
@Override public void onDescriptorWrite(final BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) { Log.e(TAG, "OnDescriptor WRITE started: status: " + getStatusName(status)); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processonDescrptorWrite(gatt, descriptor, status); } }); } else { processonDescrptorWrite(gatt, descriptor, status); } }
@Override public void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) { Log.e(TAG, "OnCharacteristic READ started: " + getUUIDName(characteristic.getUuid()) + " status: " + status); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processOnCharacteristicRead(gatt, characteristic, status); } }); } else { processOnCharacteristicRead(gatt, characteristic, status); } }
@Override public void onDescriptorWrite(final BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) { Log.e(TAG, "OnDescriptor WRITE started: status: " + getStatusName(status)); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processonDescrptorWrite(gatt, descriptor, status); } }); } else { processonDescrptorWrite(gatt, descriptor, status); } }
@Override public void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) { Log.e(TAG, "OnCharacteristic READ started: " + getUUIDName(characteristic.getUuid()) + " status: " + status); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processOnCharacteristicRead(gatt, characteristic, status); } }); } else { processOnCharacteristicRead(gatt, characteristic, status); } }
@Override public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) { Log.e(TAG, "OnCharacteristic WRITE started: " + getUUIDName(characteristic.getUuid()) + " status: " + getStatusName(status)); //Log.e(TAG, "Write Status " + String.valueOf(status)); //Log.e(TAG, "Characteristic " + String.valueOf(characteristic.getUuid())); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processOnCharacteristicWrite(gatt, characteristic, status); } }); } else { processOnCharacteristicWrite(gatt, characteristic, status); } }
@Override public void onDescriptorWrite(final BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) { Log.e(TAG, "OnDescriptor WRITE started: status: " + getStatusName(status)); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processonDescrptorWrite(gatt, descriptor, status); } }); } else { processonDescrptorWrite(gatt, descriptor, status); } }
@Override // Characteristic notification public void onCharacteristicChanged(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) { Log.e(TAG, "OnCharacteristic CHANGED started: " + getUUIDName(characteristic.getUuid())); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processRxCharacteristic(gatt, characteristic); } }); } else { processRxCharacteristic(gatt, characteristic); } }
@Override public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) { Log.e(TAG, "OnCharacteristic WRITE started: " + getUUIDName(characteristic.getUuid()) + " status: " + getStatusName(status)); //Log.e(TAG, "Write Status " + String.valueOf(status)); //Log.e(TAG, "Characteristic " + String.valueOf(characteristic.getUuid())); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processOnCharacteristicWrite(gatt, characteristic, status); } }); } else { processOnCharacteristicWrite(gatt, characteristic, status); } }
@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; }
@Override // Characteristic notification public void onCharacteristicChanged(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) { Log.e(TAG, "OnCharacteristic CHANGED started: " + getUUIDName(characteristic.getUuid())); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processRxCharacteristic(gatt, characteristic); } }); } else { processRxCharacteristic(gatt, characteristic); } }
private void processonDescrptorWrite(final BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) { Log.i(TAG, "onDescriptorWrite On Main Thread? " + isOnMainThread()); if (status == BluetoothGatt.GATT_SUCCESS) { Log.e(TAG, "Writing to characteristic: " + getUUIDName(descriptor.getCharacteristic().getUuid())); if (mGatt != null) { mGatt.writeCharacteristic(descriptor.getCharacteristic()); } else { Log.e(TAG, "mGatt was null when trying to write UUID descriptor"); } } else { Log.e(TAG, "not writing characteristic due to Unknown error writing descriptor"); } if (status == 133) { encountered133 = true; } Log.e(TAG, "OnDescriptor WRITE finished: status: " + getStatusName(status)); }
@Override public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) { try { final String msg = "OnCharacteristic WRITE: " + " status: " + getStatusName(status) + " data: " + JoH.bytesToHex(characteristic.getValue()) + " uuid: " + characteristic.getUuid(); if (status == 0) { Log.d(TAG, msg); } else { UserError.Log.e(TAG, msg); } } catch (Exception e) { UserError.Log.wtf(TAG, "Got exception trying to display data: " + e); } }
@Override public void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) { Log.e(TAG, "OnCharacteristic READ started: " + getUUIDName(characteristic.getUuid()) + " status: " + status); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processOnCharacteristicRead(gatt, characteristic, status); } }); } else { processOnCharacteristicRead(gatt, characteristic, status); } }
private void processonDescrptorWrite(final BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) { Log.i(TAG, "onDescriptorWrite On Main Thread? " + isOnMainThread()); if (status == BluetoothGatt.GATT_SUCCESS) { Log.e(TAG, "Writing to characteristic: " + getUUIDName(descriptor.getCharacteristic().getUuid())); if (mGatt != null) { mGatt.writeCharacteristic(descriptor.getCharacteristic()); } else { Log.e(TAG, "mGatt was null when trying to write UUID descriptor"); } } else { Log.e(TAG, "not writing characteristic due to Unknown error writing descriptor"); } if (status == 133) { encountered133 = true; } Log.e(TAG, "OnDescriptor WRITE finished: status: " + getStatusName(status)); }
@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; }
@Override // Characteristic notification public void onCharacteristicChanged(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) { Log.e(TAG, "OnCharacteristic CHANGED started: " + getUUIDName(characteristic.getUuid())); if (enforceMainThread()) { Handler iHandler = new Handler(Looper.getMainLooper()); iHandler.post(new Runnable() { @Override public void run() { processRxCharacteristic(gatt, characteristic); } }); } else { processRxCharacteristic(gatt, characteristic); } }
private void processonDescrptorWrite(final BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) { Log.i(TAG, "onDescriptorWrite On Main Thread? " + isOnMainThread()); if (status == BluetoothGatt.GATT_SUCCESS) { Log.e(TAG, "Writing to characteristic: " + getUUIDName(descriptor.getCharacteristic().getUuid())); if (mGatt != null) { mGatt.writeCharacteristic(descriptor.getCharacteristic()); } else { Log.e(TAG, "mGatt was null when trying to write UUID descriptor"); } } else { Log.e(TAG, "not writing characteristic due to Unknown error writing descriptor"); } if (status == 133) { encountered133 = true; } Log.e(TAG, "OnDescriptor WRITE finished: status: " + getStatusName(status)); }
@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; }
private synchronized void sendAuthRequestTxMessage(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { Log.e(TAG, "Sending new AuthRequestTxMessage to " + getUUIDName(characteristic.getUuid()) + " ..."); authRequest = new AuthRequestTxMessage(getTokenSize()); Log.i(TAG, "AuthRequestTX: " + JoH.bytesToHex(authRequest.byteSequence)); characteristic.setValue(authRequest.byteSequence); if (gatt != null) { gatt.writeCharacteristic(characteristic); } else { Log.e(TAG, "Cannot send AuthRequestTx as supplied gatt is null!"); } }