Linux 蓝牙 l2ping 与信号强度(无需连接?)
对于这里的任何 Linux BlueZ/BT 专家:
我正在寻找一种方法来“ping”已知的 BT 设备(已知的 BDADDR),如果它们在范围内,我想知道大约的信号强度。
我知道我可以首先运行 l2ping,然后建立与设备的连接,最后检查 RSSI 或链接质量(如果连接无需先配对即可工作)。
然而,我正在寻找一种无需先连接到设备即可获取信号强度的方法。完美的是来自 l2ping 回复数据包的信号强度测量,但我不知道该信息是否可用并沿着堆栈传递。
For any Linux BlueZ/BT experts here:
I'm looking for a way to "ping" known BT devices (known BDADDR) and if they are in range I'd like to know the approximate signal strength.
I know that I could first run l2ping, then establish a connection to the device and finally check the rssi or link quality if the connection worked without pairing first.
However what I'm looking for is a way of getting the signal strength without connecting to the device first. Perfect would be a signal strength measurement from the l2ping reply packet, but I don't know if that info is available at all and passed along the stack.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在查询扫描期间获取RSSI,而无需连接设备。这是使用 pybluez 的示例。您还可以在 Linux 上使用 Bluez 直接从 C 语言执行相同的操作。
inquiry-with-rssi.py
You can obtain RSSI during inquiry scan, without connecting to devices. Here's an example using pybluez. You could also do the same thing directly from C using Bluez on linux.
inquiry-with-rssi.py
我在我的 iPhone 7 和 Raspberry Pi 上使用此代码,效果非常好。
I'm using this code with my iPhone 7 and Raspberry Pi and it works great.
非常老的问题,但有人可能仍然感兴趣。
之前的答案讨论了查询扫描期间的RSSI。这是正确的,但并不总是可行,即无法发现的设备。
对于此类设备,您可以建立连接并最终请求连接 RSSI。可以使用 BlueZ 命令
hcitool rssi
获取连接 RSSI。将
l2ping
和hcitool rssi
混合即可实现这一目的。因此,我创建了这个存储库:[https://github.com/edoardesd/myBluez< a href="https://github.com/edoardesd/myBluez" rel="nofollow noreferrer">]
输出:
来自 XX:XX:XX:XX:XX:XX 的 44 字节 id 8 时间 8.23ms,RSSI -9
Very old question, but someone might be still interested in.
The previous answers talk about the RSSI during an inquiry scan. It's correct but not always doable, i.e. undiscoverable devices.
For this class of devices you can establish a connection and eventually ask for the connection RSSI. Connection RSSI can be obtained using BlueZ command
hcitool rssi <MAC:ADDRESS>
.Blend
l2ping
andhcitool rssi
do the trick.For this reason, I created this repository: [https://github.com/edoardesd/myBluez]
Output:
44 bytes from XX:XX:XX:XX:XX:XX id 8 time 8.23ms with RSSI -9