Bug 245848 - [Patch] Add commands to hccontrol to enable LE advertising
Summary: [Patch] Add commands to hccontrol to enable LE advertising
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: wireless (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Hans Petter Selasky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-23 13:14 UTC by Marc Veldman
Modified: 2020-05-18 09:17 UTC (History)
1 user (show)

See Also:


Attachments
Adds commands to hccontrol to support advertising (6.55 KB, patch)
2020-04-23 13:14 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-04-23 13:14:51 UTC
Created attachment 213720 [details]
Adds commands to hccontrol to support advertising

Add 
  LE_Set_Advertising_Parameters,
  LE_Read_Advertising_Physical_Channel_Tx_Power,
  LE_Set_Advertising_Data,
  LE_Set_Advertising_Enable
commands.

This makes it possible to make a FreeBSD host 'scannable' through
hccontrol.

hccontrol -n ubt0hci le_set_advertising_enable disable
hccontrol -n ubt0hci le_set_advertising_param
hccontrol -n ubt0hci le_read_advertising_channel_tx_power
hccontrol -n ubt0hci le_set_advertising_data
hccontrol -n ubt0hci le_set_scan_response -n FBSD_Host
hccontrol -n ubt0hci le_set_advertising_enable enable

Also add LE command to manpage.
Comment 1 Hans Petter Selasky freebsd_committer 2020-04-23 13:40:36 UTC
We have a bluetooth pairing script in base:
usr.sbin/bluetooth/bluetooth-config/bluetooth-config.sh

Should this be updated too?

--HPS
Comment 2 Marc Veldman 2020-04-23 15:01:55 UTC
(In reply to Hans Petter Selasky from comment #1)

No.
Comment 3 Marc Veldman 2020-04-23 15:04:17 UTC
(In reply to Marc Veldman from comment #2)

Apologies. That was a bit too terse.
I should not have updated the title and tried to write a reply
at the same time.

These commands only make the host a scannable LE device.
Comment 4 commit-hook freebsd_committer 2020-04-24 08:08:16 UTC
A commit references this bug:

Author: hselasky
Date: Fri Apr 24 08:08:00 UTC 2020
New revision: 360243
URL: https://svnweb.freebsd.org/changeset/base/360243

Log:
  Add support for LE advertising to hccontrol(8).

  Submitted by:	Marc Veldman <marc@bumblingdork.com>
  PR:		245848
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Changes:
  head/usr.sbin/bluetooth/hccontrol/hccontrol.8
  head/usr.sbin/bluetooth/hccontrol/le.c
Comment 5 Hans Petter Selasky freebsd_committer 2020-04-24 08:08:25 UTC
Thank you!

Some minor modifications made prior to commit.
Comment 6 Hans Petter Selasky freebsd_committer 2020-04-24 08:16:56 UTC
Hi,

These two commands don't yet work:

           Read_LE_Host_Support
           Write_LE_Host_Support

I think they are spelled:

write_le_host_supported_command

and

read_le_host_supported_command

Please fix!

--HPS
Comment 7 Marc Veldman 2020-04-24 09:17:18 UTC
The command names I added in the manpage are actually
correct. See Bluetooth Core specification V5.2 Vol.4 Part E 7.3.78 and .79

However, I did overlook the actual command in hccontrol itself,
which is wrong. I put a fix in.

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=245868

Additionally, and what I suspect is the original reason for
'read_le_host_supported_command' is in 

sys/netgraph/bluetooth/include/ng_hci.h line 1314-1327:

#define NG_HCI_OCF_READ_LE_HOST_SUPPORTED  0x6c
typedef struct {
        u_int8_t        status;         /* 0x00 - success */
        u_int8_t        le_supported_host ;/* LE host supported?*/
        u_int8_t        simultaneous_le_host; /* BR/LE simulateneous? */
} __attribute__ ((packed)) ng_hci_read_le_host_supported_rp;

#define NG_HCI_OCF_WRITE_LE_HOST_SUPPORTED  0x6d
typedef struct {
        u_int8_t        le_supported_host; /* LE host supported?*/
        u_int8_t        simultaneous_le_host; /* LE host supported?*/
} __attribute__ ((packed)) ng_hci_write_le_host_supported_cp;

typedef ng_hci_status_rp        ng_hci_write_le_host_supported_rp;

I think those should be renamed. 
Shall I make a patch for that as well?
Comment 8 Hans Petter Selasky freebsd_committer 2020-04-24 09:59:29 UTC
I think we can keep the defines as-is.

--HPS
Comment 9 commit-hook freebsd_committer 2020-04-25 00:58:47 UTC
A commit references this bug:

Author: hselasky
Date: Sat Apr 25 00:57:49 UTC 2020
New revision: 360288
URL: https://svnweb.freebsd.org/changeset/base/360288

Log:
  Put advertising data in correct place.

  Submitted by:	Marc Veldman <marc@bumblingdork.com>
  PR:		245848
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Changes:
  head/usr.sbin/bluetooth/hccontrol/le.c
Comment 10 commit-hook freebsd_committer 2020-05-18 09:13:54 UTC
A commit references this bug:

Author: hselasky
Date: Mon May 18 09:13:04 UTC 2020
New revision: 361182
URL: https://svnweb.freebsd.org/changeset/base/361182

Log:
  MFC r360243:
  Add support for LE advertising to hccontrol(8).

  Submitted by:	Marc Veldman <marc@bumblingdork.com>
  PR:		245848
  Sponsored by:	Mellanox Technologies

Changes:
_U  stable/12/
  stable/12/usr.sbin/bluetooth/hccontrol/hccontrol.8
  stable/12/usr.sbin/bluetooth/hccontrol/le.c
Comment 11 commit-hook freebsd_committer 2020-05-18 09:13:55 UTC
A commit references this bug:

Author: hselasky
Date: Mon May 18 09:13:35 UTC 2020
New revision: 361183
URL: https://svnweb.freebsd.org/changeset/base/361183

Log:
  MFC r360243:
  Add support for LE advertising to hccontrol(8).

  Submitted by:	Marc Veldman <marc@bumblingdork.com>
  PR:		245848
  Sponsored by:	Mellanox Technologies

Changes:
_U  stable/11/
  stable/11/usr.sbin/bluetooth/hccontrol/hccontrol.8
  stable/11/usr.sbin/bluetooth/hccontrol/le.c
Comment 12 commit-hook freebsd_committer 2020-05-18 09:15:59 UTC
A commit references this bug:

Author: hselasky
Date: Mon May 18 09:15:45 UTC 2020
New revision: 361186
URL: https://svnweb.freebsd.org/changeset/base/361186

Log:
  MFC r360288:
  Put advertising data in correct place.

  Submitted by:	Marc Veldman <marc@bumblingdork.com>
  PR:		245848
  Sponsored by:	Mellanox Technologies

Changes:
_U  stable/12/
  stable/12/usr.sbin/bluetooth/hccontrol/le.c
Comment 13 commit-hook freebsd_committer 2020-05-18 09:17:01 UTC
A commit references this bug:

Author: hselasky
Date: Mon May 18 09:16:18 UTC 2020
New revision: 361187
URL: https://svnweb.freebsd.org/changeset/base/361187

Log:
  MFC r360288:
  Put advertising data in correct place.

  Submitted by:	Marc Veldman <marc@bumblingdork.com>
  PR:		245848
  Sponsored by:	Mellanox Technologies

Changes:
_U  stable/11/
  stable/11/usr.sbin/bluetooth/hccontrol/le.c