Scan bluetooth low energy using hcitool?
17,105
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
Related videos on Youtube
Author by
ahmed ayman
Updated on June 04, 2022Comments
-
ahmed ayman almost 2 years
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?-
Zimano over 8 years
hcitool
is not being developed anymore and runs with libbluetooth. In my opinion you would be better off usingbluetoothctl
.
-