0

I start working with CoreBluetooth for a week, but I dont know how to reconnect to the peripheral after losing connection.

For example, my CBCentralManager connect to peripheral A, the real manager on iPhone said 'Connected', then I go away for awhile, the CBCentralManager lost connection to the peripheral A, the real manager on iPhone said 'Not Connected'. Then I go back, the CBCentralManager doesn't reconnect to peripheral A, but the real manager on iPhone said 'Connected'.

How can I make my CBCentralManager reconnect automatically?

Sorry for my bad English.

Hieu Dinh
  • 692
  • 5
  • 18
  • 1
    Once you get a call to `didDisconnectPeripheral`, immediately issue a `connect` for that peripheral. Once it it comes back into range you will reconnect – Paulw11 Jul 15 '16 at 05:44
  • Thank you Paul! Can it connect if the loss of connection is too long? – Hieu Dinh Jul 15 '16 at 05:47
  • If your app is enabled for bluetooth background mode then I believe the pending connection will last indefinitely, however you will need to implement Bluetooth state restoration as per the Core Bluetooth programming guide in the case where your app is terminated or the device is restarted – Paulw11 Jul 15 '16 at 05:48
  • Ok I understood, thank you very much! – Hieu Dinh Jul 15 '16 at 05:51

0 Answers0