Created attachment 214056 [details] Patch to add le_scan command to hccontrol The attached patch adds an le_scan command to hccontrol. This is not really one hci command, but it enables le scanning and prints the responses. The output resembles the output of hccontrol inquiry, and has a verbose mode (-v) which provides more infomation about the response(s)
Created attachment 214299 [details] Patch to add le_scan command to hccontrol with RSSI Added RSSI field to scan, show full data packet in verbose mode.
Two things: 1. Don't you check address type field? 2. hci_dump_adv()@node.c do almost same thing as print_adv_data(). How about merge them?
Thank you very much for the feedback! I will add the address type field and refactor and merge hci_dump_adv() and print_adv_data(). One thing in which they differ is the fixed texts they output. For example "LocalName" versus "Complete Local Name" and "Shortened Local Name". Do you have a preference?
(In reply to Marc Veldman from comment #3) I have no preference about that.
Created attachment 214350 [details] Improved Patch to add le_scan command to hccontrol with RSSI - Merge hci_dump_adv into print_adv_data. - Take out adv handling functions into a separate file. - Show address type. Usage: hccontrol le_scan -a -v -n 10 Sample output: Scan 7 Scan result, num_reports: 1 BD_ADDR xx:yy:zz:aa:bb:cc Address type: Random Device Address ADV Data: 03 19 00 00 02 01 06 0e 09 4d 61 72 63 27 73 20 42 6c 69 6e 6b 79 c5 Appearance: 00 00 Flags: 06 Complete local name: Marc's Blinky RSSI: -59 dBm
(In reply to Marc Veldman from comment #5) If LE event is already enabled, le_scan command will disable all event, it seems. We may restore event mask, but we have no way to get event mask set. So I'll remove event mask manipulation code and commit. And adv data in neighbor cache does not contain RSSI data, so I'll move RSSI value parse code from print_adv_data. Thoughts?
Both are real improvements. Thank you!
A commit references this bug: Author: takawata Date: Mon May 11 15:32:34 UTC 2020 New revision: 360899 URL: https://svnweb.freebsd.org/changeset/base/360899 Log: Add le_scan subcommand to hccontrol. PR: 246141 Submitted by: Marc Veldman Changes: head/usr.sbin/bluetooth/hccontrol/Makefile head/usr.sbin/bluetooth/hccontrol/adv_data.c head/usr.sbin/bluetooth/hccontrol/hccontrol.8 head/usr.sbin/bluetooth/hccontrol/hccontrol.h head/usr.sbin/bluetooth/hccontrol/le.c head/usr.sbin/bluetooth/hccontrol/node.c head/usr.sbin/bluetooth/hccontrol/util.c