【问题标题】:Scan bluetooth low energy using hcitool?使用 hcitool 扫描蓝牙低功耗?
【发布时间】:2015-08-30 18:52:10
【问题描述】:

当我运行这个使 ble 设备只扫描 5 秒的命令时:

$ sudo timeout 5s hcitool -i hci0 lescan

输出显示在终端屏幕中。

但是当我将输出重定向到一个文件以保存广告设备的地址时,每次我运行命令时,我发现文件是空的,并且输出在终端和文件中都不可见。

我使用的命令:

$ sudo timeout 5s hcitool -i hci0 lescan > file.txt

我必须做什么才能使hcitool 正确地将其输出重定向到文件?

【问题讨论】:

  • hcitool 不再被开发并与 libbluetooth 一起运行。在我看来,您最好使用bluetoothctl

标签: linux shell ubuntu bluetooth bluetooth-lowenergy


【解决方案1】:

timeout 默认情况下会向程序发送一个 SIGTERM。看起来hcitool 处理得并不优雅。而是使用 SIGINT(相当于 ctrl-c)。

sudo timeout -s SIGINT 5s hcitool -i hci0 lescan > file.txt

【讨论】:

    猜你喜欢
    • 2015-03-11
    • 2014-04-23
    • 1970-01-01
    • 2014-09-29
    • 2016-03-15
    • 2013-11-26
    • 2014-12-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多