Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bt socket closed, read return: -1, but then emission attempt has been detected #2

Open
picobulgarelli opened this issue Jan 28, 2021 · 2 comments

Comments

@picobulgarelli
Copy link

If I turn off the connected device I receive this error and I don't receive the "Disconnected" message.

Complete error from your sample:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.github.thanosfisherman.blueflow.sample, PID: 12390
java.lang.IllegalStateException: Flow exception transparency is violated:
Previous 'emit' call has thrown exception java.io.IOException: bt socket closed, read return: -1, but then emission attempt of value 'io.github.thanosfisherman.blueflow.sample.BtConnection$BtErrorConnectingState@cb152e5' has been detected.
Emissions from 'catch' blocks are prohibited in order to avoid unspecified behaviour, 'Flow.catch' operator can be used instead.
For a more detailed explanation, please refer to Flow documentation.
at kotlinx.coroutines.flow.internal.SafeCollector.exceptionTransparencyViolated(SafeCollector.kt:114)
at kotlinx.coroutines.flow.internal.SafeCollector.checkContext(SafeCollector.kt:82)
at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:70)
at kotlinx.coroutines.flow.internal.SafeCollector.emit(SafeCollector.kt:55)
at io.github.thanosfisherman.blueflow.sample.usecase.BtConnectUseCase$connect$1.invokeSuspend(BtConnectUseCase.kt:19)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7399)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)

It would be nice if you can also provide a sample to receive/send data using the mvvm architecture.

@ThanosFisherman
Copy link
Owner

I've never encountered this issue before with my Bluetooth devices. Thanks for reporting this I will have a look.

@WebTiger89
Copy link

BtDisconnectedState is never set or did I miss something? I'm also wondering how to distinguish between an error and an intended disconnect and how to disconnect friendly? Unfortunately your sample does not cover this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants