Make PTS cmd line tool additions for HID and GATT
Bug: n/a
Test: manual
Change-Id: I5210fe145936220984301ba87e11eedef9f25fbf
diff --git a/acts/tests/google/bt/pts/cmd_input.py b/acts/tests/google/bt/pts/cmd_input.py
index 52ae2bd..b623211 100644
--- a/acts/tests/google/bt/pts/cmd_input.py
+++ b/acts/tests/google/bt/pts/cmd_input.py
@@ -348,6 +348,14 @@
except Exception as err:
self.log.info(FAILURE.format(cmd, err))
+ def do_gattc_read_all_desc(self, line):
+ """Read all Descriptor values"""
+ cmd = "Read all Descriptor values"
+ try:
+ self.gattc_lib.read_all_desc()
+ except Exception as err:
+ self.log.info(FAILURE.format(cmd, err))
+
"""End GATT Client wrappers"""
"""Begin GATT Server wrappers"""
@@ -361,8 +369,8 @@
def complete_gatts_setup_database(self, text, line, begidx, endidx):
if not text:
- completions = list(
- gatt_test_database.GATT_SERVER_DB_MAPPING.keys())[:]
+ completions = list(gatt_test_database.GATT_SERVER_DB_MAPPING.keys(
+ ))[:]
else:
completions = [
s for s in gatt_test_database.GATT_SERVER_DB_MAPPING.keys()
@@ -920,3 +928,40 @@
self.log.info(FAILURE.format(cmd, err))
"""End HFP/HSP wrapper"""
+ """Begin HID wrappers"""
+
+ def do_hid_get_report(self, line):
+ """Get HID Report"""
+ cmd = "Get HID Report"
+ try:
+ self.pri_dut.droid.bluetoothHidGetReport(self.mac_addr, "1", "1",
+ 1024)
+ except Exception as err:
+ self.log.info(FAILURE.format(cmd, err))
+
+ def do_hid_set_report(self, line):
+ """Get HID Report"""
+ cmd = "Get HID Report"
+ try:
+ self.pri_dut.droid.bluetoothHidSetReport(self.mac_addr, "1",
+ "Test")
+ except Exception as err:
+ self.log.info(FAILURE.format(cmd, err))
+
+ def do_hid_virtual_unplug(self, line):
+ """Get HID Report"""
+ cmd = "Get HID Report"
+ try:
+ self.pri_dut.droid.bluetoothHidVirtualUnplug(self.mac_addr)
+ except Exception as err:
+ self.log.info(FAILURE.format(cmd, err))
+
+ def do_hid_send_report(self, line):
+ """Get HID Report"""
+ cmd = "Get HID Report"
+ try:
+ self.pri_dut.droid.bluetoothHidSendData(device_id, "42")
+ except Exception as err:
+ self.log.info(FAILURE.format(cmd, err))
+
+ """End HID wrappers"""
diff --git a/acts/tests/google/bt/pts/gattc_lib.py b/acts/tests/google/bt/pts/gattc_lib.py
index 89718d6..23d58c7 100644
--- a/acts/tests/google/bt/pts/gattc_lib.py
+++ b/acts/tests/google/bt/pts/gattc_lib.py
@@ -21,6 +21,7 @@
from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection
from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu
from acts.test_utils.bt.GattEnum import GattCbStrings
+from acts.test_utils.bt.GattEnum import GattCharDesc
from acts.test_utils.bt.GattEnum import GattDescriptor
from acts.test_utils.bt.GattEnum import GattTransport
from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids
@@ -372,6 +373,32 @@
self.bluetooth_gatt, self.discovered_services_index, i, j)
time.sleep(1) # Necessary for PTS
+ def read_all_desc(self):
+ """GATT Client read all Descriptor values"""
+ self._setup_discovered_services_index()
+ services_count = self.dut.droid.gattClientGetDiscoveredServicesCount(
+ self.discovered_services_index)
+ for i in range(services_count):
+ characteristic_uuids = (
+ self.dut.droid.gattClientGetDiscoveredCharacteristicUuids(
+ self.discovered_services_index, i))
+ for j in range(len(characteristic_uuids)):
+ descriptor_uuids = (
+ self.dut.droid.
+ gattClientGetDiscoveredDescriptorUuidsByIndex(
+ self.discovered_services_index, i, j))
+ for k in range(len(descriptor_uuids)):
+ time.sleep(1)
+ try:
+ self.log.info("Reading descriptor {}".format(
+ descriptor_uuids[k]))
+ self.dut.droid.gattClientReadDescriptorByIndex(
+ self.bluetooth_gatt,
+ self.discovered_services_index, i, j, k)
+ except Exception as err:
+ self.log.info("Failed to read to descriptor: {}".
+ format(descriptor_uuids[k]))
+
def write_all_char(self, line):
"""Write to every Characteristic on the GATT server"""
args = line.split()
@@ -386,7 +413,6 @@
self.dut.droid.gattClientGetDiscoveredCharacteristicUuids(
self.discovered_services_index, i))
for j in range(len(characteristic_uuids)):
- time.sleep(1)
char_inst_id = self.dut.droid.gattClientGetCharacteristicInstanceId(
self.bluetooth_gatt, self.discovered_services_index, i, j)
self.log.info("Writing to {} {}".format(
@@ -445,4 +471,4 @@
if len(line) == 4:
uuid = self.generic_uuid.format(line)
self.dut.droid.gattClientDiscoverServiceByUuid(self.bluetooth_gatt,
- uuid)
\ No newline at end of file
+ uuid)