iOS 11 CoreBluetooth CBCentralManager state

https://bugreport.apple.com/web/?problemID=40125114


1.Shutting down Bluetooth in the control center

2.Shutting down Bluetooth in the system settings

3.Open Bluetooth in system settings


now, Bluetooth is open .( system settings && control center )


but in the code , Bluetooth doesn't work.


any operation of Bluetooth , log is:

[CoreBluetooth] API MISUSE: <CBCentralManager: 0x1014f8150> can only accept this command while in the powered on state



As long as last operation is turn off Bluetooth at the control center, no matter how to operate the Bluetooh switch in system settings, Bluetooth will not work.

Replies

- (void)centralManagerDidUpdateState:(CBCentralManager *)central{}


central.state aways is CBCentralManagerStatePoweredOff



Only when the Bluetooth switch is operated again can the status be updated and Bluetooth can be used.

I think the reason is that turn off Bluetooth at the control center,

then turn off Bluetooth and turn on Bluetooth at system settings.

At this point, the Bluetooth status in the control center and system settings is turned on,

(the Bluetooth button state of the control center is updated by system settings. Maybe it's a UI bug)

but actually it was closed once in the control center,

so in "centralManagerDidUpdateState", state is poweroff, Bluetooth doesn't work.