带有 BLE Dongle 的 RaspberryPi 可以检测 iBeacons 吗? [英] Can RaspberryPi with BLE Dongle detect iBeacons?

查看:13
本文介绍了带有 BLE Dongle 的 RaspberryPi 可以检测 iBeacons 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 Radius Networks 购买了一个开发工具包,其中包括一个 ioGear GBU521 BLE 4.0 加密狗 和一个 Raspberry Pi.我还买了他们的 RadBeacon iBeacons 之一.他们都像广告宣传的那样工作,但我对我得到的东西感到有些惊讶.

I bought a developer kit from Radius Networks that includes a ioGear GBU521 BLE 4.0 dongle and a Raspberry Pi. I also bought one of their RadBeacon iBeacons. They both work as advertised, but I was kind of surprised by what I got.

我曾假设 RaspPi 可以检测 iBeacons.相反,该套件被设置为创建一个iBeacon.我的用例是检测 forklift 何时进入特定房间,以便我可以向他们发送工作.我的想法是在叉车上放置一个 iBeacon,然后放置一个 RaspPi 来搜索 iBeacon.当检测到 iBeacon(叉车)时,您可以断定它就在附近.我会将 RaspPi 连接到 LAN 并让它通过 REST 或类似的 传达信息.我知道我可以放置一个合适的 Android 或 Apple 设备 并以这种方式完成它,但我不明白为什么这个加密狗无法检测到这些 iBeacons 并告诉我什么他们的 UUID's 是?我错过了什么?

I had assumed that the RaspPi could detect iBeacons. Instead, the kit is setup to create an iBeacon. My use case is to detect when a forklift enters a particular room so I can send work to them. My thought was to put an iBeacon on the forklift then put a RaspPi searching for iBeacons. And when an iBeacon (forklift) was detected, you could conclude that it is nearby. I would wire the RaspPi into the LAN and have it communicate the information via REST or similar. I know I could put a suitable Android or Apple device and accomplish it that way, but I don't see why this dongle can't detect these iBeacons and tell me what their UUID's are? What am I missing?

推荐答案

是的!您可以使用 Raspberry Pi 扫描 iBeacons.我们在下面编写了一个脚本来执行此操作,您也可以通过以下步骤自行完成:

Yes! You can use your Raspberry Pi to scan for iBeacons. We've put together a script below that does this, you can also do it yourself with these steps:

  1. 启动执行蓝牙 LE 扫描的后台进程:

  1. Start a background process that does a bluetooth LE scan:

sudo hcitool lescan --duplicates &

使用 --duplicates 设置,扫描将不会忽略来自同一个 iBeacon 的多个数据包.

With the --duplicates setting the scan will not ignore multiple packets from the same iBeacon.

启动一个 hcidump 并将原始输出通过管道传输到将过滤 iBeacon 数据包的脚本:

Start an hcidump and pipe the raw output to a script that will filter for iBeacon packets:

sudo hcidump --raw 

过滤是一个棘手的部分,hcidump 的原始输出没有很好地格式化,并且还显示了不是 iBeacon 传输的数据包.为了解决这个问题,我们制作了一个过滤脚本,它逐行读取输出并将原始数据包与其他输出(即 MAC 地址等)分开.我们在 Radius Networks 对 iBeacon 蓝牙配置文件进行了大量研究,我们用它来识别 iBeacon 数据包并过滤它们从来自其他设备的数据包中取出.

The filtering is the tricky part, the raw output from hcidump isn't formatted nicely and also shows packets that aren't iBeacon transmissions. To solve this, we made a filter script that reads in the output line by line and separates out the raw packets from the other output (i.e., MAC addresses, etc.). We've done a lot of research at Radius Networks on the iBeacon bluetooth profile, which we used to identify iBeacon packets and filter them out from packets from other devices.

我们已将所有这些整合到一个 ibeacon_scan 脚本中,该脚本可以执行所有操作,包括将原始标识符转换为人类可读的形式.您可以在此处下载.很快,我们会将其包含在 iBeacon 开发工具包 中以添加扫描能力.

We've put this all together into an ibeacon_scan script that does everything, including converting the raw identifiers into human-readable form. You can download it here. Soon, we'll include this in the iBeacon Development Kit to add scanning capability.

以下是脚本输出的示例:

Here's an example of the output from the script:

$ ./ibeacon_scan
UUID: 74278BDA-B644-4520-8F0C-720EAF059935 MAJOR: 0 MINOR: 73 POWER: -50
UUID: 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6 MAJOR: 1 MINOR: 6 POWER: -59
UUID: E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 MAJOR: 6 MINOR: 9 POWER: -55

我们还为裸输出添加了一个 -b 选项,该选项很容易解析为其他脚本,这是一个示例:

We've also included a -b option for bare output that is easy to parse into other scripts, here's an example:

$ ./ibeacon_scan -b
2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6 1 6 -59
E2C56DB5-DFFB-48D2-B060-D0F5A71096E0 6 9 -55
74278BDA-B644-4520-8F0C-720EAF059935 0 73 -50

您可以使用此选项并将脚本的输出通过管道传输到您的脚本,以在检测到具有特定标识符的 iBeacon 时触发操作.

You can use this option and pipe the script's output to your script to trigger actions when iBeacons with certain identifiers are detected.

我们重新设计了这个脚本,使其反应更灵敏、更健壮,并将其整合到最新版本的 开发工具包.可在此处下载更新.

We've reworked this script to make it more responsive and robust and incorporated it into the latest version of the development kit. The update is available to download here.

正如 @sai-ramachandran 所指出的,您可以增加此脚本除 POWER 外还捕获每个 iBeacon 数据包的 RSSI.为此,请将以下几行添加到脚本中:

As pointed out by @sai-ramachandran, you can augment this script to capture the RSSI of each iBeacon packet in addition to POWER. To do this, add the following lines to the script:

 RSSI=`echo $packet | sed 's/^.{132}(.{2}).*$/1/'`
 RSSI=`echo "ibase=16; $RSSI" | bc`
 RSSI=$[RSSI - 256]

并确保将 RSSI 添加到输出中:

and be sure to add RSSI to the output:

 echo "UUID: $UUID MAJOR: $MAJOR MINOR: $MINOR POWER: $POWER RSSI: $RSSI"

这篇关于带有 BLE Dongle 的 RaspberryPi 可以检测 iBeacons 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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