BLE Peripheral disconnects every 30 seconds

I am having an issue with CoreBluetooth on iOS. My app is serving as a central that connects to one physical bluetooth peripheral. I have no issues discovering, connecting, and reading data from the peripheral. The particular information I need is provided through a notification. I can begin recieving the info after setting the notify value:


devicePeripheral.setNotifyValue(true, forCharacteristic: dataCharacteristic)


I am also keeping a strong reference to my devicePeripheral after discovery and to the dataCharacteristic after the peripheral is connected and its characteristics have been discovered.


After setting the notify value, I begin receiving the data at a frequent interval. For the app's purpose, I need to collect data from this notification for an extended period of time.


The issue I am facing is that the peripheral is automatically disconnected exactly every 30 seconds, even while my notify value is set to true- so in the middle of reading data, I am suddenly forcibly disconnected exactly every 30 seconds. I have added code that upon disconnection, I rescan and reconnect, reset the notify value and carry on capturing data. The problem is that I need to capture data continuously without interruption, and that capture is being interrupted consistently every 30 seconds. This causes a gap of lost data.

After exactly 30 seconds, "didDisconnectPeripheral" fires with the following error:


Error Domain=CBErrorDomain Code=0 "Unknown error." UserInfo=0x174b6b90 {NSLocalizedDescription=Unknown error.}



Can anyone offer any suggestions as to why this might be ocurring, and how I might resolve it?

I have also developed an Android client that interacts with this same peripheral, and it does not suffer from the same issue- there is no 30 second disconnect on that platform, and I have no issues collecting data for an extended period of time. I have also tested connecting to my peripheral from OS X. I have not found the 30 second disconnect issue on OS X either- it appears that issue is isolated to iOS.


I have tested with a iPhone 5 running iOS 8.4.1, and an iPhone 6S+ running iOS 9.2


Thanks

Replies

My first suggestion would be to look at the connection parameters of the peripheral. If they are not complying with the rules below, you may be seeing random disconnections like you describe.


The peripheral is responsible for the connection parameters used for the Low Energy connection. The connection parameter request may be rejected if it does not comply with all of these rules:

The full set of formulas:

1. Interval Max * (***** Latency + 1) ≤ 2 seconds (keep it under 1.2 for broadest compatibility)

2. Interval Min ≥ 20 ms

3. Interval Min + 20 ms ≤ Interval Max

4. ***** Latency ≤ 4

5. connSupervisionTimeout ≤ 6 seconds

6. Interval Max * (***** Latency + 1) * 3 < connSupervisionTimeout


You can read more about these requirements in the Bluetooth Accessory Design Guidelines for Apple Products (Section 3.6): https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf

Thanks for this information. I will pass it along to the party responsible for the peripheral and see if we can identify the issue.

After forwarding the Connection Parameter information to our hardware manufacturer, they have confirmed the hardware meets the requirements listed in Apple's Bluetooth Guidelines document. Unfortunately that leaves us without a resolution for this issue. Do you have any further suggestions for identifying why we cannot maintain a connection that will allow us to recieve notifications for intervals longer than 30 seconds?


Thanks

I'm curious whether this was ever resolved. I've been hitting a similar issue with my device. The strange thing is that the disconnects don't happen when using the LightBlue app so I'm wondering if there is combination of hardware/firmate and iOS issues.

I have the sampe problem but after 90 seconds. Did you find a solution ?

In my case reason was in a mismatch between characteristic properties. I wrote data to a characteristic with "waiting for response" option, but characteristic was in 'without response' state.

The symptom: write callback in delegate does not work when BLE peripheral did not write a response.

I have the same problem device get disconnect automatically after 5-10 seconds with error : Error Domain=CBErrorDomain Code=0 "Unknown error." UserInfo=0x174b6b90 {NSLocalizedDescription=Unknown error.}

Did you find a solution ?