CBPeripheral automatically disconnects with "Unknown Error" on iPhone 7

Originator:bcherry
Number:rdar://28479978 Date Originated:9/27/2016
Status:open Resolved:
Product:iOS Product Version:10
Classification: Reproducible:
 
Area:
Bluetooth

Summary:
We have an app which uses a CBCentralManager to connect to bluetooth peripherals, which we manufacture.  
In `-centralManager:didDiscoverPeripheral:`, we store a strong reference to the CBPeripheral, set the delegate, and call `-connectPeripheral:options:`.  A few seconds later, we receive the callback `-didConnectPeripheral:` on the delegate. We then call `-discoverServices`, which eventually results in `didDiscoverServices:`  This works fine on iOS8, iOS9, iPhone 4S through iPhone 6S+.

It does not work on iPhone 7.  Specifically `didDiscoverServices` will never get called, and about 30s after `-didConnectPeripheral`  we receive `-didDisconnectPeripheral:error:` with an error "CBErrorDomain Code=0 "Unknown Error".

We have found a similar report in the developer forums, and have added our own report there as well: https://forums.developer.apple.com/message/182460

Steps to Reproduce:
In code:

On iPhone 7 (FAILS)
1) `CBCentralManager -scanForPeripheralsWithServices:nil options:nil`
2) `-centralManager:didDiscoverPeripheral:`  Retain the `peripheral`, Set the delegate, call `-connectPeripheral:options:`
3) Wait for `-didConnectPeripheral:` Observe that this gets called. Call `-discoverServices:`
4) Observe that `didDiscoverServices` is never called
5) Observe that `-didDisconnectPeripheral:error:` is called with an error "CBErrorDomain Code=0 "Unknown Error". 

On iPhone Other (SUCCESS)
1) `CBCentralManager -scanForPeripheralsWithServices:nil options:nil`
2) `-centralManager:didDiscoverPeripheral:`  Retain the `peripheral`, Set the delegate, call `-connectPeripheral:options:`
3) Wait for `-didConnectPeripheral:` Observe that this gets called. Call `-discoverServices:`
4) Observe that `didDiscoverServices` is called

Expected Results:
`didDiscoverServices`  will be called on the CBPeripheral delegate after connection, and the connection will remain in-tact.

Actual Results:
`didDiscoverServices` is never called on the CBPeripheral delegate. About 30s after initial connection (`didConnectPeripheral`), `didDisconnectPeripheral` is called with "CBErrorDomain Code=0 "Unknown Error"

Version:
iOS 10.0.1, iOS 10.0.2

Notes:
This issue has been reproduced on two iPhone 7 devices, running both iOS 10 10.0.1 and 10.0.2. We do not see this issue on iPhone 4S, 5, 5C, 5S, 6, 6S, or SE running iOS 9 or any version of iOS 10.

Our hardware device that runs in peripheral mode runs Android 5.1 Lollipop.

Configuration:
iPhone 7

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!