Bug 246141 - [Patch] Add an le_scan command to hccontrol
Summary: [Patch] Add an le_scan command to hccontrol
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: wireless (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Takanori Watanabe
URL:
Keywords:
Depends on: 245920
Blocks:
  Show dependency treegraph
 
Reported: 2020-05-03 12:02 UTC by Marc Veldman
Modified: 2020-05-12 01:27 UTC (History)
2 users (show)

See Also:


Attachments
Patch to add le_scan command to hccontrol (8.82 KB, patch)
2020-05-03 12:02 UTC, Marc Veldman
no flags Details | Diff
Patch to add le_scan command to hccontrol with RSSI (9.25 KB, patch)
2020-05-09 05:50 UTC, Marc Veldman
no flags Details | Diff
Improved Patch to add le_scan command to hccontrol with RSSI (16.06 KB, patch)
2020-05-10 15:26 UTC, Marc Veldman
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Veldman 2020-05-03 12:02:17 UTC
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)
Comment 1 Marc Veldman 2020-05-09 05:50:28 UTC
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.
Comment 2 Takanori Watanabe freebsd_committer freebsd_triage 2020-05-09 07:52:46 UTC
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?
Comment 3 Marc Veldman 2020-05-09 11:05:18 UTC
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?
Comment 4 Takanori Watanabe freebsd_committer freebsd_triage 2020-05-09 13:59:06 UTC
(In reply to Marc Veldman from comment #3)
I have no preference about that.
Comment 5 Marc Veldman 2020-05-10 15:26:08 UTC
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
Comment 6 Takanori Watanabe freebsd_committer freebsd_triage 2020-05-11 12:16:51 UTC
(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?
Comment 7 Marc Veldman 2020-05-11 13:05:23 UTC
Both are real improvements. Thank you!
Comment 8 commit-hook freebsd_committer freebsd_triage 2020-05-11 15:33:03 UTC
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