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

AndroidPeripheral.requestMtu() throws OutOfOrderGattCallbackException #82

Closed
doudasek opened this issue Mar 24, 2021 · 3 comments · Fixed by #83
Closed

AndroidPeripheral.requestMtu() throws OutOfOrderGattCallbackException #82

doudasek opened this issue Mar 24, 2021 · 3 comments · Fixed by #83
Milestone

Comments

@doudasek
Copy link

When requesting MTU change, it internally succeeded but throws an exception. After that call, I am able to send for example 170B (20B before the call). You can see in logcat that it has status 0, which is GATT_SUCCESS in that callback.

Library version: 0.3.0
Phone: Pixel 5, Android 11

Code:

try {
    Timber.d("Requesting MTU: $REQUESTED_MTU")
    peripheral.requestMtu(REQUESTED_MTU)
} catch (e: Exception) {
    e.printStackTrace()
}

Stack trace:

Requesting MTU: 512
configureMTU() - device: 7D:CC:76:A0:A5:A0 mtu: 512
onConfigureMTU() - Device=7D:CC:76:A0:A5:A0 mtu=512 status=0
com.juul.kable.OutOfOrderGattCallbackException: Unexpected response type OnMtuChanged received
at com.juul.kable.AndroidPeripheral.requestMtu(Peripheral.kt:374)
at com.juul.kable.AndroidPeripheral$requestMtu$1.invokeSuspend(Unknown Source:12)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

@twyatt
Copy link
Member

twyatt commented Mar 24, 2021

Thanks for reporting. Was an oversight in the requestMtu implementation.

Can you try the following and let me know if it fixes the issue?

import java.net.URI

repositories {
    maven { url = URI("https://oss.sonatype.org/content/repositories/snapshots") }
}

dependencies {
    implementation("com.juul.kable:core:0.4.0-issue-82-SNAPSHOT")
}

Thanks!


SNAPSHOT published from #83.

@doudasek
Copy link
Author

Thank you, it is working. Do you have an estimation for the 0.5.0 release?

@twyatt
Copy link
Member

twyatt commented Mar 24, 2021

Fixed in 0.4.1.

@twyatt twyatt modified the milestones: 0.5.0, 0.4.1 Mar 24, 2021
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

Successfully merging a pull request may close this issue.

2 participants