在背景中测量多个信标并确定每个信标在后台的停留时间(Ranging multiple beacons in background and determine dwell time for each o

编程入门 行业动态 更新时间:2024-10-22 14:29:41
在背景中测量多个信标并确定每个信标在后台的停留时间(Ranging multiple beacons in background and determine dwell time for each of the beacon in background)

我在我的BLE项目中使用altbeacon库。 我想为信标启用后台扫描。 由于我不希望用户一直打开蓝牙,我正在使用用户的GPS位置来确定是否需要打开蓝牙以在后台扫描信标。 我正在使用Bootstrap通知程序触发didEnterRegion ,然后使用didEnterRegion来确定设备的Major,Minor和distance值。 如果用户居住在2-5米的距离30秒,我想触发一个事件。 我怎么能从后台做到这一点? 目前使用默认设置10s扫描和5分钟的贪睡帮助我监控我的UUID定义的区域,但是当测量主要,次要和距离时,扫描仅持续1秒,这也无法帮助我看到周围的所有信标因为我使用~2hz频率。 下次扫描仅在5分钟后进行。 我怀疑将5分钟时间减少到10秒,因为我不希望用户感觉应用程序正在消耗电池,如果他长时间打开蓝牙。

所以最后我的问题是:

在背景中进行测距时,如何增加扫描周期或扫描频率,以便能够看到该区域内的所有信标? 当信标退出该区域并且didExitRegion时,我可以获得信标的UUID,主要,次要和停留时间吗?

I am using altbeacon library in my BLE Project. I want to enable background scanning for beacons. Since I am not expecting users to have Bluetooth turned on all the time, I am using GPS location of the user to determine whether I need to turn Bluetooth on to scan for beacons in background. I am using Bootstrap notifier to trigger didEnterRegion and then using RangeNotifier to determine the Major, Minor and distance values of the device. I want to trigger an event if the user dwells at a distance of 2-5 mts for 30s. How can I do this from background? Currently using the default setting of 10s scanning and 5 mins of snooze helps me monitor the region defined by my UUID but when ranging for the major, minor and distance the scan lasts only for 1 second which also does not help me see all the beacons around as I am using ~2hz frequency. Next scan takes place only after 5 mins. I am skeptical to reduce the 5 mins time to 10s as I do not want user to feel the app is consuming battery if he leaves the Bluetooth on for too long.

So finally my questions are:

How can I increase the scan period or frequency of scanning when ranging in background so that I can see all the beacons around in the region? Can I get the UUID, major, minor and dwell time of the beacon when it exits the region and didExitRegion is called?

最满意答案

我会添加自定义逻辑来控制后台模式。 进入地理围栏后,保持前景模式30秒左右,然后进入后台模式。

如果您的受监控区域已定义主要和次要,您可以从区域出口的ID 2和id3中读取这些字段。 没有自动跟踪停留时间,但您可以在区域条目中设置应用程序中的时间戳,并从区域退出时应用程序记录的另一个时间戳中减去该时间戳。

I would add custom logic to control background mode. Stay in foreground mode for 30 seconds or so after entering the geofence, then go to background mode.

If your monitored region has major and minor defined, you can read these fields out of id 2 and id3 on region exit. There is no automatic tracking of dwell time, but you can set a timestamp in your app on region entry, and subtract it from another timestamp your app records on region exit.

更多推荐

本文发布于:2023-07-24 10:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1244996.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:信标   多个   测量   后台   时间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!