didUpdateValueFor

Hi!

I'm developing an app (in Swift 4.2) that communicates via Bluetooth with a peripheral. So far I wrote and read a characteristic to communicate with him without problems.

But now I'm in the following situation, from the didUpdateValueFor method, when the characteristic has a specific value, I execute this code:


DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5), execute: {

NotificationCenter.default.post(name: Notification.Name(rawValue: "test"), object: nil)

})


The function that captures the "test" notification starts a process 'process_X' that must continue writing and reading in the same characteristic several times and sequentially.

In this 'process_X', the characteristic is written without problem, but the didUpdateValueFor method does not skip again until the closure that started the post has been completed.


Is there any way to get the value of that characteristic within the 'process_X'?


Thanks!

Replies

I don't know if it's the best solution, but I've solved it with this

let serialQueue = DispatchQueue(label:"serialQueue");

serialQueue.async {

process_X()

}