蓝牙 LE 信号强度 Linux [英] Bluetooth LE Signal Strength Linux

查看:30
本文介绍了蓝牙 LE 信号强度 Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,有什么办法可以在linux下获取附近蓝牙设备的信号强度吗?或者任何用于 nodejs、php 或 mono 的好库(我确实知道一些 c++ 或 python,但更愿意说远离它们)如果工具不存在但很容易编写.

Hello is there any way to get the signal strength of near by bluetooth le devises in linux? Or any good libraries for nodejs, php or mono (I do know some c++ or python but would prefer to say away from them) if a tool does not exisst but would be fairly easy to write.

推荐答案

在 Linux 上,执行此操作的方法是使用 hcitool 命令.但是,您必须连接才能获取设备的 RSSI.如果您想从命令行实现此目的,请尝试:

On Linux, the way to do this is with the hcitool command. However, you have to be connected to get the rssi of a device. If you want to achieve this from the command line, try:

#hcitool rssi AA:BB:CC:DD:EE:FF

如果您想查看实现此目的的实际 C 代码,请查看 bluez tools/hcitool.c 文件,在 cmd_rssi 函数下.

If you want to see the actual C code to achieve this, take a look at the bluez tools/hcitool.c file, under the cmd_rssi function.

static void cmd_rssi(int dev_id, int argc, char **argv)
{
    ...
}


对于低功耗蓝牙,我只知道一种方法,那就是使用#btmon 命令.在后台运行 btmon,然后扫描低功耗蓝牙设备:


For Bluetooth Low Energy, I only know one way to do this, and that is using the #btmon command. Run btmon in the background then scan for Bluetooth Low Energy devices:

#./btmon &
# hcitool lescan

显示器上显示的结果应该是这样的:

The results displayed on the monitor should be similar to this:

> HCI Event: LE Meta Event (0x3e) plen 12                                                                                  
      LE Advertising Report (0x02)
        Num reports: 1
        Event type: Scan response - SCAN_RSP (0x04)
        Address type: Public (0x00)
        Address: AA:BB:CC:DD:EE:FF (<Vendor Name>)
        Data length: 0
        ***RSSI: -34 dBm (0xde)***
AA:BB:CC:DD:EE:FF <Device Name>

请注意,使用 btmon 时,您无需连接即可获取 BLE 设备的 rssi.

Note that when using btmon you do not have to connect to get the rssi of a BLE device.

这篇关于蓝牙 LE 信号强度 Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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