iBeacon可靠/不可靠 [英] iBeacon Reliable/Unreliable

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

问题描述

我正在开发家庭自动化应用程序。我正在使用estimotes iBeacons,我想要做的就是让我的家庭自动化控制能够知道我在家里的距离。每个iBeacon在我的家庭控制器上都有一个虚拟开关,当我接触到iBeacon时,我的设备在前台或后台将更新我的控制器以打开我的开关,当我靠近灯塔时关闭它然后当我有想远离我的灯塔。所有这一切都很完美,我很喜欢它,但是我的一些条件依赖于我在一段时间内接近,我注意到的是几分钟后甚至在接近半小时后一个灯塔,iPhone 5s基本上断开它的连接,然后将其重新启动,导致它执行退出(关闭我的虚拟交换机),然后立即执行输入(转回虚拟交换机)。你可以想象这对于妻子和我自己来说非常烦人,因为退出/进入,卧室的灯开始闪烁。我已经阅读过有关此问题的人,并尝试了我在互联网上看到的所有内容都无济于事。

I am working on my home automation app. I am using estimotes iBeacons and what I want to do is give my Home Automation Control the ability to know my proximity in my home. Each iBeacon is given a virtual switch on my Home Controller and when I come in contact with a iBeacon my device either in foreground or background will update my control to turn on my switch for when I am near a beacon and turn it off when I have wondered away from my beacon. All of this works perfectly and I am loving it, however some of my conditions rely on me to be in a proximity for a period of time, and what I am noticing is after a couple of minutes or even after a half hour of being near a beacon, the iPhone 5s basically drops its connection and then fires it back up, causing it to perform an exit (turn off my virtual switch) and then immediately perform an enter (turn back on the virtual switch). As you can imagine this is very annoying to the wife and myself in the middle of the night when the bedroom lights start to flicker on and off because of the exit/enter. I have read about people having this problem and tried everything I have seen on the internet to no avail.

我注意到的是,无论何时越过监视器穿越iBeacon,调用didDetermineState和相应的Enter / Exit回调函数。我该怎么办才能让它停止发生?如果需要,我可以提供代码示例,但这更像是一个普遍的问题。

What I noticed is that whenever a monitor crossing has been crossed for a iBeacon, both the didDetermineState and the corresponding Enter/Exit call back functions are called. What can I do to get this to stop occurring? I can provide code examples if needed but this is more of a general question.

推荐答案

这是iBeacons的一个常见问题(和像我们这样的极客的妻子),简单的解决方案是软件过滤器。您必须忽略仅持续几秒钟的区域退出事件,直到您确认没有后续条目事件。

This is a common problem with iBeacons (and wives of geeks like us), and the simple solution is a software filter. You must ignore region exit events that last only a few seconds until you verify that there is no subsequent entry event.

您可以通过创建变量(例如justExitedRegion)来执行此操作跟踪这些事件。当您获得退出区域通知时,请设置justExitedRegion = YES并启动五秒计时器。当计时器熄灭时,如果justExitedRegion == YES,则正常执行退出逻辑并设置justExitedRegion = NO。否则,跳过处理退出逻辑。

You can do this by creating a variable (e.g justExitedRegion) that tracks these events. When you get an exit region notification, set justExitedRegion=YES and start a five second timer. When the timer goes off, if justExitedRegion==YES, perform your exit logic normally and set justExitedRegion=NO. Otherwise skip processing the exit logic.

同时,如果您收到条目通知并且justExitedRegion == YES,请将justExitedRegion设置为NO并跳过您的条目处理。

Meanwhile, if you get an entry notification and justExitedRegion==YES, set justExitedRegion to NO and skip your entry processing.

这篇关于iBeacon可靠/不可靠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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