Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 6 - Bluetooth LE disconnect

Ok what the heck is up with iOS6 and how it handles Bluetooth LE disconnections? Before the device would disconnect immediately but now, for some strange reason, the device waits to disconnect for about 30-60 seconds. I need it to disconnect ASAFP!

I've been searing all over the internet trying to figure out how to initiate an immediate disconnection from the peripheral and I found this nifty email that explains a workaround is to unsubscribe from notifications on the service characteristics.

Now I think I'm doing that.. When I want to disconnect I call [connected_device setNotifyValue:NO forCharacteristic:connected_characteristic]

Then, in the didUpdateNotificationStateForCharacteristic function, I have...

if((int)characteristic.isNotifying == 0){
   [manager cancelPeripheralConnection:peripheral];
}

In the function didDisconnectPeripheral...

connected_peripheral = nil;
connected_characteristic = nil;
[connected_peripheral release];
[connected_characteristic release];

I've also taken a good hard look at Apple's CoreBluetooth Temperature Sensor example but it hasn't really helped much....

Any help on this would be amazing!! I just don't know what I'm missing.....

UPDATE: It looks like the app needs to be connected to the bluetooth device for at least a minute before it is allowed to disconnect. If the app is connected for over a minute it will disconnect immediately when the command is sent. Otherwise, it will wait until that one minute mark to actually disconnect.

UPDATE: When I try to disconnect before the one minute mark, I get the following output to the log when the device actually disconnects.

Oct 24 16:49:35 Christophers-iPhone awdd[8168] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Oct 24 16:49:35 Christophers-iPhone awdd[8168] <Error>: CoreLocation: CLClient is deprecated. Will be obsolete soon.
like image 265
ChrisB Avatar asked Oct 18 '12 15:10

ChrisB


People also ask

Why does iPhone Bluetooth keep disconnecting?

Your Bluetooth might keep disconnecting on your iPhone due to software incompatibility issues, software bugs, or a mix-up in the cellular settings. Check that you're within connection range and your Bluetooth settings are correct.

How do I turn on ble on my iPhone?

On your iOS device go into "Settings-> Bluetooth" and turn on your BLE device. You should see the device listed in your available devices.

How do I make my iPhone Bluetooth undiscoverable?

Do so by tapping the grey cog icon on one of your Home screens (or in a folder named "Utilities"). Scroll to the third group of options and tap Privacy. Select Bluetooth Sharing. Slide the switches next to any authorized apps left to the "Off" position.


1 Answers

According to Apple, this new feature is "by design". The way we resolved this issue was to send a command to the Peripheral and have it disconnect from its end. If you do this, then the disconnect is immediate. I do not know why Apple changed this behavior from iOS5 to iOS6 but they must have had their reasons. Of course this solution only works if you have access to the Peripheral firmware and can change it. If there is a different solution, then we have not found it.

like image 141
Anders Grunnet-Jepsen Avatar answered Oct 01 '22 09:10

Anders Grunnet-Jepsen