Ejemplo n.º 1
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)

        if self._phone2 is None:
            msg = "PHONE2 is not specified in the bench configuration"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, msg)

        # Get original phone mode
        self._original_flight_mode2 = self._networking_api2.get_flight_mode()
        # Flight mode
        if self._use_flightmode != self._original_flight_mode2:
            self._networking_api2.set_flight_mode(self._use_flightmode)

        self._logger.info("Reset phone Bluetooth adapter")
        self._bt_api2.bt_reset_device()

        # Get phones address
        self._phone1_addr = self._bt_api.get_bt_adapter_address()
        self._phone2_addr = self._bt_api2.get_bt_adapter_address()

        return Global.SUCCESS, "No errors"
Ejemplo n.º 2
0
    def set_up(self):
        """
        Initialize the test
        """
        LabWifiIperf.set_up(self)
        LiveBTBase.set_up(self)

        # Check values
        if self._bt_play_music is not None and self._bt_play_music not in [
                "on", "off"
        ]:
            msg = "Bad value for BT_PLAY_MUSIC : %s" % self._bt_play_music
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Setup DUT for KPI TC
        LabWifiKPIBase.set_up(self)

        if self._bt_play_music == "on":
            LiveBTBase.set_up(self)
            # Configure Headset and launch audio
            self._bt_headset = self._em.get_bluetooth_headset("BT_HEADSET")
            self._bt_headset_addr = self._bt_headset.get_bdaddress()
            a2dp_pair_connect_to_headset(self._bt_api, self._bt_headset)
            a2dp_switch_music_state(self._bt_api, self._bt_headset,
                                    BtAudioCmd.PLAY)

        return Global.SUCCESS, "No errors"
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)

        self._bt_headset_addr = self._bt_headset.get_bdaddress()

        if self._ref_bt_addr.lower() in ["none", ""] and self._bench_config is not None:
            self._ref_bt_addr = str(self._bench_config.get_param_value("MacAddress"), "")

        if self._ref_bt_addr.lower() in ["none", "", "00:00:00:00:00:00"]:
            msg = "No BD address found in the TC and/or in bench_config"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_BENCH_CONFIG, msg)

        if not str(self._duration).isdigit():
            msg = "Bad value on duration parameter : %s" % self._duration
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        self._duration = int(self._duration)

        # Configure Headset
        a2dp_pair_connect_to_headset(self._bt_api, self._bt_headset)

        # Launch audio
        a2dp_switch_music_state(self._bt_api, self._bt_headset, BtAudioCmd.PLAY)

        return Global.SUCCESS, "No errors"
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)
        LiveWifiBase.set_up(self)

        # Connect BT to Headset
        a2dp_pair_connect_to_headset(self._bt_api, self._bt_headset)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 5
0
    def set_up(self):
        """
        Initialize the test
        """

        LiveBTBase.set_up(self)

        #locally initialize phone for PAN - turn tethering ON
        self._bt_api.set_bt_tethering_power("on")
        result, output = Global.SUCCESS, ""
        return result, output
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)

        if not str(self._duration).isdigit():
            msg = "Bad value on duration parameter : %s" % self._duration
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        self._duration = int(self._duration)

        self._networking_api.set_wifi_power(0)
        self._bt_api.set_bt_power(0)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 7
