Java Code Examples for io.reactivex.subjects.SingleSubject#onError()
The following examples show how to use
io.reactivex.subjects.SingleSubject#onError() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CorePeripheral.java From RxCentralBle with Apache License 2.0 | 6 votes |
private void processRead(SingleSubject<Pair<UUID, byte[]>> scopedSubject, UUID svc, UUID chr) { synchronized (syncRoot) { PeripheralError error = subscribeChecks(); if (error != null) { scopedSubject.onError(error); return; } BluetoothGattCharacteristic characteristic = getCharacteristic(svc, chr); if (characteristic == null) { scopedSubject.onError(new PeripheralError(MISSING_CHARACTERISTIC)); return; } readSubject = scopedSubject; currentOperation = readSubject; if (bluetoothGatt != null && !bluetoothGatt.readCharacteristic(characteristic)) { readSubject.onError(new PeripheralError(READ_CHARACTERISTIC_FAILED, ERROR_STATUS_CALL_FAILED)); } } }
Example 2
Source File: CorePeripheral.java From RxCentralBle with Apache License 2.0 | 6 votes |
private void processUnregisterNotification( SingleSubject<UUID> scopedSubject, UUID svc, UUID chr) { synchronized (syncRoot) { PeripheralError error = subscribeChecks(); if (error != null) { scopedSubject.onError(error); return; } BluetoothGattCharacteristic characteristic = getCharacteristic(svc, chr); if (characteristic == null) { scopedSubject.onError(new PeripheralError(MISSING_CHARACTERISTIC)); return; } registerNotificationSubject = scopedSubject; currentOperation = registerNotificationSubject; if (bluetoothGatt != null) { error = setCharacteristicNotification(bluetoothGatt, characteristic, false); if (error != null) { registerNotificationSubject.onError(new PeripheralError(UNREGISTER_NOTIFICATION_FAILED, error)); } } } }
Example 3
Source File: CorePeripheral.java From RxCentralBle with Apache License 2.0 | 6 votes |
@TargetApi(21) private void processRequestMtu(SingleSubject<Integer> scopedSubject, int mtu) { synchronized (syncRoot) { PeripheralError error = subscribeChecks(); if (error != null) { scopedSubject.onError(error); return; } requestMtuSubject = scopedSubject; currentOperation = requestMtuSubject; if (bluetoothGatt != null && !bluetoothGatt.requestMtu(mtu)) { requestMtuSubject.onError(new PeripheralError(REQUEST_MTU_FAILED, ERROR_STATUS_CALL_FAILED)); } } }
Example 4
Source File: CorePeripheral.java From RxCentralBle with Apache License 2.0 | 6 votes |
private void processReadRssi(SingleSubject<Integer> scopedSubject) { synchronized (syncRoot) { PeripheralError error = subscribeChecks(); if (error != null) { scopedSubject.onError(error); return; } readRssiSubject = scopedSubject; currentOperation = readRssiSubject; if (bluetoothGatt != null && !bluetoothGatt.readRemoteRssi()) { readRssiSubject.onError(new PeripheralError(READ_RSSI_FAILED, ERROR_STATUS_CALL_FAILED)); } } }
Example 5
Source File: CorePeripheral.java From RxCentralBle with Apache License 2.0 | 5 votes |
private void processWrite(SingleSubject<UUID> scopedSubject, UUID svc, UUID chr, byte[] data) { synchronized (syncRoot) { PeripheralError error = subscribeChecks(); if (error != null) { scopedSubject.onError(error); return; } BluetoothGattCharacteristic characteristic = getCharacteristic(svc, chr); if (characteristic == null) { scopedSubject.onError(new PeripheralError(MISSING_CHARACTERISTIC)); return; } writeSubject = scopedSubject; currentOperation = writeSubject; if ((characteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) == BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) { characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); } else { characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT); } if (!characteristic.setValue(data)) { writeSubject.onError(new PeripheralError(CHARACTERISTIC_SET_VALUE_FAILED)); } if (bluetoothGatt != null && !bluetoothGatt.writeCharacteristic(characteristic)) { writeSubject.onError(new PeripheralError(WRITE_CHARACTERISTIC_FAILED, ERROR_STATUS_CALL_FAILED)); } } }
Example 6
Source File: CorePeripheral.java From RxCentralBle with Apache License 2.0 | 5 votes |
private void processRegisterNotification( SingleSubject<UUID> scopedSubject, UUID svc, UUID chr, @Nullable Preprocessor preprocessor) { synchronized (syncRoot) { PeripheralError error = subscribeChecks(); if (error != null) { scopedSubject.onError(error); return; } BluetoothGattCharacteristic characteristic = getCharacteristic(svc, chr); if (characteristic == null) { scopedSubject.onError(new PeripheralError(MISSING_CHARACTERISTIC)); return; } registerNotificationSubject = scopedSubject; currentOperation = registerNotificationSubject; if (bluetoothGatt != null) { error = setCharacteristicNotification(bluetoothGatt, characteristic, true); if (error != null) { registerNotificationSubject.onError(new PeripheralError(REGISTER_NOTIFICATION_FAILED, error)); } else { preprocessorMap.put(chr, preprocessor); } } } }