Reputation: 3854
I am using Bluetooth LE (4.0) and the CoreBluetooth Framework to create an iOS (7.1) app that makes the device act as a "Peripheral". I am able to connect to the app using another iOS device that acts as the "Central", in order to explore its services and characteristics.
However, once the connection is made, the connection will randomly get dropped anywhere from 30 seconds after making the connection to 1 minute and I have no idea why.
When I check the delegate method:
-(void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)aPeripheral error:(NSError *)error
The error message is "the specified device has disconnected from us".
Does anyone know why this is happening? Like I said, I can successfully connect and discover everything but the connection randomly gets dropped.
Thanks!
Upvotes: 3
Views: 865
Reputation: 2005
As far as I know these disconnects are intentional and occur when a connection persists for an unnecessary amount of time (the characteristic value is not updated frequently enough).
A simple work-around is to reconnect whenever centralManager:didDisconnectPeripheral:error: is called and you receive this error message. Another suggestion is to schedule a timer that would repeatedly send an update to the subscribed centrals even if the characteristic's value has not changed.
Upvotes: 1