public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@codecoup.pl>
To: "Michał Narajowski" <michal.narajowski@codecoup.pl>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 04/31] monitor: Add LE Set Extended Advertising Parameters decoding
Date: Thu, 08 Jun 2017 15:00:39 +0200	[thread overview]
Message-ID: <4278864.kuFK7dqXAa@ix> (raw)
In-Reply-To: <20170606094120.14541-7-michal.narajowski@codecoup.pl>

Hi Micha=C5=82,

On Tuesday, 6 June 2017 11:40:53 CEST Micha=C5=82 Narajowski wrote:
> < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen =
25
>         Handle: 0x01
>         Properties: 0x0000
>         Min advertising interval: 20.000 msec (0x0020)
>         Max advertising interval: 159.375 msec (0x00ff)
>         Channel map: 37, 38, 39 (0x07)
>         Own address type: Random (0x01)
>         Peer address type: Public (0x00)
>         Peer address: 00:00:00:00:00:00 (OUI 00-00-00)
>         Filter policy: Allow Scan Request from Any, Allow Connect Request
> from Any (0x00) Tx power: 0xff
>         Primary PHY: LE 1M
>         Secondary max skip: 0x00
>         Secondary PHY: LE Coded (0x03)
>         SID: 0x06
>         Scan request notifications: Disabled
> ---
>  monitor/bt.h     |  24 +++++++++
>  monitor/packet.c | 158
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed,
> 181 insertions(+), 1 deletion(-)
>=20
> diff --git a/monitor/bt.h b/monitor/bt.h
> index d2e3e16..e903366 100644
> --- a/monitor/bt.h
> +++ b/monitor/bt.h
> @@ -2182,6 +2182,30 @@ struct bt_hci_cmd_le_set_adv_set_rand_addr {
>  	uint8_t  bdaddr[6];
>  } __attribute__ ((packed));
>=20
> +#define BT_HCI_CMD_LE_SET_EXT_ADV_PARAMS			0x2036
> +struct bt_hci_cmd_le_set_ext_adv_params {
> +	uint8_t  handle;
> +	uint16_t evt_properties;
> +	uint8_t  min_interval[3];
> +	uint8_t  max_interval[3];
> +	uint8_t  channel_map;
> +	uint8_t  own_addr_type;
> +	uint8_t  peer_addr_type;
> +	uint8_t  peer_addr[6];
> +	uint8_t  filter_policy;
> +	uint8_t  tx_power;
> +	uint8_t  primary_phy;
> +	uint8_t  secondary_max_skip;
> +	uint8_t  secondary_phy;
> +	uint8_t  sid;
> +	uint8_t  notif_enable;
> +} __attribute__ ((packed));
> +struct bt_hci_rsp_le_set_ext_adv_params {
> +	uint8_t  status;
> +	uint8_t  tx_power;
> +} __attribute__ ((packed));
> +
> +
>  #define BT_HCI_EVT_INQUIRY_COMPLETE		0x01
>  struct bt_hci_evt_inquiry_complete {
>  	uint8_t  status;
> diff --git a/monitor/packet.c b/monitor/packet.c
> index 771b7bb..35ffde9 100644
> --- a/monitor/packet.c
> +++ b/monitor/packet.c
> @@ -6939,6 +6939,160 @@ static void le_set_adv_set_rand_addr(const void
> *data, uint8_t size) print_addr("Advertising random address", cmd->bdaddr,
> 0x00);
>  }
>=20
> +static const struct {
> +	uint8_t bit;
> +	const char *str;
> +} ext_adv_properties_table[] =3D {
> +	{  0, "Connectable"		},
> +	{  1, "Scannable"		},
> +	{  2, "Directed"	},
> +	{  3, "High Duty Cycle Directed Connectable"	},
> +	{  4, "Use legacy advertising PDUs"	},
> +	{  5, "Anonymous advertising"	},
> +	{  6, "Include TxPower"		},
> +	{ }
> +};
> +
> +static void print_ext_adv_properties(uint16_t flags)
> +{
> +	uint16_t mask =3D flags;
> +	int i;
> +
> +	print_field("Properties: 0x%4.4x", flags);
> +
> +	for (i =3D 0; ext_adv_properties_table[i].str; i++) {
> +		if (flags & (1 << ext_adv_properties_table[i].bit)) {
> +			print_field("  %s", ext_adv_properties_table[i].str);
> +			mask &=3D ~(1 << ext_adv_properties_table[i].bit);
> +		}
> +	}

This should also decode legacy PDU if legacy flag is set.

> +
> +	if (mask)
> +		print_text(COLOR_UNKNOWN_ADV_FLAG, "  Unknown advertising properties"
> +							" (0x%4.4x)", mask);
> +}
> +
> +static void print_ext_slot_625(const char *label, const uint8_t value[3])
> +{
> +	uint32_t value_cpu =3D value[0];
> +
> +	value_cpu |=3D value[1] << 8;
> +	value_cpu |=3D value[2] << 16;
> +
> +	 print_field("%s: %.3f msec (0x%4.4x)", label,
> +				 value_cpu * 0.625, value_cpu);
> +}
> +
> +
> +static void le_set_ext_adv_params_cmd(const void *data, uint8_t size)
> +{
> +	const struct bt_hci_cmd_le_set_ext_adv_params *cmd =3D data;
> +	const char *str;
> +
> +	print_field("Handle: 0x%2.2x", cmd->handle);
> +	print_ext_adv_properties(le16_to_cpu(cmd->evt_properties));
> +
> +	print_ext_slot_625("Min advertising interval", cmd->min_interval);
> +	print_ext_slot_625("Max advertising interval", cmd->max_interval);
> +
> +	switch (cmd->channel_map) {
> +	case 0x01:
> +		str =3D "37";
> +		break;
> +	case 0x02:
> +		str =3D "38";
> +		break;
> +	case 0x03:
> +		str =3D "37, 38";
> +		break;
> +	case 0x04:
> +		str =3D "39";
> +		break;
> +	case 0x05:
> +		str =3D "37, 39";
> +		break;
> +	case 0x06:
> +		str =3D "38, 39";
> +		break;
> +	case 0x07:
> +		str =3D "37, 38, 39";
> +		break;
> +	default:
> +		str =3D "Reserved";
> +		break;
> +	}
> +
> +	print_field("Channel map: %s (0x%2.2x)", str, cmd->channel_map);
> +
> +	print_own_addr_type(cmd->own_addr_type);
> +	print_peer_addr_type("Peer address type", cmd->peer_addr_type);
> +	print_addr("Peer address", cmd->peer_addr, cmd->peer_addr_type);
> +
> +	switch (cmd->filter_policy) {
> +	case 0x00:
> +		str =3D "Allow Scan Request from Any, "
> +			"Allow Connect Request from Any";
> +		break;
> +	case 0x01:
> +		str =3D "Allow Scan Request from White List Only, "
> +			"Allow Connect Request from Any";
> +		break;
> +	case 0x02:
> +		str =3D "Allow Scan Request from Any, "
> +			"Allow Connect Request from White List Only";
> +		break;
> +	case 0x03:
> +		str =3D "Allow Scan Request from White List Only, "
> +			"Allow Connect Request from White List Only";
> +		break;
> +	default:
> +		str =3D "Reserved";
> +		break;
> +	}
> +
> +	print_field("Filter policy: %s (0x%2.2x)", str, cmd->filter_policy);
> +	print_field("Tx power: 0x%2.2x", cmd->tx_power);
> +
> +	switch (cmd->primary_phy) {
> +	case 0x01:
> +		str =3D "LE 1M";
> +		break;
> +	case 0x03:
> +		str =3D "LE Coded";
> +		break;
> +	default:
> +		str =3D "Reserved";
> +		break;
> +	}
> +
> +	print_field("Primary PHY: %s", str);
> +	print_field("Secondary max skip: 0x%2.2x", cmd->secondary_max_skip);
> +	print_le_phy("Secondary PHY", cmd->secondary_phy);
> +	print_field("SID: 0x%2.2x", cmd->sid);
> +
> +
> +	switch (cmd->notif_enable) {
> +	case 0x00:
> +		str =3D "Disabled";
> +		break;
> +	case 0x01:
> +		str =3D "Enabled";
> +		break;
> +	default:
> +		str =3D "Reserved";
> +		break;
> +	}
> +	print_field("Scan request notifications: %s", str);
> +}
> +
> +static void le_set_ext_adv_params_rsp(const void *data, uint8_t size)
> +{
> +	const struct bt_hci_rsp_le_set_ext_adv_params *rsp =3D data;
> +
> +	print_status(rsp->status);
> +	print_field("Selected Tx power: 0x%2.2x", rsp->tx_power);
> +}
> +
>  struct opcode_data {
>  	uint16_t opcode;
>  	int bit;
> @@ -7651,7 +7805,9 @@ static const struct opcode_data opcode_table[] =3D {
>  	{ 0x2035, 289, "LE Set Advertising Set Random Address",
>  				le_set_adv_set_rand_addr, 7, true,
>  				status_rsp, 1, true },
> -	{ 0x2036, 290, "LE Set Extended Advertising Parameters" },
> +	{ 0x2036, 290, "LE Set Extended Advertising Parameters",
> +				le_set_ext_adv_params_cmd, 25, true,
> +				le_set_ext_adv_params_rsp, 2, true },
>  	{ 0x2037, 291, "LE Set Extended Advertising Data" },
>  	{ 0x2038, 292, "LE Set Extended Scan Response Data" },
>  	{ 0x2039, 293, "LE Set Extended Advertising Enable" },


=2D-=20
pozdrawiam
Szymon Janc

  parent reply	other threads:[~2017-06-08 13:00 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06  9:40 [PATCH BlueZ 00/31] monitor: Bluetooth 5 HCI commands support Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 01/31] monitor: Add LE Enhanced Receiver Test decoding Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 1/2] monitor: Add LE Set Extended Scan Parameters decoding Michał Narajowski
2017-06-08  8:38   ` Marcel Holtmann
2017-06-06  9:40 ` [PATCH BlueZ 02/31] monitor: Add LE Enhanced Transmitter Test decoding Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 2/2] monitor: Add LE Set Extended Scan Enable decoding Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 03/31] monitor: Add LE Set Advertising Set Random Address decoding Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 04/31] monitor: Add LE Set Extended Advertising Parameters decoding Michał Narajowski
2017-06-08  8:44   ` Marcel Holtmann
2017-06-08 13:00   ` Szymon Janc [this message]
2017-06-06  9:40 ` [PATCH BlueZ 05/31] monitor: Add LE Set Extended Advertising Data decoding Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 06/31] monitor: Add LE Set Extended Scan Response " Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 07/31] monitor: Add LE Set Extended Advertising Enable decoding Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 08/31] monitor: Add LE Read Maximum Advertising Data Length decoding Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 09/31] monitor: Add LE Read Number of Supported Advertising Sets decoding Michał Narajowski
2017-06-06  9:40 ` [PATCH BlueZ 10/31] monitor: Add LE Remove Advertising Set decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 11/31] monitor: Add LE Clear Advertising Sets decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 12/31] monitor: Add LE Set Periodic Advertising Parameters decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 13/31] monitor: Add LE Set Periodic Advertising Data decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 14/31] monitor: Add LE Set Periodic Advertising Enable decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 15/31] monitor: Add LE Set Extended Scan Parameters decoding Michał Narajowski
2017-06-06  9:46   ` Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 16/31] monitor: Add LE Set Extended Scan Enable decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 17/31] monitor: Add LE Extended Create Connection decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 18/31] monitor: Add LE Periodic Advertising Create Sync decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 19/31] monitor: Add LE Periodic Advertising Create Sync Cancel decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 20/31] monitor: Add LE Periodic Advertising Terminate Sync decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 21/31] monitor: Add LE Add Device To Periodic Advertiser List decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 22/31] monitor: Add LE Remove Device From " Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 23/31] monitor: Add LE Clear " Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 24/31] monitor: Add LE Read Periodic Advertiser List Size decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 25/31] monitor: Add LE Read Transmit Power decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 26/31] monitor: Add LE Read RF Path Compensation decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 27/31] monitor: Add LE Write " Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 28/31] monitor: Add LE Set Privacy Mode decoding Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 29/31] monitor: Add LE Extended Advertising Report Event decoding Michał Narajowski
2017-06-06 14:10   ` Łukasz Rymanowski
2017-06-06  9:41 ` [PATCH BlueZ 30/31] monitor: Add LE Advertising Set Terminated " Michał Narajowski
2017-06-06  9:41 ` [PATCH BlueZ 31/31] monitor: Add LE Scan Request Received " Michał Narajowski
2017-06-08  8:47 ` [PATCH BlueZ 00/31] monitor: Bluetooth 5 HCI commands support Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4278864.kuFK7dqXAa@ix \
    --to=szymon.janc@codecoup.pl \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=michal.narajowski@codecoup.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox