Scan bluetooth low energy using hcitool?

我怕爱的太早我们不能终老 提交于 2019-12-23 15:51:38

问题


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.

The command I used:

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

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


回答1:


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 timeout -s SIGINT 5s hcitool -i hci0 lescan > file.txt



来源:https://stackoverflow.com/questions/32300008/scan-bluetooth-low-energy-using-hcitool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!