Commit 0224d2fa authored by Johan Hedberg's avatar Johan Hedberg

Bluetooth: mgmt: Fix New Settings event for connectable/discoverable

When powered off and doing changes to the Connectable or Discoverable
setting we should also send an appropriate New Settings event in
addition to the command response.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent beadb2bd
...@@ -876,11 +876,20 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) ...@@ -876,11 +876,20 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len)
} }
if (!hdev_is_powered(hdev)) { if (!hdev_is_powered(hdev)) {
if (cp->val) bool changed = false;
set_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
else if (!!cp->val != test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) {
clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); change_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
changed = true;
}
err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev); err = send_settings_rsp(sk, MGMT_OP_SET_DISCOVERABLE, hdev);
if (err < 0)
goto failed;
if (changed)
err = new_settings(hdev, sk);
goto failed; goto failed;
} }
...@@ -938,13 +947,25 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len) ...@@ -938,13 +947,25 @@ static int set_connectable(struct sock *sk, u16 index, void *data, u16 len)
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (!hdev_is_powered(hdev)) { if (!hdev_is_powered(hdev)) {
bool changed = false;
if (!!cp->val != test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
changed = true;
if (cp->val) if (cp->val)
set_bit(HCI_CONNECTABLE, &hdev->dev_flags); set_bit(HCI_CONNECTABLE, &hdev->dev_flags);
else { else {
clear_bit(HCI_CONNECTABLE, &hdev->dev_flags); clear_bit(HCI_CONNECTABLE, &hdev->dev_flags);
clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags); clear_bit(HCI_DISCOVERABLE, &hdev->dev_flags);
} }
err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev); err = send_settings_rsp(sk, MGMT_OP_SET_CONNECTABLE, hdev);
if (err < 0)
goto failed;
if (changed)
err = new_settings(hdev, sk);
goto failed; goto failed;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment