Tim*_*lum 15 linux bluetooth rssi bluetooth-lowenergy bluez
您好有什么办法可以通过linux中的bluetooth le设备获得近乎信号强度?或者nodejs,php或mono的任何好的库(我确实知道一些c ++或python但更愿意说它们),如果一个工具不存在但是很容易写
谢谢
You*_*eed 31
在Linux上,执行此操作的方法是使用hcitool命令.但是,必须连接才能获取设备的rssi.如果要从命令行实现此目的,请尝试:
#hcitool rssi AA:BB:CC:DD:EE:FF
Run Code Online (Sandbox Code Playgroud)
如果要查看实际的C代码,请查看cmd_rssi函数下的bluez tools/hcitool.c文件.
static void cmd_rssi(int dev_id, int argc, char **argv)
{
...
}
Run Code Online (Sandbox Code Playgroud)
对于低功耗蓝牙,我只知道一种方法,那就是使用#btmon命令.在后台运行btmon,然后扫描蓝牙低功耗设备:
#./btmon &
# hcitool lescan
Run Code Online (Sandbox Code Playgroud)
显示器上显示的结果应类似于:
> 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>
Run Code Online (Sandbox Code Playgroud)
请注意,使用btmon时,您无需连接即可获取BLE设备的rssi.
我希望这有帮助.
btmgmt
$ sudo btmgmt find\n\nDiscovery started\nhci0 type 7 discovering on\nhci0 dev_found: 50:8C:FD:99:0A:EC type LE Random rssi -80 flags 0x0000 \nAD flags 0x06 \neir_len 23\n\xe2\x80\xa6\n
Run Code Online (Sandbox Code Playgroud)\n相对信号强度指示器为rssi -80
,但列表更长,包含有关此设备和其他设备的更多信息。
要监视您的蓝牙邻居,仅显示具有最强 RSSI 的唯一 MAC 地址,请运行以下命令:
\n$ sudo btmgmt find |grep rssi |sort -n |uniq -w 33\n\nhci0 dev_found: 40:43:42:B3:71:11 type LE Random rssi -53 flags 0x0000 \nhci0 dev_found: 44:DA:5F:EA:C6:CF type LE Random rssi -78 flags 0x0000 \nhci0 dev_found: 7F:7D:08:6B:E0:37 type LE Random rssi -74 flags 0x0000 \nhci0 dev_found: A4:58:0F:21:A1:8C type BR/EDR rssi -79 flags 0x0000\n
Run Code Online (Sandbox Code Playgroud)\n
小智 5
您可以使用以下组合:
sudo hcitool lescan --duplicates & ;
sudo hcidump --raw
Run Code Online (Sandbox Code Playgroud)
这将为您提供所有蓝牙数据包的原始转储,其中包含您必须感兴趣的所有相关信息,例如:UUID、Major、Minor、RSSI、TxPower。您必须运行某种脚本来解析和过滤 LE 数据包,并将它们转换为可读形式。
使用 Bash 和 S 编辑器编写的脚本之一由 jjnebaker 提供,这里讨论的问题和解决方案在这里
另一种选择是使用PyBluez使用示例代码在这里 ,但你可能会发现有用根据由Switchdoc实验室提供给您的需求,以及解决方案。这里
归档时间: |
|
查看次数: |
28960 次 |
最近记录: |