使用hcitool扫描蓝牙低能量? [英] Scan bluetooth low energy using hcitool?

查看:392
本文介绍了使用hcitool扫描蓝牙低能量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行此命令使得BLE装置扫描仅只有5秒:

When I run this command which makes the ble device scanning for just 5 seconds only:

$ sudo timeout 5s hcitool -i hci0 lescan

的输出被显示在终端屏幕上。

the output is shown in the terminal screen.

但是,当我将输出重定向到一个文件来保存广告设备的地址,每次我跑我找到这个文件是空的,输出是不是在终端,也没有在文件中看到该命令的时间。

But when I redirect the output to a file to save the addresses of the advertising devices, every time I run the command I find the file is empty and the output isn't visible in the terminal nor in the file.

我使用的命令:

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

我有什么,以使做 hcitool 正确的输出中重定向到文件?

What do I have to do in order to make hcitool correctly redirect its ouput to the file?

推荐答案

暂停默认发送SIGTERM的程序。貌似 hcitool 不处理正常。而是使用SIGINT(相当于CTRL-C)。

timeout by default sends a SIGTERM to the program. Looks like hcitool doesn't handle that gracefully. Instead use SIGINT (equivalent to ctrl-c).

sudo的超时-s SIGINT 5S hcitool -i hci0莱斯康> file.txt的

这篇关于使用hcitool扫描蓝牙低能量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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