calling writeValue:forCharacteristic:type: at fast speed break the Core Bluetooth

We use iPhone to interact with a BLE device through Core Bluetooth framework. Everything works fine, except the Core Bluetooth will crash when we power off the device while iOS is still writing characteristic by calling

writeValue:forCharacteristic:type:
. The write type is
CBCharacteristicWriteWithoutResponse
. In such circumstances we must reboot iPhone in order to connect to ANY BLE devices again, since turning off and on the bluetooth on iPhone is of no use.

I have made some tests on this problem and get some information that when we power off the BLE device, iOS needs some time to get the disconnection event, so

writeValue:forCharacteristic:type:
is still being called at this period, this may cause the CoreBluetooth framework crash! I don't know why the BLE stack of iOS can't handle this.

Any ideas on how to avoid such things when the device is out of power suddenly while iOS is still writing characteristic to it OR can

writeValue:forCharacteristic:type:
be called at some what safe manner?

Thanks!

Replies

I did the same action with you ,but did not encounter the case you said..."iOS needs some time to get the disconnection event", yes, that's standard action. BLE master device(iPhone) need wait TIMEOUT to decide the connection disconnect, if no other BLE protocol command tell it that, and this will not cause the exception you described I think...