Correct way to implement CoreBluetooth connectPeripheral timeout?

Given that bluetooth seems to be well versed in connections when one end disconnects, I thought the method would CBCentralManager connectPeripheral:options:automatically disconnect if it couldn’t connect after a certain time (because maybe I disabled / w 70> the target peripheral in the interval between when I scanned it and when the user chose it to connect).

I looked at the argument optionsfor a possible timeout parameter, but there was no such luck.

Is the correct technique a NSTimertrigger cancelPeripheralConnection:that eventually triggers if the timer expires, and the invalidatetimer in centralManager:didConnectPeripheral:and out friends?

+4
source share
1 answer

Please check the Apple foro CBCentralManager documentation and its connectPeripheral: options: method. First, attempts to connect to a peripheral device do not fail, and secondly, you can set a delegate to receive connection / disconnection notifications.

https://developer.apple.com/library/mac/documentation/CoreBluetooth/Reference/CBCentralManager_Class/index.html#//apple_ref/occ/instm/CBCentralManager/connectPeripheral:options :

-2
source

Source: https://habr.com/ru/post/1606597/


All Articles