in rx-central-ble/src/main/java/com/uber/rxcentralble/core/CorePeripheral.java [274:306]
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));
}
}
}