Search code examples
objective-cmacosbluetooth-lowenergycore-bluetoothxcode9.2

Peripheral state never changes after CBPeripheralStateDisconnecting state on mac osx 10.13 CoreBluetooth framework


I have updated macOS to High sierra and Xcode to 9.2. I am working on BLE device connection / disconnection and reading data. It was was working fine in Xcode 8.2, Now there are changes in CoreBluetooth framework.

A new state CBPeripheralStateDisconnecting is added in peripheral state. Now, I need functionality to cancel connection with BLE device from CBPeripheralStateConnecting state, too.

I have used cancelPeripheralConnection: method to cancel connection. After this method device state changes to CBPeripheralStateDisconnecting and never gets into state CBPeripheralStateDisconnected. I tried to connect again but still state not changing.

In short BLE device state never changes after CBPeripheralStateDisconnecting state. Please can anyone suggest a way?

Thanks in advance.


Solution

  • I have solved issue by treating CBPeripheralStateDisconnecting & CBPeripheralStateDisconnected state as same. Implemented same flow on CBPeripheralStateDisconnecting as CBPeripheralStateDisconnected i.e. send connection request again to device & it worked.