且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

蓝牙LE信号强度Linux

更新时间:2022-01-11 22:22:36

在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 工具/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.

我希望这会有所帮助.