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