diff options
author | Jakub Pawlowski <jpawlowski@google.com> | 2016-07-12 04:46:08 -0700 |
---|---|---|
committer | tturney <tturney@google.com> | 2016-07-12 10:51:30 -0700 |
commit | e593e58b9f1d1ad62d203ee5aebb5c10ed046537 (patch) | |
tree | 8abfe55ba1f374d7b926fc8eed6f459835142fe4 | |
parent | 69cab4ef28619ea66d2b4aea4a1a1a6fcda81206 (diff) | |
download | platform_tools_test_connectivity-e593e58b9f1d1ad62d203ee5aebb5c10ed046537.tar.gz platform_tools_test_connectivity-e593e58b9f1d1ad62d203ee5aebb5c10ed046537.tar.bz2 platform_tools_test_connectivity-e593e58b9f1d1ad62d203ee5aebb5c10ed046537.zip |
Fix GattOverBrEdrTest
Btsnoop log analysis showed that connection attempt was made over LE
transport. Use connectGatt with transport specifier to make sure classic
transport is used.
GattTransport is using IntEnum instead of regular Enum type. Thanks to
it we don't have to do ".value" at every occurence.
Bug: 29777301
Change-Id: I2fb30d3e0dd429535655859c16016642a293fe96
-rw-r--r-- | acts/framework/acts/test_utils/bt/GattEnum.py | 8 | ||||
-rw-r--r-- | acts/framework/acts/test_utils/bt/bt_gatt_utils.py | 12 | ||||
-rw-r--r-- | acts/tests/google/ble/gatt/GattConnectTest.py | 3 | ||||
-rw-r--r-- | acts/tests/google/bt/gatt/GattOverBrEdrTest.py | 33 |
4 files changed, 38 insertions, 18 deletions
diff --git a/acts/framework/acts/test_utils/bt/GattEnum.py b/acts/framework/acts/test_utils/bt/GattEnum.py index 6b512bc34a..b08f82b483 100644 --- a/acts/framework/acts/test_utils/bt/GattEnum.py +++ b/acts/framework/acts/test_utils/bt/GattEnum.py @@ -15,7 +15,7 @@ # the License. from enum import Enum - +from enum import IntEnum class GattCbErr(Enum): CHAR_WRITE_REQ_ERR = "Characteristic Write Request event not found. Expected {}" @@ -155,3 +155,9 @@ class MtuSize(Enum): class BluetoothGatt(Enum): GATT_SUCCESS = 0 GATT_FAILURE = 0x101 + + +class GattTransport(IntEnum): + TRANSPORT_AUTO = 0x00 + TRANSPORT_BREDR = 0x01 + TRANSPORT_LE = 0x02
\ No newline at end of file diff --git a/acts/framework/acts/test_utils/bt/bt_gatt_utils.py b/acts/framework/acts/test_utils/bt/bt_gatt_utils.py index bef916dd83..57555d10d5 100644 --- a/acts/framework/acts/test_utils/bt/bt_gatt_utils.py +++ b/acts/framework/acts/test_utils/bt/bt_gatt_utils.py @@ -24,6 +24,7 @@ from acts.test_utils.bt.GattEnum import GattConnectionState from acts.test_utils.bt.GattEnum import GattCharacteristic from acts.test_utils.bt.GattEnum import GattDescriptor from acts.test_utils.bt.GattEnum import GattService +from acts.test_utils.bt.GattEnum import GattTransport from acts.test_utils.bt.GattEnum import GattConnectionPriority import pprint from queue import Empty @@ -37,12 +38,13 @@ class GattTestUtilsError(Exception): pass -def setup_gatt_connection(cen_ad, mac_address, autoconnect): +def setup_gatt_connection(cen_ad, mac_address, autoconnect, + transport=GattTransport.TRANSPORT_AUTO): test_result = True gatt_callback = cen_ad.droid.gattCreateGattCallback() log.info("Gatt Connect to mac address {}.".format(mac_address)) bluetooth_gatt = cen_ad.droid.gattClientConnectGatt( - gatt_callback, mac_address, autoconnect) + gatt_callback, mac_address, autoconnect, transport) expected_event = GattCbStrings.GATT_CONN_CHANGE.value.format(gatt_callback) try: event = cen_ad.ed.pop_event(expected_event, default_timeout) @@ -72,12 +74,12 @@ def disconnect_gatt_connection(cen_ad, bluetooth_gatt, gatt_callback): def orchestrate_gatt_connection(cen_ad, per_ad, - le=True, + transport=GattTransport.TRANSPORT_LE, mac_address=None, autoconnect=False): adv_callback = None if mac_address is None: - if le: + if transport == GattTransport.TRANSPORT_LE: try: mac_address, adv_callback = ( get_mac_address_of_generic_advertisement(cen_ad, per_ad)) @@ -87,7 +89,7 @@ def orchestrate_gatt_connection(cen_ad, mac_address = per_ad.droid.bluetoothGetLocalAddress() adv_callback = None test_result, bluetooth_gatt, gatt_callback = setup_gatt_connection( - cen_ad, mac_address, autoconnect) + cen_ad, mac_address, autoconnect, transport) if not test_result: raise GattTestUtilsError("Could not connect to peripheral.") return bluetooth_gatt, gatt_callback, adv_callback diff --git a/acts/tests/google/ble/gatt/GattConnectTest.py b/acts/tests/google/ble/gatt/GattConnectTest.py index 07a057739c..02046e0073 100644 --- a/acts/tests/google/ble/gatt/GattConnectTest.py +++ b/acts/tests/google/ble/gatt/GattConnectTest.py @@ -30,6 +30,7 @@ from acts.test_utils.bt.GattEnum import MtuSize from acts.test_utils.bt.GattEnum import GattCbErr from acts.test_utils.bt.GattEnum import GattCbStrings from acts.test_utils.bt.GattEnum import GattConnectionPriority +from acts.test_utils.bt.GattEnum import GattTransport from acts.test_utils.bt.bt_gatt_utils import GattTestUtilsError from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection from acts.test_utils.bt.bt_gatt_utils import orchestrate_gatt_connection @@ -261,7 +262,7 @@ class GattConnectTest(BluetoothBaseTest): return False autoconnect = True bluetooth_gatt = self.cen_ad.droid.gattClientConnectGatt( - gatt_callback, mac_address, autoconnect) + gatt_callback, mac_address, autoconnect, GattTransport.TRANSPORT_AUTO) expected_event = GattCbStrings.GATT_CONN_CHANGE.value.format( gatt_callback) try: diff --git a/acts/tests/google/bt/gatt/GattOverBrEdrTest.py b/acts/tests/google/bt/gatt/GattOverBrEdrTest.py index 0f1d9d6420..b856d1034b 100644 --- a/acts/tests/google/bt/gatt/GattOverBrEdrTest.py +++ b/acts/tests/google/bt/gatt/GattOverBrEdrTest.py @@ -24,6 +24,7 @@ from acts.test_utils.bt.bt_test_utils import reset_bluetooth from acts.test_utils.bt.GattEnum import GattCharacteristic from acts.test_utils.bt.GattEnum import GattDescriptor from acts.test_utils.bt.GattEnum import GattService +from acts.test_utils.bt.GattEnum import GattTransport from acts.test_utils.bt.GattEnum import MtuSize from acts.test_utils.bt.GattEnum import GattCbStrings from acts.test_utils.bt.bt_gatt_utils import GattTestUtilsError @@ -211,7 +212,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): """ try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -249,7 +251,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): """ try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -294,7 +297,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): """ try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -340,7 +344,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): """ try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -388,7 +393,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): """ try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -428,7 +434,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): """ try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -476,7 +483,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): """ try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -523,7 +531,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): return False try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -570,7 +579,7 @@ class GattOverBrEdrTest(BluetoothBaseTest): try: bluetooth_gatt, gatt_callback, adv_callback = ( orchestrate_gatt_connection(self.cen_ad, self.per_ad, - False, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -615,7 +624,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): return False try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False @@ -741,7 +751,8 @@ class GattOverBrEdrTest(BluetoothBaseTest): return False try: bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad, False, + orchestrate_gatt_connection(self.cen_ad, self.per_ad, + GattTransport.TRANSPORT_BREDR, self.per_droid_mac_address)) except GattTestUtilsError: return False |