kable
kable copied to clipboard
Cancelling scope of observation prevents restarting observation after creating new scope
As reported on Slack, observation isn't starting after a previous observation is cancelled (and remote peripheral is powered off and back on). Upon reconnecting, setCharacteristicNotification
is not called to enable the observation.
Reproduction steps were said to be:
- Observe a characteristic.
- Cancel the scope of observation.
- Turn off the peripheral (hardware) and turn on it.
- Reconnect with the peripheral.
- Observe the characteristic again.
Travis, I see that didStartNotification = false
is not called in stopObservation
Seems that handler.stopObservation(characteristic)
hangs forever. But I didn't understand the reason. I changed the order of the call and solving this issue, but I can't tell you if is the expected behaviour because handler.stopObservation(characteristic)
is not completed.
private suspend fun stopObservation() {
didStartObservation = false
suppressConnectionExceptions {
handler.stopObservation(characteristic)
}
}
@twyatt
the handler.stopObservation(characteristic)
described above calls setConfigDescriptor(platformCharacteristic, enable = false) but setConfigDescriptor never is completed.
setConfigDescriptor calls write(configDescriptor, DISABLE_NOTIFICATION_VALUE) but never is completed.
the write function calls connection.execute I unable to debug but it never is completed.
the write function calls connection.execute I unable to debug but it never is completed.
Thanks for investigating this! This will be super helpful when I find some time to dig into this.
Unfortunately I don't have time to reproduce the issue, so I'm shooting blind with this fix. If someone is able to test and validate if it actually fixes the issue, it would be much appreciated:
repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
implementation("com.juul.kable:core:0.18.0-issue-358-1-SNAPSHOT")
}
I've been running with and without this snapshot for the last 8 days and it definitely seems to fix both the issues described above. Thanks @twyatt for fixing and @francismariano for defining the issue! 🎉
Thanks for testing/validating the snapshot @ebabel! I've taken the PR out of draft.