if (!match->mgmt_status) {
rp.rssi = conn->rssi;
- if (match->valid_tx_power)
+ if (match->valid_tx_power) {
rp.tx_power = conn->tx_power;
- else
+ rp.max_tx_power = conn->max_tx_power;
+ } else {
rp.tx_power = HCI_TX_POWER_INVALID;
-
- rp.max_tx_power = HCI_TX_POWER_INVALID;
+ rp.max_tx_power = HCI_TX_POWER_INVALID;
+ }
}
cmd_complete(cmd->sk, cmd->index, MGMT_OP_GET_CONN_INFO,
hci_dev_lock(hdev);
/* TX power data is valid in case request completed successfully,
- * otherwise we assume it's not valid.
+ * otherwise we assume it's not valid. At the moment we assume that
+ * either both or none of current and max values are valid to keep code
+ * simple.
*/
match.valid_tx_power = !status;
sizeof(req_txp_cp), &req_txp_cp);
}
+ /* Max TX power needs to be read only once per connection */
+ if (conn->max_tx_power == HCI_TX_POWER_INVALID) {
+ req_txp_cp.handle = cpu_to_le16(conn->handle);
+ req_txp_cp.type = 0x01;
+ hci_req_add(&req, HCI_OP_READ_TX_POWER,
+ sizeof(req_txp_cp), &req_txp_cp);
+ }
+
err = hci_req_run(&req, conn_info_refresh_complete);
if (err < 0)
goto unlock;
/* Cache is valid, just reply with values cached in hci_conn */
rp.rssi = conn->rssi;
rp.tx_power = conn->tx_power;
- rp.max_tx_power = HCI_TX_POWER_INVALID;
+ rp.max_tx_power = conn->max_tx_power;
err = cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO,
MGMT_STATUS_SUCCESS, &rp, sizeof(rp));