Bluetooth: implement bluetooth_Sanity_Discoverable
This test is the first example of a Bluetooth test with a separate
tester device (a stumpy with the testbed-ap profile is the intent).
It can be run two ways:
1. as bluetooth_Sanity_Discoverable - in which case the Tester will
be used to perform a device discovery and verify that the DUT
was detected in the process.
2. as bluetooth_Sanity_Discoverable.manual - in which case only the
DUT is used, and instructions presented on screen for use with
a third-party Tester (such as the Bluetooth PTS).
BUG=chromium:256771
TEST=run_remote_tests
Change-Id: I851a05acff3ca3edba32bb2f0cd043d8042d162d
Reviewed-on: https://gerrit.chromium.org/gerrit/65074
Commit-Queue: Scott James Remnant <keybuk@chromium.org>
Reviewed-by: Scott James Remnant <keybuk@chromium.org>
Tested-by: Scott James Remnant <keybuk@chromium.org>
diff --git a/server/cros/bluetooth/bluetooth_tester.py b/server/cros/bluetooth/bluetooth_tester.py
index 861a6f8..b055365 100644
--- a/server/cros/bluetooth/bluetooth_tester.py
+++ b/server/cros/bluetooth/bluetooth_tester.py
@@ -2,6 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import base64
+import json
+
from autotest_lib.client.cros import constants
from autotest_lib.server import autotest, hosts
@@ -39,6 +42,45 @@
timeout_seconds=self.XMLRPC_BRINGUP_TIMEOUT_SECONDS)
+ def setup(self, profile):
+ """Set up the tester with the given profile.
+
+ @param profile: Profile to use for this test, valid values are:
+ computer - a standard computer profile
+
+ @return True on success, False otherwise.
+
+ """
+ return self._proxy.setup(profile)
+
+
+ def discover_devices(self, br_edr=True, le_public=True, le_random=True):
+ """Discover remote devices.
+
+ Activates device discovery and collects the set of devices found,
+ returning them as a list.
+
+ @param br_edr: Whether to detect BR/EDR devices.
+ @param le_public: Whether to detect LE Public Address devices.
+ @param le_random: Whether to detect LE Random Address devices.
+
+ @return List of devices found as tuples with the format
+ (address, address_type, rssi, flags, base64-encoded eirdata),
+ or False if discovery could not be started.
+
+ """
+ devices = self._proxy.discover_devices(br_edr, le_public, le_random)
+ if devices == False:
+ return False
+
+ return (
+ (address, address_type, rssi, flags,
+ base64.decodestring(eirdata))
+ for address, address_type, rssi, flags, eirdata
+ in json.loads(devices)
+ )
+
+
def close(self):
"""Tear down state associated with the client."""
# This kills the RPC server.