Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App don't discover services when reconnecting after power cycling bluetooth

When I am toggling bluetooth while connected to a CoreBluetooth peripheral I do a disconnection and deletion of all references to my peripheral in the centralManagerDidUpdateState callback.

Doing another scan will find and reconnect to the device and again issue a discoverServices, but this time around the callback didDiscoverServices never happens. By deleting all settings (General -> Reset -> Reset all settings) or do a reboot it works again. Disconnect/reconnect as normal does also work. How can I work around this or delete all cache and UUID's stored by iOS programatically?

like image 803
chwi Avatar asked Nov 12 '22 00:11

chwi


1 Answers

When you get the callback that the centralManager state has changed to CBCentralManagerStatePoweredOff, you need to loop through all your peripherals and call cancelConnection: on them. Then you'll be good to go.

[_yourCentralManager cancelPeripheralConnection:yourPeripheral];
like image 100
Tommy Devoy Avatar answered Nov 15 '22 06:11

Tommy Devoy