带有BLE加密狗的RaspberryPi是否可以检测iBeacons? [英] Can RaspberryPi with BLE Dongle detect iBeacons?

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

问题描述

我从Radius Networks购买了一个开发套件,其中包括ioGear GBU521 BLE 4.0 dongleRaspberry 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 or similar传达信息.我知道我可以放一个合适的Android or Apple device并以这种方式完成它,但是我不明白为什么该加密狗无法检测到这些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.

这是脚本输出的示例:

$ ./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.

EDIT2 :如 @ 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加密狗的RaspberryPi是否可以检测iBeacons?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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