Bluetooth: add basic adapter functionality to client
Just about all tests will want to reset the device to a known state
so provide reset_on() and reset_off() to do that. The difference is
whether the adapter is powered on or off after the reset; most tests
will want the former, but it's conceivable the latter might be
necessary.
Provide basic property manipulation with set_powered(),
set_discoverable() and set_pairable().
BUG=chromium:256771
TEST=simple test that uses the exposed methods,
verify operation using btmon on DUT
Change-Id: Ib3a5efb3ea5de8a457e9043f57801d7b00cf1808
Reviewed-on: https://gerrit.chromium.org/gerrit/63261
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Commit-Queue: Scott James Remnant <keybuk@chromium.org>
Tested-by: Scott James Remnant <keybuk@chromium.org>
diff --git a/server/cros/bluetooth/bluetooth_client.py b/server/cros/bluetooth/bluetooth_client.py
index 61d352f..4e6ae4b 100644
--- a/server/cros/bluetooth/bluetooth_client.py
+++ b/server/cros/bluetooth/bluetooth_client.py
@@ -40,7 +40,55 @@
constants.BLUETOOTH_CLIENT_XMLRPC_SERVER_READY_METHOD,
timeout_seconds=self.XMLRPC_BRINGUP_TIMEOUT_SECONDS)
+ def reset_on(self):
+ """Reset the adapter and settings and power up the adapter.
+
+ @return True on success, False otherwise.
+
+ """
+ return self._proxy.reset_on()
+
+ def reset_off(self):
+ """Reset the adapter and settings, leave the adapter powered off.
+
+ @return True on success, False otherwise.
+
+ """
+ return self._proxy.reset_off()
+
+ def set_powered(self, powered):
+ """Set the adapter power state.
+
+ @param powered adapter power state to set (True or False).
+
+ @return True on success, False otherwise.
+
+ """
+ return self._proxy.set_powered(powered)
+
+ def set_discoverable(self, discoverable):
+ """Set the adapter discoverable state.
+
+ @param powered adapter discoverable state to set (True or False).
+
+ @return True on success, False otherwise.
+
+ """
+ return self._proxy.set_discoverable(discoverable)
+
+ def set_pairable(self, pairable):
+ """Set the adapter pairable state.
+
+ @param powered adapter pairable state to set (True or False).
+
+ @return True on success, False otherwise.
+
+ """
+ return self._proxy.set_pairable(pairable)
+
def close(self):
"""Tear down state associated with the client."""
+ # Leave the adapter powered off, but don't do a full reset.
+ self._proxy.set_powered(False)
# This kills the RPC server.
self._host.close()