BLE在后台 [英] BLE in the background

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

问题描述

我正在开发一个使用iBeacon的项目,该项目要求应用程序在后台持续运行。请不要忘记这个的实用性。 iBeacon API不允许应用程序在后台持续排列或接收除了进入/退出事件之外的任何其他通信(在您设置needsDisplay标志的情况下接受,但这并不像我需要它那样被动)。一旦进入特定区域,当应用程序完全背景时,您似乎无法检测到哪个信标最接近。

I'm working on a project with iBeacon that requires the app run constantly in the background. Nevermind the practicality of this, please. The iBeacon API doesn't allow apps to range in the background constantly or receive any other communication other than enter/exit events (accept in the case where you set the needsDisplay flag, but this isn't as passive as I need it to be). Once in a particular region, it seems you can't detect which beacon you're closest to while the app is completely backgrounded.

为了破解这个工作,我设置了几个iOS设备作为CoreBluetooth外设,插入并始终在应用程序可以不断发现。由于用于外围设备的BLE配置文件是可连接的,因此应用程序可以在后台无限延续,iBeacon测距可以全天使用。为了启动,我看到电池寿命减少非常少。

In order to hack this into working, I set up a couple of iOS devices as CoreBluetooth peripherals, plugged in and always on that the app can constantly "discover." Because the BLE profile used for the peripherals are "connectable," the app can stay on infinitely in the background and iBeacon ranging is possible all throughout the day. To boot, I've seen very minimal battery life reduction.

现在的问题是,每隔一天左右,应用程序退出并且没有被输入唤醒/退出事件,在范围内也没有被其他BLE设备唤醒。

The problem now, is that every other day or so, the app quits and is not awakened by the enter/exit events, nor is it awakened by the other BLE devices when in range.

我明白,有了像这样的hacky解决方案,肯定会有无数的问题,但对于我的生活,我无法缩小可能导致这种情况的原因。想法?

I understand that with a hacky solution like this, there are bound to be a myriad of problems, but for the life of me I can't narrow down what might be causing this. Thoughts?

推荐答案

每隔一段时间,CoreLocation就会挂起并且不会报告任何新的进入/退出事件。重新启动手机通常可以解决这个问题。轶事报道的增加表明,自iOS 7.1发布以来,这可能更为常见(我在StackOverflow过去几周看到过这样的其他两个问题,我们在Radius Networks的这个问题上得到了很多支持请求),但没有确凿证据证明7.1的变化会影响这一点。

Every once in awhile, CoreLocation will get hung up and not report any new entry/exit events. Rebooting the phone generally fixes this. An increase in anecdotal reports suggest this may be more common since the release of iOS 7.1 (I have seen two other questions like this in the past few weeks on StackOverflow, and we have gotten lots of support requests on this issue at Radius Networks), but there is no hard evidence to prove a change in 7.1 affects this.

编辑:其他地方收集的其他数据显示,当这些挂起发生时,蓝牙继续为了正常工作,挂起的设备仍然可以作为iBeacon进行传输。这表明CoreLocation中的一个错误会导致定期蓝牙LE扫描以查找iBeacons停止。到目前为止,唯一已知的修复方法是重新启动受影响的手机。

这个问题非常罕见,以至于我无法对其进行定性以了解根原因。这是蓝牙问题吗? CoreLocation问题?你的设置可能是找到问题的理想方法。

The problem is rare enough that I have never been able to characterize it to know the root cause. Is it a Bluetooth problem? A CoreLocation problem? Your setup might be producing an ideal means of finding the issue.

一旦你重现这个问题,我就会这样做:

As soon as you reproduce this issue, here is what I would do:


  1. 启动另一个iBeacon扫描程序,如找到iBeacon ,并为该区域内的任何iBeacons设置范围(确保配置了Proximity UUID。)你看到了吗?如果是这样,蓝牙和CoreLocation可以正常工作,因此问题可能出在你的应用上。

  1. Start another iBeacon scanning program like Locate for iBeacon, and have it range for any iBeacons in the area (be sure your Proximity UUIDs are configured.) Do you see them? If so, Bluetooth and CoreLocation work, so the issue may be with your app.

如果你在(1)中没有看到任何iBeacons,请转到设置>蓝牙,并扫描其他附近的设备(甚至是经典的蓝牙设备)。使您的Macbook或蓝牙耳机可见,以便于测试。如果你没有看到任何设备,那么蓝牙就会被挂断。尝试将其关闭并重新打开。

If you do not see any iBeacons in (1), go to Settings > Bluetooth, and do a scan for other nearby devices (even classic Bluetooth devices). Make your Macbook or bluetooth headset visible to make this easy to test. If you do not see any devices then bluetooth is hung up. Try turning it off and back on.

如果您在(2)中看到蓝牙设备但在(1)中没有iBeacons,那么可能存在操作系统问题处理CoreLocation。

If you see Bluetooth devices in (2) but no iBeacons in (1) then there may be an OS problem with handling CoreLocation.

我有兴趣了解你的看法。上面的过程不会解决您的问题,但它可能会提供更多证据证明可以进行修复的事情。

I'd be interested in knowing what you see. The procedure above won't fix your problem, but it might give some more evidence of what is going on that will make a fix possible.

以下是用户的其他问题报告类似问题:

Here are other questions where users report a similar problem:

iBeacon的iOS应用必须重启设备

ibeacon在iPhone 4S中没有出现

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

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