this my solution for multiple write
mConnObservable.flatMapSingle(rxBleConnection -> {
return rxBleConnection.writeCharacteristic(SSID, mSsidView.getText().toString().getBytes())
.flatMap(ssidBytes -> rxBleConnection.writeCharacteristic(SSID2, mPassPhrase.getText().toString().getBytes())
.flatMap(ssid2Bytes -> rxBleConnection.writeCharacteristic(SSID3, mSecurityModeSpinner.getSelectedItem().toString().getBytes())));
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ssid3Bytes -> {
//do something
}, this::onError, this::onComplete);
you should put the other flatMap operations in first flatMap, beacause you can only get rxBleConnection in first flatMap
Original solution for RxAndroidBle RxJava 1 version:
mConnObservable.flatMap(rxBleConnection -> {
return rxBleConnection.writeCharacteristic(SSID, mSsidView.getText().toString().getBytes())
.flatMap(ssidBytes -> rxBleConnection.writeCharacteristic(SSID2, mPassPhrase.getText().toString().getBytes())
.flatMap(ssid2Bytes -> rxBleConnection.writeCharacteristic(SSID3, mSecurityModeSpinner.getSelectedItem().toString().getBytes())));
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ssid3Bytes -> {
//do something
}, this::onError, this::onComplete);