测量接近与树莓丕蓝牙 [英] Measuring proximity with bluetooth on raspberry Pi
问题描述
我一直在尝试使用这个脚本<一个href=\"https://$c$c.google.com/p/pybluez/source/browse/trunk/examples/advanced/inquiry-with-rssi.py?r=1\" rel=\"nofollow\">https://$c$c.google.com/p/pybluez/source/browse/trunk/examples/advanced/inquiry-with-rssi.py?r=1但似乎袜子= bluez.hci_open_dev(的dev_id)
返回一个非工作插座。每次袜子被传递给函数错误(9,坏文件描述符')
被抛出。
I've been trying to use this script https://code.google.com/p/pybluez/source/browse/trunk/examples/advanced/inquiry-with-rssi.py?r=1 but it seems that sock = bluez.hci_open_dev(dev_id)
returns a non-working socket. Every time sock is passed into a function error(9, 'Bad file descriptor')
is thrown.
本脚本是pretty老所以有一个像样的机会它不工作了。所以,我有两个问题。有谁知道如何使用pybluez库(或一个更现代的等价物)来衡量一个蓝牙设备的接近与树莓派?
This script is pretty old so there is a decent chance it doesn't work any more. So I have two questions. Does anyone know how to use the pybluez library (or a more modern equivalent) to measure proximity of a bluetooth device with a raspberry pi?
和我在做什么错这个脚本是导致我建立一个破碎的插座?
And what am I doing wrong with this script that is causing me to build a broken socket?
感谢。
推荐答案
试试这个:
运行 hcitool dev的
,让您的蓝牙设备的地址。
Run hcitool dev
to get the address of your bluetooth device.
在你的联系,变线120脚本:
In the script you linked to, change line 120 from:
dev_id = 0
到
dev_id = bluez.hci_get_route(ADDRESS_FOR_YOUR_BLUETOOTH_DEVICE)
要衡量接近,该脚本调用函数
To measure proximity, the script calls the function
device_inquiry_with_with_rssi(sock)
应打印的蓝牙装置的ID及其相应的RSSI值(见行95-102)的列表。通常情况下,设备必须在配对模式的调查结果中显示。该函数也返回的ID / RSSI来的名单为一个数组,这样你就可以从自己的code称它为和处理返回的结果。 RSSI值表示一个设备的信号强度,所以是接近的间接测量(参见<一href=\"http://stackoverflow.com/questions/13705647/finding-distance-from-rssi-value-of-bluetooth-low-energy-enable-device\">Finding从蓝牙低功耗的RSSI值距离使设备)。
这篇关于测量接近与树莓丕蓝牙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!