使ios7 BLE外设在后台工作 [英] Making ios7 BLE peripheral to work in background

查看:189
本文介绍了使ios7 BLE外设在后台工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了有关它的所有相关信息,但仍然无法使我的iOS7设备像后台广告客户一样工作。它在前景中工作正常,但在后台我甚至可以发现它。我在plist文件中添加了 App使用CoreBluetooth 共享数据。我在后台进行了阅读后将自定义UUID放入溢出数据中。我也尝试了这个(但没有运气)。

I have read every related information about it, but still can't make my iOS7 device work like peripheral advertiser in background. It works fine in foreground, but in background I can even discover it. I added App shares data using CoreBluetooth in plist file. I read that after going in background it puts my custom UUID in overflow data. I tried this one too(but no luck).

NSDictionary *advertisingData = @{
 CBAdvertisementDataServiceUUIDsKey : @[CBUUID UUIDWithString:TRANSFER_SERVICE_UUID],
 CBAdvertisementDataOverflowServiceUUIDsKey : @[CBUUID UUIDWithString:TRANSFER_SERVICE_UUID]
};  
[manager startAdvertising:advertisingData];

在另一侧的中央(MAC OS应用程序),我只扫描我的: TRANSFER_SERVICE_UUID 服务。有没有我错过的东西,我应该在中央一侧另外实施?

In the central from other side (MAC OS app), I am scanning only for my: TRANSFER_SERVICE_UUID service. Is there something that I have missed that I should implement additionally in the central side?

推荐答案

注意<$ c中的这一行$ c> startAdvertising:方法的文档:


当应用程序在后台时,本地名称不会使用,所有服务UUID将被放置在溢出区域。但是,未指定蓝牙 - 外设背景模式的应用程序将无法在后台播放任何内容。

While an application is in the background, the local name will not be used and all service UUIDs will be placed in the "overflow" area. However, applications that have not specified the "bluetooth-peripheral" background mode will not be able to advertise anything while in the background.

也就是说,后台外围设备会从广告中删除所有内容,只能通过 iOS应用程序检测到它的存在。 iOS应用程序可以到达溢出区域,但MacOS应用程序不能。您需要关闭MacOS端的服务过滤才能检测到外围设备并连接到它以发现它是否有搜索到的服务。

That is, the backgrounded peripheral removes every thing from the advertisement and only its presence can be detected by non iOS applications. iOS apps are able to reach the overflow area but MacOS apps can't. You need to turn off the service filtering on the MacOS side to be able to detect the peripheral and connect to it to discover if it has the searched service.

仅供参考我们,有对于这种情况没有解决方法,已经在Apple bluetooth-dev邮件列表和许多SO问题上多次讨论过。

FYI, there is no workaround for this scenario, it has been discussed several times on the Apple bluetooth-dev mailing list and in many SO questions.

另请注意 CBAdvertisementDataOverflowServiceUUIDsKey 不是 startAdvertising:的有效输入键。如果在溢出区域中发现了某些内容,则iOS会在 didDiscoverPeripheral 回调中返回 CBAdvertisementDataOverflowServiceUUIDsKey 。仅使用 CBAdvertisementDataServiceUUIDsKey 来定义广告服务列表。

Also note that CBAdvertisementDataOverflowServiceUUIDsKey is not a valid input key for startAdvertising:. CBAdvertisementDataOverflowServiceUUIDsKey is returned by iOS in the didDiscoverPeripheral callback if it found something in the overflow area. Use only CBAdvertisementDataServiceUUIDsKey to define the list of advertised services.

这篇关于使ios7 BLE外设在后台工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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