CoreBluetooth - writeValue. How to retry?

How to use the writeValue (.withResponse) function if a message fails or timeout to automatically retry?

Please come with some concepts.