Loading system/blueberry/tests/gd_sl4a/lib/bt_constants.py +0 −269 Original line number Diff line number Diff line Loading @@ -60,7 +60,6 @@ adv_succ = "BleAdvertise{}onSuccess" bluetooth_off = "BluetoothStateChangedOff" bluetooth_on = "BluetoothStateChangedOn" mtu_changed = "GattConnect{}onMtuChanged" gatt_connection_state_change = "GattConnect{}onConnectionStateChange" advertising_set_started = "AdvertisingSet{}onAdvertisingSetStarted" advertising_set_stopped = "AdvertisingSet{}onAdvertisingSetStopped" advertising_set_on_own_address_read = "AdvertisingSet{}onOwnAddressRead" Loading Loading @@ -261,274 +260,6 @@ ble_advertise_error_code = { ### Bluetooth Low Energy Constants End ### ### Bluetooth GATT Constants Begin ### # Gatt Callback error messages gatt_cb_err = { "char_write_req_err": "Characteristic Write Request event not found. Expected {}", "char_write_err": "Characteristic Write event not found. Expected {}", "desc_write_req_err": "Descriptor Write Request event not found. Expected {}", "desc_write_err": "Descriptor Write event not found. Expected {}", "char_read_err": "Characteristic Read event not found. Expected {}", "char_read_req_err": "Characteristic Read Request not found. Expected {}", "desc_read_err": "Descriptor Read event not found. Expected {}", "desc_read_req_err": "Descriptor Read Request event not found. Expected {}", "rd_remote_rssi_err": "Read Remote RSSI event not found. Expected {}", "gatt_serv_disc_err": "GATT Services Discovered event not found. Expected {}", "serv_added_err": "Service Added event not found. Expected {}", "mtu_changed_err": "MTU Changed event not found. Expected {}", "mtu_serv_changed_err": "MTU Server Changed event not found. Expected {}", "gatt_conn_changed_err": "GATT Connection Changed event not found. Expected {}", "char_change_err": "GATT Characteristic Changed event not fond. Expected {}", "phy_read_err": "Phy Read event not fond. Expected {}", "phy_update_err": "Phy Update event not fond. Expected {}", "exec_write_err": "GATT Execute Write event not found. Expected {}" } # GATT callback strings as defined in GattClientFacade.java and # GattServerFacade.java implemented callbacks. gatt_cb_strings = { "char_write_req": "GattServer{}onCharacteristicWriteRequest", "exec_write": "GattServer{}onExecuteWrite", "char_write": "GattConnect{}onCharacteristicWrite", "desc_write_req": "GattServer{}onDescriptorWriteRequest", "desc_write": "GattConnect{}onDescriptorWrite", "char_read": "GattConnect{}onCharacteristicRead", "char_read_req": "GattServer{}onCharacteristicReadRequest", "desc_read": "GattConnect{}onDescriptorRead", "desc_read_req": "GattServer{}onDescriptorReadRequest", "rd_remote_rssi": "GattConnect{}onReadRemoteRssi", "gatt_serv_disc": "GattConnect{}onServicesDiscovered", "serv_added": "GattServer{}onServiceAdded", "mtu_changed": "GattConnect{}onMtuChanged", "mtu_serv_changed": "GattServer{}onMtuChanged", "gatt_conn_change": "GattConnect{}onConnectionStateChange", "char_change": "GattConnect{}onCharacteristicChanged", "phy_read": "GattConnect{}onPhyRead", "phy_update": "GattConnect{}onPhyUpdate", "serv_phy_read": "GattServer{}onPhyRead", "serv_phy_update": "GattServer{}onPhyUpdate", } # GATT event dictionary of expected callbacks and errors. gatt_event = { "char_write_req": { "evt": gatt_cb_strings["char_write_req"], "err": gatt_cb_err["char_write_req_err"] }, "exec_write": { "evt": gatt_cb_strings["exec_write"], "err": gatt_cb_err["exec_write_err"] }, "char_write": { "evt": gatt_cb_strings["char_write"], "err": gatt_cb_err["char_write_err"] }, "desc_write_req": { "evt": gatt_cb_strings["desc_write_req"], "err": gatt_cb_err["desc_write_req_err"] }, "desc_write": { "evt": gatt_cb_strings["desc_write"], "err": gatt_cb_err["desc_write_err"] }, "char_read": { "evt": gatt_cb_strings["char_read"], "err": gatt_cb_err["char_read_err"] }, "char_read_req": { "evt": gatt_cb_strings["char_read_req"], "err": gatt_cb_err["char_read_req_err"] }, "desc_read": { "evt": gatt_cb_strings["desc_read"], "err": gatt_cb_err["desc_read_err"] }, "desc_read_req": { "evt": gatt_cb_strings["desc_read_req"], "err": gatt_cb_err["desc_read_req_err"] }, "rd_remote_rssi": { "evt": gatt_cb_strings["rd_remote_rssi"], "err": gatt_cb_err["rd_remote_rssi_err"] }, "gatt_serv_disc": { "evt": gatt_cb_strings["gatt_serv_disc"], "err": gatt_cb_err["gatt_serv_disc_err"] }, "serv_added": { "evt": gatt_cb_strings["serv_added"], "err": gatt_cb_err["serv_added_err"] }, "mtu_changed": { "evt": gatt_cb_strings["mtu_changed"], "err": gatt_cb_err["mtu_changed_err"] }, "gatt_conn_change": { "evt": gatt_cb_strings["gatt_conn_change"], "err": gatt_cb_err["gatt_conn_changed_err"] }, "char_change": { "evt": gatt_cb_strings["char_change"], "err": gatt_cb_err["char_change_err"] }, "phy_read": { "evt": gatt_cb_strings["phy_read"], "err": gatt_cb_err["phy_read_err"] }, "phy_update": { "evt": gatt_cb_strings["phy_update"], "err": gatt_cb_err["phy_update_err"] }, "serv_phy_read": { "evt": gatt_cb_strings["serv_phy_read"], "err": gatt_cb_err["phy_read_err"] }, "serv_phy_update": { "evt": gatt_cb_strings["serv_phy_update"], "err": gatt_cb_err["phy_update_err"] } } # Matches constants of connection states defined in BluetoothGatt.java gatt_connection_state = {"disconnected": 0, "connecting": 1, "connected": 2, "disconnecting": 3, "closed": 4} # Matches constants of Bluetooth GATT Characteristic values as defined # in BluetoothGattCharacteristic.java gatt_characteristic = { "property_broadcast": 0x01, "property_read": 0x02, "property_write_no_response": 0x04, "property_write": 0x08, "property_notify": 0x10, "property_indicate": 0x20, "property_signed_write": 0x40, "property_extended_props": 0x80, "permission_read": 0x01, "permission_read_encrypted": 0x02, "permission_read_encrypted_mitm": 0x04, "permission_write": 0x10, "permission_write_encrypted": 0x20, "permission_write_encrypted_mitm": 0x40, "permission_write_signed": 0x80, "permission_write_signed_mitm": 0x100, "write_type_default": 0x02, "write_type_no_response": 0x01, "write_type_signed": 0x04, } # Matches constants of Bluetooth GATT Characteristic values as defined # in BluetoothGattDescriptor.java gatt_descriptor = { "enable_notification_value": [0x01, 0x00], "enable_indication_value": [0x02, 0x00], "disable_notification_value": [0x00, 0x00], "permission_read": 0x01, "permission_read_encrypted": 0x02, "permission_read_encrypted_mitm": 0x04, "permission_write": 0x10, "permission_write_encrypted": 0x20, "permission_write_encrypted_mitm": 0x40, "permission_write_signed": 0x80, "permission_write_signed_mitm": 0x100 } # https://www.bluetooth.com/specifications/gatt/descriptors gatt_char_desc_uuids = { "char_ext_props": '00002900-0000-1000-8000-00805f9b34fb', "char_user_desc": '00002901-0000-1000-8000-00805f9b34fb', "client_char_cfg": '00002902-0000-1000-8000-00805f9b34fb', "server_char_cfg": '00002903-0000-1000-8000-00805f9b34fb', "char_fmt_uuid": '00002904-0000-1000-8000-00805f9b34fb', "char_agreg_fmt": '00002905-0000-1000-8000-00805f9b34fb', "char_valid_range": '00002906-0000-1000-8000-00805f9b34fb', "external_report_reference": '00002907-0000-1000-8000-00805f9b34fb', "report_reference": '00002908-0000-1000-8000-00805f9b34fb' } # https://www.bluetooth.com/specifications/gatt/characteristics gatt_char_types = { "device_name": '00002a00-0000-1000-8000-00805f9b34fb', "appearance": '00002a01-0000-1000-8000-00805f9b34fb', "peripheral_priv_flag": '00002a02-0000-1000-8000-00805f9b34fb', "reconnection_address": '00002a03-0000-1000-8000-00805f9b34fb', "peripheral_pref_conn": '00002a04-0000-1000-8000-00805f9b34fb', "service_changed": '00002a05-0000-1000-8000-00805f9b34fb', "system_id": '00002a23-0000-1000-8000-00805f9b34fb', "model_number_string": '00002a24-0000-1000-8000-00805f9b34fb', "serial_number_string": '00002a25-0000-1000-8000-00805f9b34fb', "firmware_revision_string": '00002a26-0000-1000-8000-00805f9b34fb', "hardware_revision_string": '00002a27-0000-1000-8000-00805f9b34fb', "software_revision_string": '00002a28-0000-1000-8000-00805f9b34fb', "manufacturer_name_string": '00002a29-0000-1000-8000-00805f9b34fb', "pnp_id": '00002a50-0000-1000-8000-00805f9b34fb', } # Matches constants of Bluetooth GATT Characteristic values as defined # in BluetoothGattCharacteristic.java gatt_characteristic_value_format = { "string": 0x1, "byte": 0x2, "sint8": 0x21, "uint8": 0x11, "sint16": 0x22, "unit16": 0x12, "sint32": 0x24, "uint32": 0x14 } # Matches constants of Bluetooth Gatt Service types as defined in # BluetoothGattService.java gatt_service_types = {"primary": 0, "secondary": 1} # Matches constants of Bluetooth Gatt Connection Priority values as defined in # BluetoothGatt.java gatt_connection_priority = {"balanced": 0, "high": 1, "low_power": 2} # Min and max MTU values gatt_mtu_size = {"min": 23, "max": 217} # Gatt Characteristic attribute lengths gatt_characteristic_attr_length = {"attr_1": 1, "attr_2": 3, "attr_3": 15} # Matches constants of Bluetooth Gatt operations status as defined in # BluetoothGatt.java gatt_status = {"success": 0, "failure": 0x101} # Matches constants of Bluetooth transport values as defined in # BluetoothDevice.java gatt_transport = {"auto": 0x00, "bredr": 0x01, "le": 0x02} # Matches constants of Bluetooth physical channeling values as defined in # BluetoothDevice.java gatt_phy = {"1m": 1, "2m": 2, "le_coded": 3} # Matches constants of Bluetooth physical channeling bitmask values as defined # in BluetoothDevice.java gatt_phy_mask = {"1m_mask": 1, "2m_mask": 2, "coded_mask": 4} # Values as defiend in the Bluetooth GATT specification gatt_server_responses = { "GATT_SUCCESS": 0x0, "GATT_FAILURE": 0x1, "GATT_READ_NOT_PERMITTED": 0x2, "GATT_WRITE_NOT_PERMITTED": 0x3, "GATT_INVALID_PDU": 0x4, "GATT_INSUFFICIENT_AUTHENTICATION": 0x5, "GATT_REQUEST_NOT_SUPPORTED": 0x6, "GATT_INVALID_OFFSET": 0x7, "GATT_INSUFFICIENT_AUTHORIZATION": 0x8, "GATT_INVALID_ATTRIBUTE_LENGTH": 0xd, "GATT_INSUFFICIENT_ENCRYPTION": 0xf, "GATT_CONNECTION_CONGESTED": 0x8f, "GATT_13_ERR": 0x13, "GATT_12_ERR": 0x12, "GATT_0C_ERR": 0x0C, "GATT_16": 0x16 } ### Bluetooth GATT Constants End ### ### Chameleon Constants Begin ### # Chameleon audio bits per sample. Loading system/blueberry/tests/gd_sl4a/lib/gd_sl4a_base_test.py +6 −19 Original line number Diff line number Diff line Loading @@ -26,11 +26,9 @@ from mobly.base_test import BaseTestClass from mobly.controllers.android_device_lib.adb import AdbError from mobly.controllers import android_device from mobly.controllers.android_device import MOBLY_CONTROLLER_CONFIG_NAME as ANDROID_DEVICE_COFNIG_NAME from mobly.controllers.android_device_lib.jsonrpc_client_base import \ AppRestoreConnectionError from mobly.controllers.android_device_lib.services.sl4a_service import Sl4aService import mobly.controllers.android_device_lib.sl4a_client as sl4a_client from blueberry.utils.mobly_sl4a_utils import setup_sl4a from blueberry.utils.mobly_sl4a_utils import teardown_sl4a from blueberry.tests.gd.cert.context import get_current_context from blueberry.tests.gd.cert.gd_device import MOBLY_CONTROLLER_CONFIG_NAME as GD_DEVICE_CONFIG_NAME from blueberry.tests.gd_sl4a.lib.ble_lib import enable_bluetooth, disable_bluetooth, BleLib Loading @@ -54,25 +52,14 @@ class GdSl4aBaseTestClass(BaseTestClass): self.cert = self.gd_devices[0] # Parse and construct Android device objects self.android_devices = self.register_controller(android_device, required=True) server_port = int(self.controller_configs[ANDROID_DEVICE_COFNIG_NAME][0]['server_port']) forwarded_port = int(self.controller_configs[ANDROID_DEVICE_COFNIG_NAME][0]['forwarded_port']) sl4a_client._DEVICE_SIDE_PORT = server_port sl4a_client._APP_START_WAIT_TIME = 0.5 self.android_devices = self.register_controller(android_device, required=True) self.dut = self.android_devices[0] self.dut.services.register('sl4a', Sl4aService, start_service=False) try: self.dut.sl4a.start() except AppRestoreConnectionError: pass try: self.dut.sl4a.clear_host_port() except AdbError: pass sl4a_client._APP_START_WAIT_TIME = 2 * 60 self.dut.sl4a.restore_app_connection(port=forwarded_port) setup_sl4a(self.dut, server_port, forwarded_port) # Enable full btsnoop log self.dut.adb.root() self.dut.adb.shell("setprop persist.bluetooth.btsnooplogmode full") getprop_result = self.dut.adb.shell("getprop persist.bluetooth.btsnooplogmode") == "full" if not getprop_result: Loading @@ -81,7 +68,7 @@ class GdSl4aBaseTestClass(BaseTestClass): self.ble = BleLib(dut=self.dut) def teardown_class(self): pass teardown_sl4a(self.dut) def setup_test(self): self.cert.rootservice.StartStack( Loading Loading
system/blueberry/tests/gd_sl4a/lib/bt_constants.py +0 −269 Original line number Diff line number Diff line Loading @@ -60,7 +60,6 @@ adv_succ = "BleAdvertise{}onSuccess" bluetooth_off = "BluetoothStateChangedOff" bluetooth_on = "BluetoothStateChangedOn" mtu_changed = "GattConnect{}onMtuChanged" gatt_connection_state_change = "GattConnect{}onConnectionStateChange" advertising_set_started = "AdvertisingSet{}onAdvertisingSetStarted" advertising_set_stopped = "AdvertisingSet{}onAdvertisingSetStopped" advertising_set_on_own_address_read = "AdvertisingSet{}onOwnAddressRead" Loading Loading @@ -261,274 +260,6 @@ ble_advertise_error_code = { ### Bluetooth Low Energy Constants End ### ### Bluetooth GATT Constants Begin ### # Gatt Callback error messages gatt_cb_err = { "char_write_req_err": "Characteristic Write Request event not found. Expected {}", "char_write_err": "Characteristic Write event not found. Expected {}", "desc_write_req_err": "Descriptor Write Request event not found. Expected {}", "desc_write_err": "Descriptor Write event not found. Expected {}", "char_read_err": "Characteristic Read event not found. Expected {}", "char_read_req_err": "Characteristic Read Request not found. Expected {}", "desc_read_err": "Descriptor Read event not found. Expected {}", "desc_read_req_err": "Descriptor Read Request event not found. Expected {}", "rd_remote_rssi_err": "Read Remote RSSI event not found. Expected {}", "gatt_serv_disc_err": "GATT Services Discovered event not found. Expected {}", "serv_added_err": "Service Added event not found. Expected {}", "mtu_changed_err": "MTU Changed event not found. Expected {}", "mtu_serv_changed_err": "MTU Server Changed event not found. Expected {}", "gatt_conn_changed_err": "GATT Connection Changed event not found. Expected {}", "char_change_err": "GATT Characteristic Changed event not fond. Expected {}", "phy_read_err": "Phy Read event not fond. Expected {}", "phy_update_err": "Phy Update event not fond. Expected {}", "exec_write_err": "GATT Execute Write event not found. Expected {}" } # GATT callback strings as defined in GattClientFacade.java and # GattServerFacade.java implemented callbacks. gatt_cb_strings = { "char_write_req": "GattServer{}onCharacteristicWriteRequest", "exec_write": "GattServer{}onExecuteWrite", "char_write": "GattConnect{}onCharacteristicWrite", "desc_write_req": "GattServer{}onDescriptorWriteRequest", "desc_write": "GattConnect{}onDescriptorWrite", "char_read": "GattConnect{}onCharacteristicRead", "char_read_req": "GattServer{}onCharacteristicReadRequest", "desc_read": "GattConnect{}onDescriptorRead", "desc_read_req": "GattServer{}onDescriptorReadRequest", "rd_remote_rssi": "GattConnect{}onReadRemoteRssi", "gatt_serv_disc": "GattConnect{}onServicesDiscovered", "serv_added": "GattServer{}onServiceAdded", "mtu_changed": "GattConnect{}onMtuChanged", "mtu_serv_changed": "GattServer{}onMtuChanged", "gatt_conn_change": "GattConnect{}onConnectionStateChange", "char_change": "GattConnect{}onCharacteristicChanged", "phy_read": "GattConnect{}onPhyRead", "phy_update": "GattConnect{}onPhyUpdate", "serv_phy_read": "GattServer{}onPhyRead", "serv_phy_update": "GattServer{}onPhyUpdate", } # GATT event dictionary of expected callbacks and errors. gatt_event = { "char_write_req": { "evt": gatt_cb_strings["char_write_req"], "err": gatt_cb_err["char_write_req_err"] }, "exec_write": { "evt": gatt_cb_strings["exec_write"], "err": gatt_cb_err["exec_write_err"] }, "char_write": { "evt": gatt_cb_strings["char_write"], "err": gatt_cb_err["char_write_err"] }, "desc_write_req": { "evt": gatt_cb_strings["desc_write_req"], "err": gatt_cb_err["desc_write_req_err"] }, "desc_write": { "evt": gatt_cb_strings["desc_write"], "err": gatt_cb_err["desc_write_err"] }, "char_read": { "evt": gatt_cb_strings["char_read"], "err": gatt_cb_err["char_read_err"] }, "char_read_req": { "evt": gatt_cb_strings["char_read_req"], "err": gatt_cb_err["char_read_req_err"] }, "desc_read": { "evt": gatt_cb_strings["desc_read"], "err": gatt_cb_err["desc_read_err"] }, "desc_read_req": { "evt": gatt_cb_strings["desc_read_req"], "err": gatt_cb_err["desc_read_req_err"] }, "rd_remote_rssi": { "evt": gatt_cb_strings["rd_remote_rssi"], "err": gatt_cb_err["rd_remote_rssi_err"] }, "gatt_serv_disc": { "evt": gatt_cb_strings["gatt_serv_disc"], "err": gatt_cb_err["gatt_serv_disc_err"] }, "serv_added": { "evt": gatt_cb_strings["serv_added"], "err": gatt_cb_err["serv_added_err"] }, "mtu_changed": { "evt": gatt_cb_strings["mtu_changed"], "err": gatt_cb_err["mtu_changed_err"] }, "gatt_conn_change": { "evt": gatt_cb_strings["gatt_conn_change"], "err": gatt_cb_err["gatt_conn_changed_err"] }, "char_change": { "evt": gatt_cb_strings["char_change"], "err": gatt_cb_err["char_change_err"] }, "phy_read": { "evt": gatt_cb_strings["phy_read"], "err": gatt_cb_err["phy_read_err"] }, "phy_update": { "evt": gatt_cb_strings["phy_update"], "err": gatt_cb_err["phy_update_err"] }, "serv_phy_read": { "evt": gatt_cb_strings["serv_phy_read"], "err": gatt_cb_err["phy_read_err"] }, "serv_phy_update": { "evt": gatt_cb_strings["serv_phy_update"], "err": gatt_cb_err["phy_update_err"] } } # Matches constants of connection states defined in BluetoothGatt.java gatt_connection_state = {"disconnected": 0, "connecting": 1, "connected": 2, "disconnecting": 3, "closed": 4} # Matches constants of Bluetooth GATT Characteristic values as defined # in BluetoothGattCharacteristic.java gatt_characteristic = { "property_broadcast": 0x01, "property_read": 0x02, "property_write_no_response": 0x04, "property_write": 0x08, "property_notify": 0x10, "property_indicate": 0x20, "property_signed_write": 0x40, "property_extended_props": 0x80, "permission_read": 0x01, "permission_read_encrypted": 0x02, "permission_read_encrypted_mitm": 0x04, "permission_write": 0x10, "permission_write_encrypted": 0x20, "permission_write_encrypted_mitm": 0x40, "permission_write_signed": 0x80, "permission_write_signed_mitm": 0x100, "write_type_default": 0x02, "write_type_no_response": 0x01, "write_type_signed": 0x04, } # Matches constants of Bluetooth GATT Characteristic values as defined # in BluetoothGattDescriptor.java gatt_descriptor = { "enable_notification_value": [0x01, 0x00], "enable_indication_value": [0x02, 0x00], "disable_notification_value": [0x00, 0x00], "permission_read": 0x01, "permission_read_encrypted": 0x02, "permission_read_encrypted_mitm": 0x04, "permission_write": 0x10, "permission_write_encrypted": 0x20, "permission_write_encrypted_mitm": 0x40, "permission_write_signed": 0x80, "permission_write_signed_mitm": 0x100 } # https://www.bluetooth.com/specifications/gatt/descriptors gatt_char_desc_uuids = { "char_ext_props": '00002900-0000-1000-8000-00805f9b34fb', "char_user_desc": '00002901-0000-1000-8000-00805f9b34fb', "client_char_cfg": '00002902-0000-1000-8000-00805f9b34fb', "server_char_cfg": '00002903-0000-1000-8000-00805f9b34fb', "char_fmt_uuid": '00002904-0000-1000-8000-00805f9b34fb', "char_agreg_fmt": '00002905-0000-1000-8000-00805f9b34fb', "char_valid_range": '00002906-0000-1000-8000-00805f9b34fb', "external_report_reference": '00002907-0000-1000-8000-00805f9b34fb', "report_reference": '00002908-0000-1000-8000-00805f9b34fb' } # https://www.bluetooth.com/specifications/gatt/characteristics gatt_char_types = { "device_name": '00002a00-0000-1000-8000-00805f9b34fb', "appearance": '00002a01-0000-1000-8000-00805f9b34fb', "peripheral_priv_flag": '00002a02-0000-1000-8000-00805f9b34fb', "reconnection_address": '00002a03-0000-1000-8000-00805f9b34fb', "peripheral_pref_conn": '00002a04-0000-1000-8000-00805f9b34fb', "service_changed": '00002a05-0000-1000-8000-00805f9b34fb', "system_id": '00002a23-0000-1000-8000-00805f9b34fb', "model_number_string": '00002a24-0000-1000-8000-00805f9b34fb', "serial_number_string": '00002a25-0000-1000-8000-00805f9b34fb', "firmware_revision_string": '00002a26-0000-1000-8000-00805f9b34fb', "hardware_revision_string": '00002a27-0000-1000-8000-00805f9b34fb', "software_revision_string": '00002a28-0000-1000-8000-00805f9b34fb', "manufacturer_name_string": '00002a29-0000-1000-8000-00805f9b34fb', "pnp_id": '00002a50-0000-1000-8000-00805f9b34fb', } # Matches constants of Bluetooth GATT Characteristic values as defined # in BluetoothGattCharacteristic.java gatt_characteristic_value_format = { "string": 0x1, "byte": 0x2, "sint8": 0x21, "uint8": 0x11, "sint16": 0x22, "unit16": 0x12, "sint32": 0x24, "uint32": 0x14 } # Matches constants of Bluetooth Gatt Service types as defined in # BluetoothGattService.java gatt_service_types = {"primary": 0, "secondary": 1} # Matches constants of Bluetooth Gatt Connection Priority values as defined in # BluetoothGatt.java gatt_connection_priority = {"balanced": 0, "high": 1, "low_power": 2} # Min and max MTU values gatt_mtu_size = {"min": 23, "max": 217} # Gatt Characteristic attribute lengths gatt_characteristic_attr_length = {"attr_1": 1, "attr_2": 3, "attr_3": 15} # Matches constants of Bluetooth Gatt operations status as defined in # BluetoothGatt.java gatt_status = {"success": 0, "failure": 0x101} # Matches constants of Bluetooth transport values as defined in # BluetoothDevice.java gatt_transport = {"auto": 0x00, "bredr": 0x01, "le": 0x02} # Matches constants of Bluetooth physical channeling values as defined in # BluetoothDevice.java gatt_phy = {"1m": 1, "2m": 2, "le_coded": 3} # Matches constants of Bluetooth physical channeling bitmask values as defined # in BluetoothDevice.java gatt_phy_mask = {"1m_mask": 1, "2m_mask": 2, "coded_mask": 4} # Values as defiend in the Bluetooth GATT specification gatt_server_responses = { "GATT_SUCCESS": 0x0, "GATT_FAILURE": 0x1, "GATT_READ_NOT_PERMITTED": 0x2, "GATT_WRITE_NOT_PERMITTED": 0x3, "GATT_INVALID_PDU": 0x4, "GATT_INSUFFICIENT_AUTHENTICATION": 0x5, "GATT_REQUEST_NOT_SUPPORTED": 0x6, "GATT_INVALID_OFFSET": 0x7, "GATT_INSUFFICIENT_AUTHORIZATION": 0x8, "GATT_INVALID_ATTRIBUTE_LENGTH": 0xd, "GATT_INSUFFICIENT_ENCRYPTION": 0xf, "GATT_CONNECTION_CONGESTED": 0x8f, "GATT_13_ERR": 0x13, "GATT_12_ERR": 0x12, "GATT_0C_ERR": 0x0C, "GATT_16": 0x16 } ### Bluetooth GATT Constants End ### ### Chameleon Constants Begin ### # Chameleon audio bits per sample. Loading
system/blueberry/tests/gd_sl4a/lib/gd_sl4a_base_test.py +6 −19 Original line number Diff line number Diff line Loading @@ -26,11 +26,9 @@ from mobly.base_test import BaseTestClass from mobly.controllers.android_device_lib.adb import AdbError from mobly.controllers import android_device from mobly.controllers.android_device import MOBLY_CONTROLLER_CONFIG_NAME as ANDROID_DEVICE_COFNIG_NAME from mobly.controllers.android_device_lib.jsonrpc_client_base import \ AppRestoreConnectionError from mobly.controllers.android_device_lib.services.sl4a_service import Sl4aService import mobly.controllers.android_device_lib.sl4a_client as sl4a_client from blueberry.utils.mobly_sl4a_utils import setup_sl4a from blueberry.utils.mobly_sl4a_utils import teardown_sl4a from blueberry.tests.gd.cert.context import get_current_context from blueberry.tests.gd.cert.gd_device import MOBLY_CONTROLLER_CONFIG_NAME as GD_DEVICE_CONFIG_NAME from blueberry.tests.gd_sl4a.lib.ble_lib import enable_bluetooth, disable_bluetooth, BleLib Loading @@ -54,25 +52,14 @@ class GdSl4aBaseTestClass(BaseTestClass): self.cert = self.gd_devices[0] # Parse and construct Android device objects self.android_devices = self.register_controller(android_device, required=True) server_port = int(self.controller_configs[ANDROID_DEVICE_COFNIG_NAME][0]['server_port']) forwarded_port = int(self.controller_configs[ANDROID_DEVICE_COFNIG_NAME][0]['forwarded_port']) sl4a_client._DEVICE_SIDE_PORT = server_port sl4a_client._APP_START_WAIT_TIME = 0.5 self.android_devices = self.register_controller(android_device, required=True) self.dut = self.android_devices[0] self.dut.services.register('sl4a', Sl4aService, start_service=False) try: self.dut.sl4a.start() except AppRestoreConnectionError: pass try: self.dut.sl4a.clear_host_port() except AdbError: pass sl4a_client._APP_START_WAIT_TIME = 2 * 60 self.dut.sl4a.restore_app_connection(port=forwarded_port) setup_sl4a(self.dut, server_port, forwarded_port) # Enable full btsnoop log self.dut.adb.root() self.dut.adb.shell("setprop persist.bluetooth.btsnooplogmode full") getprop_result = self.dut.adb.shell("getprop persist.bluetooth.btsnooplogmode") == "full" if not getprop_result: Loading @@ -81,7 +68,7 @@ class GdSl4aBaseTestClass(BaseTestClass): self.ble = BleLib(dut=self.dut) def teardown_class(self): pass teardown_sl4a(self.dut) def setup_test(self): self.cert.rootservice.StartStack( Loading