更新时间:2022-01-11 22:22:12
在 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.