I have a BLE GATT service whose characteristic is set to indicate
. When I write to the characteristic, the peripheral does some computation and indicates back a changed value – picked up by the BroadcastReceiver
in a block looking something like this: private val gattUpdateReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { val action = intent.action when { BLEConstants.ACTION_DATA_AVAILABLE.equals(action) -> { Log.i(TAG, "you got data!") //etc, you get the idea.
I want to chain several writes to that characteristic together: write -> get updated value -> write2 -> get updated value -> write3 ...
How do I do this so that I don’t get write -> write2 -> get updated value...
out of order? The BroadcastReceiver
doesn’t (and shouldn’t) know what data to be indicated back, so it can’t go “ah, I was just indicated XYZ
so it’s time for write2()
“.
submitted by /u/tofuwat
[link] [comments]