Hi guys, I have a problem which I can't solve. Key...
# coroutines
l
Hi guys, I have a problem which I can't solve. Keyword is bluetooth classic. I'm using a library
BlueFlow
which wraps the classic API and uses flows under the hood. My problem is when I write/send bytes on/to the socket, there is no callback which lets me know when I can send the next bytes. The only way to know when I can send the next bytes is to wait for the response from the device (
inputStream.read(buffer)
) but this leads to confusing code, one can't read the code from top to bottom anymore, if you know what I mean. I share this code in multiple projects and my first soltution uses a "send request" which is stored in a queue and when I get a proper response from the device I poll the next "send request". Is it possible to unwire this with coroutines? Here is the code of my newer project: