I am trying to read and write in/from characteristic of particular service of BLE device.
I am referring demo code from RxAndroidBle here.
In this demo as soon as discover services when you press particular characteristic it go in next screen and make connection and then doing read/write operation.
My question: is there any way to read/write any characteristics after service discovered? Why you need to make connection for with any characteristics before read/write operation?
Below code is used to connect single characteristic but i want to connect 3-4 characteristics at the same time. i tried .flatmap() but giving me errors.
final Disposable connectionDisposable = connectionObservable
.flatMapSingle(RxBleConnection::discoverServices)
.flatMapSingle(rxBleDeviceServices -> rxBleDeviceServices.getCharacteristic(Consts.ALERT_LEVEL_UUID))
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(disposable -> text_connection.setText("Status: Connecting"))
.subscribe(
characteristic -> {
updateUI(characteristic);
Log.i(getClass().getSimpleName(), "Hey, connection has been established!");
},
this::onConnectionFailure,
this::onConnectionReceived
);
Like in below image as soon as you press R or W for any characteristic it will give you result.