def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) device_name = "" device_list = self._api.bt_scan_devices() for devTmp in device_list: if devTmp.address == self._pars.device_to_check: device_name = devTmp.name if device_name == "": self._logger.debug( "BtCheckAdv: device {0} isn't advertising".format( self._pars.device_to_check)) else: self._logger.debug( "BtCheckAdv: device {0} is advertising (name={1})".format( self._pars.device_to_check, device_name)) context.set_info(self._pars.save_as, device_name)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ BtBase.run(self, context) if not isinstance(self._pars.timeout, int): msg = "Error parameter TIMEOUT is not integer : %s" % str( type(self._pars.timeout)) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) full_path = posixpath.join(self._device.multimedia_path, self._pars.filename) if self._pars.action_control == "START_PLAYER": self._api.start_a2dp_media_player(full_path, self._pars.timeout) elif self._pars.action_control == "STOP_PLAYER": self._api.stop_a2dp_media_player() elif self._pars.action_control in [ "PLAY", "PAUSE", "STOP", "NEXT_TRACK", "PREVIOUS_TRACK", "VOLUMEDOWN", "VOLUMEUP" ]: self._api.control_a2dp_media_player(self._pars.action_control) else: msg = "Error parameter ACTION_CONTROL is unknown : %s" % str( self._pars.action_control) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) service_name = str(self._pars.service_name) char_name = str(self._pars.characteristic_name) if self._pars.characteristic_format is None: data_type = "string" else: data_type = str(self._pars.characteristic_format) self._logger.info("Read characteristic {0} on service {1} with {2} format". format(char_name, service_name, data_type)) characteristic_value = self._api.bt_gatt_read_characteristic(service_name=service_name, char_name=char_name, data_type=data_type) context.set_info(self._pars.characteristic_value, str(characteristic_value)) self.ts_verdict_msg = "{0} stored as {1}".format(characteristic_value, self._pars.characteristic_value) self._logger.debug(self.ts_verdict_msg)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) service_name = str(self._pars.service_name) char_name = str(self._pars.characteristic_name) data = self._pars.data data_type = self._pars.data_type acknowledgement = self._pars.acknowledgement self._logger.info( "Write {0} on characteristic {1} on service {2} as {3} type". format(data, char_name, service_name, data_type)) self._api.bt_gatt_write_characteristic(service_name=service_name, char_name=char_name, data=data, data_type=data_type, acknowledgement=acknowledgement)
def __init__(self, tc_conf, global_conf, ts_conf, factory): """ Constructor """ BtBase.__init__(self, tc_conf, global_conf, ts_conf, factory) self._time_out = self._TIME_OUT_SECS
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ BtBase.run(self, context) if not isinstance(self._pars.timeout, int): msg = "Error parameter TIMEOUT is not integer : %s" % str( type(self._pars.timeout)) self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) button_list = split_and_strip(self._pars.buttons, ",") for key in button_list: if key not in ["PLAY", "PAUSE", "STOP", "FORWARD", "BACKWARD"]: msg = "Error parameter BUTTONS contains invalid value : %s" % key self._logger.error(msg) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, msg) full_path = posixpath.join(self._device.multimedia_path, \ self._pars.filename) self._api.avrcp_expect_buttons(self._pars.buttons, \ self._pars.timeout, \ full_path)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) service_name = str(self._pars.service_name) char_name = str(self._pars.characteristic_name) subscribe = self._pars.subscribe if subscribe: self._logger.info( "Subscribe to notification about characteristic {0} on service {1}" .format(char_name, service_name)) self._api.bt_gatt_subscribe_notification(service_name=service_name, char_name=char_name) elif not subscribe: self._logger.info( "Unsubscribe to notification about characteristic {0} on service {1}" .format(char_name, service_name)) self._api.bt_gatt_unsubscribe_notification( service_name=service_name, char_name=char_name)
def __init__(self, tc_conf, global_conf, ts_conf, factory): """ Constructor """ BtBase.__init__(self, tc_conf, global_conf, ts_conf, factory) if self._pars.timeout is None: self._pars.timeout = "3600"
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) mode = self._pars.mode.lower() self._api.set_bt_scanning(mode)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) self._api.trust_device(self._pars.bdaddr, self._pars.trust)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) power = self._pars.power.lower() self._api.set_bt_adapter_power(power)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ BtBase.run(self, context) self._api.set_bt_name(self._pars.name)
def __init__(self, tc_conf, global_conf, ts_conf, factory): """ Constructor """ BtBase.__init__(self, tc_conf, global_conf, ts_conf, factory) if not self._pars.buttons: self._pars.buttons = "" if self._pars.timeout is None: self._pars.timeout = "0"
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) self._api.bt_fota(self._pars.mac_address, self._pars.files_to_flash.split(';'), self._pars.timeout)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) iface = self._pars.iface mode = str(self._pars.mode).lower() self._api.set_ssp_mode(mode)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) # Collects arguments defaulting the non passed ones address = self._pars.bdaddr self._api.wait_for_disconnection(address)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) # Collects pairing arguments defaulting the non passed ones address = self._pars.bdaddr if self._pars.profile is not None: profile = self._pars.profile.lower() self._api.wait_for_connection(address, profile)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) # Collect arguments enable = self._pars.enable service = self._pars.service.lower() # Enable or disable service self._api.enable_service(enable, service)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) # Collects pairing arguments defaulting the non passed ones address = self._pars.bdaddr reconnect = "on" if self._pars.unpair_first == True else "off" pairing_reply = BTConst.DFLT_PAIRING_REPLY key = self._pars.pairing_reply.lower() if key in BTConst.PAIRING_REPLIES: pairing_reply = BTConst.PAIRING_REPLIES[key] pincode = self._pars.pin_code if self._pars.pin_code else "0000" passkey = self._pars.pass_key if self._pars.pass_key else 0 # Pair the DUT with the device pair_result = self._api.pair_to_device(address, reconnect, pairing_reply, pincode, passkey) if pair_result[0] == BT_BOND_STATE.BOND_NONE: if self._pars.paired: self._raise_device_exception("Pairing with device failed") else: return_msg = "Pairing with device rejected" self._ts_verdict_msg = return_msg self._logger.info(return_msg) return if pair_result[0] == BT_BOND_STATE.BOND_BONDED: if self._pars.paired: return_msg = "Pairing with device succeeded" self._ts_verdict_msg = return_msg self._logger.info(return_msg) return else: self._raise_device_exception( "Pairing with device succeeded but it should not") self._raise_device_exception( "Unknown bond state returned by the device")
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) if self._pars.timeout: self._time_out = self._pars.timeout config = PairingConfig(self._pars) self._api.wait_for_pairing(config.address, config.reconnect, config.accept, config.pincode, config.passkey, self._time_out)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) expected_timeout = self._pars.timeout # Get the BT current discoverable timeout discoverable_timeout = self._api.get_bt_discoverable_timeout() if discoverable_timeout != expected_timeout: self._raise_device_exception( "Expected %d discoverable timeout, got %d" % (discoverable_timeout, expected_timeout))
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) connected = False address = self._pars.bdaddr list_connected_devices = self._api.list_connected_device() for element in list_connected_devices: if str(element.address).upper() == str(address).upper(): connected = True break if not connected: self._raise_device_exception("Device %s is not connected" % address)
def run(self, context): """ Runs the test step @type context: TestStepContext @param context: test case context """ BtBase.run(self, context) assert self._pars.raise_error in [True, False], \ "RAISE_ERROR (%s) value should have been checked by the framework" % self._pars.raise_error try: scan_result = self._api.bt_scan_devices() if scan_result is None: msg = "Scan result is null" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) except DeviceException as acs_exception: if self._pars.raise_error is False: self._logger.debug( "Error/Timeout on scan devices - Exception ignored") else: raise acs_exception
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) # Collects pairing arguments defaulting the non passed ones address = self._pars.bdaddr reconnect = "on" if self._pars.unpair_first == True else "off" pairing_reply = BTConst.DFLT_PAIRING_REPLY key = self._pars.pairing_reply.lower() if key in BTConst.PAIRING_REPLIES: pairing_reply = BTConst.PAIRING_REPLIES[key] self._logger.debug("PAIRING_REPLY in TEST STEP: %s => %d" % (key, pairing_reply)) timeout = self._pars.timeout pincode = self._pars.pin_code if self._pars.pin_code else "0000" passkey = self._pars.pass_key if self._pars.pass_key else 0 # Wait for pairing request self._api.wait_for_pairing(address, reconnect, pairing_reply, pincode, passkey, timeout)
def run(self, context): """ Runs the test step :type context: TestStepContext :param context: test case context """ BtBase.run(self, context) service_name = str(self._pars.service_name) char_name = str(self._pars.characteristic_name) notif_type = None if self._pars.notification_type is not None: notif_type = str(self._pars.notification_type) time_lap = self._pars.time_lap notif_found = False self._logger.info("Retrieve notification about '{0}' characteristic on '{1}' service, until {2} minutes ago". format(char_name, service_name, time_lap)) notifications_list = self._api.bt_gatt_get_notification(service_name=service_name, char_name=char_name, time_lap=time_lap) if notifications_list is not None and len(notifications_list) > 0: index = 0 for i, notification in enumerate(notifications_list): if notif_type is not None: if notification.type != notif_type: self._logger.debug("Notification type is not {0} ({1}). Notification filtered". format(notif_type, notification.type)) continue notif_found = True index += 1 self._logger.debug("Notification saved as {0}:NOTIFICATION_{1}".format(self._pars.save_as, index)) key = "{0}:NOTIFICATION_{1}:{2}".format(self._pars.save_as, index, "DATE") value = notification.date context.set_info(key, value) self._logger.debug("{0} = {1}".format(key, value)) key = "{0}:NOTIFICATION_{1}:{2}".format(self._pars.save_as, index, "SERVICE") value = notification.service context.set_info(key, value) self._logger.debug("{0} = {1}".format(key, value)) key = "{0}:NOTIFICATION_{1}:{2}".format(self._pars.save_as, index, "CHARACTERISTIC") value = notification.characteristic context.set_info(key, value) self._logger.debug("{0} = {1}".format(key, value)) key = "{0}:NOTIFICATION_{1}:{2}".format(self._pars.save_as, index, "TYPE") value = notification.type context.set_info(key, value) self._logger.debug("{0} = {1}".format(key, value)) for data_tmp in notification.data: key = "{0}:NOTIFICATION_{1}:{2}".format(self._pars.save_as, index, data_tmp) value = notification.data[data_tmp] context.set_info(key, value) self._logger.debug("{0} = {1}".format(key, value)) if not notif_found: error_message = "No notification found on '{0}' characteristic".format(char_name) error_message += " in '{0}' service".format(service_name) if notif_type is not None: error_message += " with {0} type".format(notif_type) error_message += ", within {0} minutes. Result returned: ".format(time_lap) self._logger.debug(error_message) key = "{0}:NOTIFICATION_1:TYPE".format(self._pars.save_as) context.set_info(key, "not_found") self._logger.debug("{0} = {1}".format(key, "not_found"))
def __init__(self, tc_conf, global_conf, ts_conf, factory=None): """ Constructor """ BtBase.__init__(self, tc_conf, global_conf, ts_conf, factory)