diff options
author | Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com> | 2014-05-14 07:43:06 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-05-16 00:48:07 -0400 |
commit | eed5daf318cf579f06c3e1eb47d014c35c84e3a3 (patch) | |
tree | 03e2bcdd70000971b5873732b782fb31313092c4 /net | |
parent | d0455ed996df84fd2670a655fe13ab72f8264765 (diff) |
Bluetooth: Add support for max_tx_power in Get Conn Info
This patch adds support for max_tx_power in Get Connection Information
request. Value is read only once for given connection and then always
returned in response as parameter.
Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/mgmt.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 664dbc4eccbe..17ebaa3b01bb 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -4583,12 +4583,13 @@ static void get_conn_info_complete(struct pending_cmd *cmd, void *data) | |||
4583 | if (!match->mgmt_status) { | 4583 | if (!match->mgmt_status) { |
4584 | rp.rssi = conn->rssi; | 4584 | rp.rssi = conn->rssi; |
4585 | 4585 | ||
4586 | if (match->valid_tx_power) | 4586 | if (match->valid_tx_power) { |
4587 | rp.tx_power = conn->tx_power; | 4587 | rp.tx_power = conn->tx_power; |
4588 | else | 4588 | rp.max_tx_power = conn->max_tx_power; |
4589 | } else { | ||
4589 | rp.tx_power = HCI_TX_POWER_INVALID; | 4590 | rp.tx_power = HCI_TX_POWER_INVALID; |
4590 | 4591 | rp.max_tx_power = HCI_TX_POWER_INVALID; | |
4591 | rp.max_tx_power = HCI_TX_POWER_INVALID; | 4592 | } |
4592 | } | 4593 | } |
4593 | 4594 | ||
4594 | cmd_complete(cmd->sk, cmd->index, MGMT_OP_GET_CONN_INFO, | 4595 | cmd_complete(cmd->sk, cmd->index, MGMT_OP_GET_CONN_INFO, |
@@ -4611,7 +4612,9 @@ static void conn_info_refresh_complete(struct hci_dev *hdev, u8 status) | |||
4611 | hci_dev_lock(hdev); | 4612 | hci_dev_lock(hdev); |
4612 | 4613 | ||
4613 | /* TX power data is valid in case request completed successfully, | 4614 | /* TX power data is valid in case request completed successfully, |
4614 | * otherwise we assume it's not valid. | 4615 | * otherwise we assume it's not valid. At the moment we assume that |
4616 | * either both or none of current and max values are valid to keep code | ||
4617 | * simple. | ||
4615 | */ | 4618 | */ |
4616 | match.valid_tx_power = !status; | 4619 | match.valid_tx_power = !status; |
4617 | 4620 | ||
@@ -4728,6 +4731,14 @@ static int get_conn_info(struct sock *sk, struct hci_dev *hdev, void *data, | |||
4728 | sizeof(req_txp_cp), &req_txp_cp); | 4731 | sizeof(req_txp_cp), &req_txp_cp); |
4729 | } | 4732 | } |
4730 | 4733 | ||
4734 | /* Max TX power needs to be read only once per connection */ | ||
4735 | if (conn->max_tx_power == HCI_TX_POWER_INVALID) { | ||
4736 | req_txp_cp.handle = cpu_to_le16(conn->handle); | ||
4737 | req_txp_cp.type = 0x01; | ||
4738 | hci_req_add(&req, HCI_OP_READ_TX_POWER, | ||
4739 | sizeof(req_txp_cp), &req_txp_cp); | ||
4740 | } | ||
4741 | |||
4731 | err = hci_req_run(&req, conn_info_refresh_complete); | 4742 | err = hci_req_run(&req, conn_info_refresh_complete); |
4732 | if (err < 0) | 4743 | if (err < 0) |
4733 | goto unlock; | 4744 | goto unlock; |
@@ -4747,7 +4758,7 @@ static int get_conn_info(struct sock *sk, struct hci_dev *hdev, void *data, | |||
4747 | /* Cache is valid, just reply with values cached in hci_conn */ | 4758 | /* Cache is valid, just reply with values cached in hci_conn */ |
4748 | rp.rssi = conn->rssi; | 4759 | rp.rssi = conn->rssi; |
4749 | rp.tx_power = conn->tx_power; | 4760 | rp.tx_power = conn->tx_power; |
4750 | rp.max_tx_power = HCI_TX_POWER_INVALID; | 4761 | rp.max_tx_power = conn->max_tx_power; |
4751 | 4762 | ||
4752 | err = cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO, | 4763 | err = cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO, |
4753 | MGMT_STATUS_SUCCESS, &rp, sizeof(rp)); | 4764 | MGMT_STATUS_SUCCESS, &rp, sizeof(rp)); |