diff --git a/profile/src/main/java/no/nordicsemi/android/toolbox/profile/repository/channelSounding/ChannelSoundingManager.kt b/profile/src/main/java/no/nordicsemi/android/toolbox/profile/repository/channelSounding/ChannelSoundingManager.kt index 9e7f2efd..23b24012 100644 --- a/profile/src/main/java/no/nordicsemi/android/toolbox/profile/repository/channelSounding/ChannelSoundingManager.kt +++ b/profile/src/main/java/no/nordicsemi/android/toolbox/profile/repository/channelSounding/ChannelSoundingManager.kt @@ -215,13 +215,14 @@ class ChannelSoundingManager @Inject constructor( rangingSession = null _rangingData.value = null // unregister the callback - + rangingManager?.unregisterCapabilitiesCallback(rangingCapabilityCallback) + // Invoke the onClosed callback after a short delay to ensure the session is closed onClosed?.let { _rangingData.value = RangingSessionAction.OnStart // Wait for a moment to ensure the session is properly closed before invoking the callback // Launch a coroutine to delay and call onClosed CoroutineScope(Dispatchers.IO).launch { - delay(500) + delay(1000) it() }