Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] Bleutooth: Add definitions for LE Read Tx Power
@ 2020-01-07  8:48 Ankit Navik
  2020-01-08 20:57 ` Marcel Holtmann
  0 siblings, 1 reply; 3+ messages in thread
From: Ankit Navik @ 2020-01-07  8:48 UTC (permalink / raw)
  To: linux-bluetooth

Add the definitions for LE read transmit power HCI commands to
read the minimum and maximum Tx power.

Signed-off-by: Ankit Navik <ankit.p.navik@intel.com>
---
 include/net/bluetooth/hci.h      |  7 +++++++
 include/net/bluetooth/hci_core.h |  3 +++
 net/bluetooth/hci_event.c        | 18 ++++++++++++++++++
 3 files changed, 28 insertions(+)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 07b6ece..6e8805f 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1641,6 +1641,13 @@ struct hci_cp_le_ext_conn_param {
 	__le16 max_ce_len;
 } __packed;
 
+#define HCI_OP_LE_READ_TX_POWER		0x204b
+struct hci_rp_le_read_tx_power {
+	__u8 status;
+	__s8 min_tx_power;
+	__s8 max_tx_power;
+} __packed;
+
 #define HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS	0x203b
 struct hci_rp_le_read_num_supported_adv_sets {
 	__u8  status;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index faebe38..88c6e55 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -418,6 +418,9 @@ struct hci_dev {
 	__u8			scan_rsp_data[HCI_MAX_AD_LENGTH];
 	__u8			scan_rsp_data_len;
 
+	__s8			min_tx_power;
+	__s8			max_tx_power;
+
 	struct list_head	adv_instances;
 	unsigned int		adv_instance_cnt;
 	__u8			cur_adv_instance;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6ddc4a7..fc154cf 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -988,6 +988,20 @@ static void hci_cc_le_read_adv_tx_power(struct hci_dev *hdev,
 	hdev->adv_tx_power = rp->tx_power;
 }
 
+static void hci_cc_le_read_tx_power(struct hci_dev *hdev,
+					struct sk_buff *skb)
+{
+	struct hci_rp_le_read_tx_power *rp = (void *) skb->data;
+
+	BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
+
+	if (rp->status)
+		return;
+
+	hdev->min_tx_power = rp->min_tx_power;
+	hdev->max_tx_power = rp->max_tx_power;
+}
+
 static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
@@ -3414,6 +3428,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
 		hci_cc_le_read_max_data_len(hdev, skb);
 		break;
 
+	case HCI_OP_LE_READ_TX_POWER:
+		hci_cc_le_read_tx_power(hdev, skb);
+		break;
+
 	case HCI_OP_WRITE_LE_HOST_SUPPORTED:
 		hci_cc_write_le_host_supported(hdev, skb);
 		break;
-- 
2.7.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bleutooth: Add definitions for LE Read Tx Power
  2020-01-07  8:48 [PATCH] Bleutooth: Add definitions for LE Read Tx Power Ankit Navik
@ 2020-01-08 20:57 ` Marcel Holtmann
  2020-01-09 17:28   ` Navik, Ankit P
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2020-01-08 20:57 UTC (permalink / raw)
  To: Ankit Navik; +Cc: BlueZ devel list

Hi Ankit,

> Add the definitions for LE read transmit power HCI commands to
> read the minimum and maximum Tx power.
> 
> Signed-off-by: Ankit Navik <ankit.p.navik@intel.com>
> ---
> include/net/bluetooth/hci.h      |  7 +++++++
> include/net/bluetooth/hci_core.h |  3 +++
> net/bluetooth/hci_event.c        | 18 ++++++++++++++++++
> 3 files changed, 28 insertions(+)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 07b6ece..6e8805f 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -1641,6 +1641,13 @@ struct hci_cp_le_ext_conn_param {
> 	__le16 max_ce_len;
> } __packed;
> 
> +#define HCI_OP_LE_READ_TX_POWER		0x204b
> +struct hci_rp_le_read_tx_power {
> +	__u8 status;
> +	__s8 min_tx_power;
> +	__s8 max_tx_power;
> +} __packed;
> +
> #define HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS	0x203b

can we please keep this list sorted by opcode.

> struct hci_rp_le_read_num_supported_adv_sets {
> 	__u8  status;
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index faebe38..88c6e55 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -418,6 +418,9 @@ struct hci_dev {
> 	__u8			scan_rsp_data[HCI_MAX_AD_LENGTH];
> 	__u8			scan_rsp_data_len;
> 
> +	__s8			min_tx_power;
> +	__s8			max_tx_power;
> +

They are LE specific so lets prefix them as le_ and put them together with other le_ data.

> 	struct list_head	adv_instances;
> 	unsigned int		adv_instance_cnt;
> 	__u8			cur_adv_instance;
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 6ddc4a7..fc154cf 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -988,6 +988,20 @@ static void hci_cc_le_read_adv_tx_power(struct hci_dev *hdev,
> 	hdev->adv_tx_power = rp->tx_power;
> }
> 
> +static void hci_cc_le_read_tx_power(struct hci_dev *hdev,
> +					struct sk_buff *skb)

Please do proper indentation.

> +{
> +	struct hci_rp_le_read_tx_power *rp = (void *) skb->data;
> +
> +	BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
> +
> +	if (rp->status)
> +		return;
> +
> +	hdev->min_tx_power = rp->min_tx_power;
> +	hdev->max_tx_power = rp->max_tx_power;
> +}
> +
> static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb)
> {
> 	struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
> @@ -3414,6 +3428,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb,
> 		hci_cc_le_read_max_data_len(hdev, skb);
> 		break;
> 
> +	case HCI_OP_LE_READ_TX_POWER:
> +		hci_cc_le_read_tx_power(hdev, skb);
> +		break;
> +
> 	case HCI_OP_WRITE_LE_HOST_SUPPORTED:
> 		hci_cc_write_le_host_supported(hdev, skb);
> 		break;

Regards

Marcel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] Bleutooth: Add definitions for LE Read Tx Power
  2020-01-08 20:57 ` Marcel Holtmann
