Relative Content

Tag Archive for androidkotlinkotlin-coroutineskotlin-flow

Android serial comms using thread, handler, kotlin flows, suspend functions and compose

I’m trying to write an Android app which requires some serial comms with a bluetooth device. Some of this comms is command/response and some of it is event data that just gets sent from the device. All of it is packetized with packet type identifiers. I’ve setup a bluetooth serial thread which handles bluetoothSocket input/output streams. I can create command packets and send them. The thread takes a Handler as an arguement and sends messages to the main thread when a complete data packet is received (a handful of bytes in a ByteArray).

Datastore flow stuck

I’m looking to read my DataStore for Feature Flags I have saved there. DataStore returns a flow, which makes sense but I do really need to read it once at the moment. No fancy logic. Listening to live changes is less important right now but might be in the future.

Kotlin callback-based apis with more than one method

I have a use case called “RegisterDeviceUseCase” with a function “execute()”.
I want this function to call a bluetooth adapter to get some information from the peripheral, and with the result, call a rest api and make execute() return the result from the rest call.