I'm writing an Android application that is using RxAndroidBle, to support my device I need a higher MTU
I followed the provided library example:https://github.com/Polidea/RxAndroidBle/wiki/Tutorial:-MTU-negotiation
But it is not compiling
private ObservableTransformer<RxBleConnection, RxBleConnection> mtuNegotiationObservableTransformer = upstream -> {
return upstream.doOnSubscribe(ignoredDisposable -> Log.i("MTU", "MTU negotiation is supported")
.flatMapSingle(connection ->
connection.requestMtu(GATT_MTU_MAXIMUM)
.doOnSubscribe(ignoredDisposable -> Log.i("MTU", "Negotiating MTU started"))
.doOnSuccess(mtu -> Log.i("MTU", "Negotiated MTU: " + mtu))
.ignoreElement()
.andThen(Single.just(connection)));
};
The compiler message is: cannot resolve method 'flatmapsingle'
Why is it that it is not working? In other parts of my code I´m using .flatMapSingle without a problem. Thanks for helping!
There seem to be a mistake in number of closing brackets. Try the below code:
private ObservableTransformer<RxBleConnection, RxBleConnection> mtuNegotiationObservableTransformer = upstream -> {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return upstream.doOnSubscribe(ignoredDisposable -> Log.i("MTU", "MTU negotiation is not supported")); // added a closing bracket here
}
return upstream
.doOnSubscribe(ignoredDisposable -> Log.i("MTU", "MTU negotiation is supported")) // and here
.flatMapSingle(connection ->
connection.requestMtu(GATT_MTU_MAXIMUM)
.doOnSubscribe(ignoredDisposable -> Log.i("MTU", "Negotiating MTU started"))
.doOnSuccess(mtu -> Log.i("MTU", "Negotiated MTU: " + mtu))
.ignoreElement()
.andThen(Single.just(connection)));
};