0
    def set_up(self):
        """
        Initialize the test
        """

        LiveBTBase.set_up(self)

        # set flight mode
        self._logger.info("set Device to normal mode")
        if self._networking_api.get_flight_mode():
            self._networking_api.set_flight_mode(0)
            time.sleep(self._wait_btwn_cmd)
            if self._networking_api.get_flight_mode():
                msg = "set to normal mode failure"
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        # pylint: disable=E1101
        # set BT mode
        if self._bt_mode.strip().lower() in ("on", "1"):
            # Already Powered On in LiveBTBase
            # Store BT power state
            self._initial_bt_state = self._bt_api.get_bt_power_status_eot()
            if self._initial_bt_state != str(BT_STATE.STATE_ON):
                msg = "set BT ON failure"
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        elif self._bt_mode.strip().lower() in ("off", "0"):
            self._logger.info("set BT mode to OFF")
            self._bt_api.set_bt_power("0")
            # Store BT power state
            self._initial_bt_state = self._bt_api.get_bt_power_status_eot()
            if self._initial_bt_state != str(BT_STATE.STATE_OFF):
                msg = "set BT OFF failure"
                self._logger.error(msg)
                raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            self._logger.info("Set wrong BT init mode")
            msg = "set wrong BT init mode, failed . alter bt_init_mode in "\
                + "test case xml file"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 8
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)
        LiveWifiBase.set_up(self)

        self._bt_headset_addr = self._bt_headset.get_bdaddress()

        if not str(self._duration).isdigit():
            msg = "Bad value on duration parameter : %s" % self._duration
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
        self._duration = int(self._duration)

        # Connect to BT Headset
        a2dp_pair_connect_to_headset(self._bt_api, self._bt_headset)

        # Launch audio
        a2dp_switch_music_state(self._bt_api, self._bt_headset, BtAudioCmd.PLAY)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 9
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)

        # Disable BT interface if required
        if self._bt_initial_state in ["OFF", "0", "FALSE", False]:
            self._bt_initial_state = False
            self._bt_api.set_bt_power("off")
            time.sleep(self._wait_btwn_cmd)
        else:
            # BT is enabled in LiveBTBase.set_up
            self._bt_initial_state = True

        # Verify BT tethering state after BT OFF/ON sequence
        # if BT OFF, tethering shall be also OFF
        pan_state = self._bt_api.get_bt_tethering_power()
        if not self._bt_initial_state and pan_state:
            msg = "BT Tethering shall be OFF when BT is OFF"
            self._logger.error(msg)
            raise DeviceException(DeviceException.INVALID_DEVICE_STATE, msg)
        elif self._bt_initial_state and self._tethering_reset and pan_state:
            msg = "BT Tethering shall be OFF after BT power OFF/ON sequence"
            self._logger.error(msg)
            raise DeviceException(DeviceException.INVALID_DEVICE_STATE, msg)
        elif self._bt_initial_state and not self._tethering_reset:
            msg = "BT Tethering reset state cannot be validated as previous state unknown"
            self._logger.info(msg)
            # ensure BT tethering is OFF
            self._bt_api.set_bt_tethering_power("0")
            time.sleep(self._wait_btwn_cmd)
        else:
            msg = "BT Tethering initial state is OFF"
            self._logger.info(msg)

        return Global.SUCCESS, "No errors"
Ejemplo n.º 10
0
    def set_up(self):
        """
        Initialize the test
        """
        LiveBTBase.set_up(self)

        # Check audio command list is not empty
        if (len(self._audiocmd_list) == 1
                and self._audiocmd_list[0].strip() == ""):
            msg = "MUSIC_CONTROL_SEQUENCE cannot be empty"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Check CONNECT_INITIATOR value is valid
        self._connector = self._connector.upper()
        if self._connector not in ("DUT", "HEADSET"):
            msg = "BAD CONNECT_INITIATOR value. only DUT or HEADSET expected"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Get Bluetooth instance
        self._bt_headset = self._em.get_bluetooth_headset("BT_HEADSET")

        # BD address of Headset
        self._hsaddr = self._bt_headset.get_bdaddress()

        if self._hsaddr.lower() in ["none", "", "00:00:00:00:00:00"]:
            msg = "No BD addr defined for BT HEADSET in bench_config"
            self._logger.error(msg)
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Check BT address validity
        if not NetworkingUtil.is_valid_mac_address(self._hsaddr):
            msg = "Wrong BD address for HEADSET [%s]" % self._hsaddr
            raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)

        # Initialize BT headset to OFF state
        self._init_headset_off()
        time.sleep(5)

        # In both case (connector DUT or HEADSET), DUT shall initiates pairing
        # Put HEADSET in pairing mode (HS shall be OFF prior to that step)
        self._logger.info("Set headset in pairable mode")
        self._bt_headset.set_discoverable()
        time.sleep(1)

        # DUT scan to discover remote headset
        if not self._bt_api.bt_find_device(self._hsaddr):
            msg = "Headset <%s> not found" % self._hsaddr
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        # DUT initiates pairing to headset
        pair_result = self._bt_api.pair_to_device(self._hsaddr, 1)

        # pylint: disable=E1101
        if pair_result[0] == BT_BOND_STATE.BOND_BONDED:
            msg = "Pairing with headset succeeded"
            self._logger.info(msg)
        elif pair_result[0] == BT_BOND_STATE.BOND_NONE:
            msg = "Pairing with headset failed"
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)
        else:
            msg = "[PHONE1]Unexpected return value %s" % pair_result
            self._logger.error(msg)
            raise DeviceException(DeviceException.OPERATION_FAILED, msg)

        if self._connector == "HEADSET":
            # If Initiator is HEADSET, DUT shall be discoverable
            self._bt_api.set_bt_discoverable("connectable", 0)

        return Global.SUCCESS, "No errors"