@ 2020-01-09 17:28   ` Navik, Ankit P
  0 siblings, 0 replies; 3+ messages in thread
From: Navik, Ankit P @ 2020-01-09 17:28 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: BlueZ devel list

Hi Marcel, 

> -----Original Message-----
> From: Marcel Holtmann <marcel@holtmann.org>
> Sent: Thursday, January 9, 2020 2:27 AM
> To: Navik, Ankit P <ankit.p.navik@intel.com>
> Cc: BlueZ devel list <linux-bluetooth@vger.kernel.org>
> Subject: Re: [PATCH] Bleutooth: Add definitions for LE Read Tx Power
> 
> Hi Ankit,
> 
> > Add the definitions for LE read transmit power HCI commands to read
> > the minimum and maximum Tx power.
> >
> > Signed-off-by: Ankit Navik <ankit.p.navik@intel.com>
> > ---
> > include/net/bluetooth/hci.h      |  7 +++++++
> > include/net/bluetooth/hci_core.h |  3 +++
> > net/bluetooth/hci_event.c        | 18 ++++++++++++++++++
> > 3 files changed, 28 insertions(+)
> >
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index 07b6ece..6e8805f 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -1641,6 +1641,13 @@ struct hci_cp_le_ext_conn_param {
> > 	__le16 max_ce_len;
> > } __packed;
> >
> > +#define HCI_OP_LE_READ_TX_POWER		0x204b
> > +struct hci_rp_le_read_tx_power {
> > +	__u8 status;
> > +	__s8 min_tx_power;
> > +	__s8 max_tx_power;
> > +} __packed;
> > +
> > #define HCI_OP_LE_READ_NUM_SUPPORTED_ADV_SETS	0x203b
> 
> can we please keep this list sorted by opcode.

Yes, I will fix and submit v2. 
> 
> > struct hci_rp_le_read_num_supported_adv_sets {
> > 	__u8  status;
> > diff --git a/include/net/bluetooth/hci_core.h
> > b/include/net/bluetooth/hci_core.h
> > index faebe38..88c6e55 100644
> > --- a/include/net/bluetooth/hci_core.h
> > +++ b/include/net/bluetooth/hci_core.h
> > @@ -418,6 +418,9 @@ struct hci_dev {
> > 	__u8			scan_rsp_data[HCI_MAX_AD_LENGTH];
> > 	__u8			scan_rsp_data_len;
> >
> > +	__s8			min_tx_power;
> > +	__s8			max_tx_power;
> > +
> 
> They are LE specific so lets prefix them as le_ and put them together with other
> le_ data.

Agree. 
> 
> > 	struct list_head	adv_instances;
> > 	unsigned int		adv_instance_cnt;
> > 	__u8			cur_adv_instance;
> > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > index 6ddc4a7..fc154cf 100644
> > --- a/net/bluetooth/hci_event.c
> > +++ b/net/bluetooth/hci_event.c
> > @@ -988,6 +988,20 @@ static void hci_cc_le_read_adv_tx_power(struct
> hci_dev *hdev,
> > 	hdev->adv_tx_power = rp->tx_power;
> > }
> >
> > +static void hci_cc_le_read_tx_power(struct hci_dev *hdev,
> > +					struct sk_buff *skb)
> 
> Please do proper indentation.

I'll send v2. 

Regards, 
Ankit
> 
> > +{
> > +	struct hci_rp_le_read_tx_power *rp = (void *) skb->data;
> > +
> > +	BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
> > +
> > +	if (rp->status)
> > +		return;
> > +
> > +	hdev->min_tx_power = rp->min_tx_power;
> > +	hdev->max_tx_power = rp->max_tx_power; }
> > +
> > static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct
> > sk_buff *skb) {
> > 	struct hci_rp_user_confirm_reply *rp = (void *) skb->data; @@ -3414,6
> > +3428,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct
> sk_buff *skb,
> > 		hci_cc_le_read_max_data_len(hdev, skb);
> > 		break;
> >
> > +	case HCI_OP_LE_READ_TX_POWER:
> > +		hci_cc_le_read_tx_power(hdev, skb);
> > +		break;
> > +
> > 	case HCI_OP_WRITE_LE_HOST_SUPPORTED:
> > 		hci_cc_write_le_host_supported(hdev, skb);
> > 		break;
> 
> Regards
> 
> Marcel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07  8:48 [PATCH] Bleutooth: Add definitions for LE Read Tx Power Ankit Navik
2020-01-08 20:57 ` Marcel Holtmann
2020-01-09 17:28   ` Navik, Ankit P

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git