Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ actual class GattServer(
return try {
withTimeout(SEND_TIMEOUT) {
while (true) {
val startCount = peripheralManagerReadyCount.value
if (peripheralManager.updateValue(
value = data.toNSData(),
forCharacteristic = cbCharacteristic,
Expand All @@ -235,7 +236,7 @@ actual class GattServer(
return@withTimeout true
}
// Write did not succeed; wait for queue to drain
peripheralManagerReady.first()
peripheralManagerReadyCount.first { it > startCount }
}
false
}
Expand Down Expand Up @@ -338,13 +339,11 @@ actual class GattServer(
}
}

private val peripheralManagerReady = MutableSharedFlow<Unit>()
private val peripheralManagerReadyCount = MutableStateFlow(0L)

override fun peripheralManagerIsReadyToUpdateSubscribers(peripheral: CBPeripheralManager) {
verboseLog { "peripheralManagerIsReadyToUpdateSubscribers" }
runBlocking {
peripheralManagerReady.emit(Unit)
}
peripheralManagerReadyCount.value++
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,7 @@ actual val platformModule: Module = module {
fallbackToResetRequest = true,
closeGattServerWhenBtDisabled = false,
delayBleConnectionsAfterAppStart = true,
desiredTxWindow = 6,
desiredRxWindow = 6,
) }
}