iOS 6 - 蓝牙LE断开连接 [英] iOS 6 - Bluetooth LE disconnect

查看:200
本文介绍了iOS 6 - 蓝牙LE断开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那么iOS6及其如何处理蓝牙LE断开是怎么回事?在设备立即断开之前,但由于某些奇怪的原因,设备等待断开约30-60秒。我需要它断开ASAFP!

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.

现在我想我正在这样做...当我想断开连接时我打电话给 [connected_device setNotifyValue:NO forCharacteristic:connected_characteristic]

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

然后,在didUpdateNotificationStateForCharacteristic函数中,我有......

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

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

在函数didDisconnectPeripheral ...

In the function didDisconnectPeripheral...

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

我也仔细看了一眼Apple的 CoreBluetooth温度传感器示例但它并没有多少帮助....

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.


推荐答案

根据Apple的说法,这个新功能是按设计。
我们解决这个问题的方法是向外围设备发送一个命令并将其从端部断开。如果这样做,则立即断开连接。我不知道为什么Apple将这种行为从iOS5改为iOS6,但他们必须有他们的理由。当然,只有您可以访问外围设备固件并且可以更改它时,此解决方案才有效。如果有不同的解决方案,那么我们还没有找到它。

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.

这篇关于iOS 6 - 蓝牙LE断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