def run(self, context): """ This test step will fail if at any point an error occurred and the advertising could not be started :param context: :return: """ advertise_mode = BleBase.check_advertise_mode_valid( self, self._pars.advertise_mode) tx_power_level = BleBase.check_tx_power_level_valid( self, self._pars.tx_power_level) advertise_code = BleBase.check_advertise_code_valid( self, self._pars.advertise_code) BleBase.run(self, context) if (advertise_mode is not False) and (tx_power_level is not False): self._api.ble_start_advertising(tx_power_level, advertise_mode, advertise_code, self._pars.is_connectable, self._pars.advertise_timeout) else: msg = "You have not provided a valid code for ADVERTISE_MODE and/or TX_POWER_LEVEL" \ "and/or ADVERTISE_CODE:" \ "advertiseMode: %s tx_power_level: %s advertiseCode: %s" % \ (str(advertise_mode), str(tx_power_level), str(advertise_code)) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ If the result contains 4 different found advertisements, then the result is PASS. Any different and it means that the advertisement is not being sent or read correctly :param context: :return: """ scan_mode = BleBase.check_scan_mode_valid(self, self._pars.scan_mode) BleBase.run(self, context) if scan_mode is not False: broadcasted_instances = self._api.ble_scan_advertising_power_levels(scan_mode, self._pars.timeout) else: msg = "You have not provided a valid code for ADVERTISE_MODE" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) if not broadcasted_instances: msg = "No broadcast was observed" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) count_advertised_instances = len(broadcasted_instances) if count_advertised_instances != 4: msg = "There should be 4 different addresses advertised for each power level, actual count is: " +\ str(count_advertised_instances) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) for instance in broadcasted_instances: self._logger.debug("Found broadcast result: " + instance.to_string())
def run(self, context): """ This test step will fail if at any point an error occurred and the advertising could not be started or the server was not created properly :param context: :return: """ advertise_mode = BleBase.check_advertise_mode_valid( self, self._pars.advertise_mode) tx_power_level = BleBase.check_tx_power_level_valid( self, self._pars.tx_power_level) gatt_server_type = BleBase.check_gatt_server_type( self, self._pars.gatt_server_type) BleBase.run(self, context) if (advertise_mode is not False) and (tx_power_level is not False) and (gatt_server_type is not False): output = self._api.ble_gatt_advertise_server( tx_power_level, advertise_mode, self._pars.advertise_timeout, gatt_server_type) self._logger.debug(output) else: msg = "You have not provided a valid code for ADVERTISE_MODE and/or TX_POWER_LEVEL and/or GATT_SERVER_TYPE" \ " advertiseMode: %s tx_power_level: %s gatt_server_type: %s" % \ (str(advertise_mode), str(tx_power_level), str(gatt_server_type)) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ If no device is returned by the Agent filtered search, the the operation has failed :param context: :return: """ scan_mode = BleBase.check_scan_mode_valid(self, self._pars.scan_mode) BleBase.run(self, context) if scan_mode is not False: bluetooth_device = self._api.ble_scan_filter_service_data( self._pars.service_uuid, scan_mode, self._pars.timeout) else: msg = "You have not provided a valid code for SCAN_MODE" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) if not bluetooth_device: msg = "No device was found using the name filter: " + str( self._pars.remote_name) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) self._logger.debug("Found device: " + str(bluetooth_device.name) + " " + str(bluetooth_device.address))
def run(self, context): """ This test step will fail if at any point an error occurred and the broadcast could not be stopped :param context: :return: """ BleBase.run(self, context) self._api.ble_stop_beacon_broadcast()
def run(self, context): """ If the connection was unsuccessful, the test step will fail :param context: :return: """ BleBase.run(self, context) output = self._api.ble_gatt_client_connect_to_server(self._pars.address) self._logger.debug(output)
def run(self, context): """ If the characteristic cannot be read, the the operation has failed :param context: :return: """ BleBase.run(self, context) output = self._api.ble_gatt_client_read_characteristic(self._pars.address) self._logger.debug(output)
def run(self, context): """ If the services could not be discovered, the test step will fail :param context: :return: """ BleBase.run(self, context) output = self._api.ble_gatt_client_discover_services( self._pars.address) self._logger.debug(output)
def run(self, context): """ If the descriptor cannot be written, the the operation has failed :param context: :return: """ BleBase.run(self, context) output = self._api.ble_gatt_client_write_descriptor( self._pars.address, self._pars.write_descriptor_value) self._logger.debug(output)
def run(self, context): """ This test step will fail if at any point an error occurred and the advertising could not be stopped or the server closed :param context: :return: """ BleBase.run(self, context) output = self._api.ble_gatt_stop_server_no_advertising() self._logger.debug(output)
def run(self, context): """ If advertising is not supported, then the TestStep will return FAIL :param context: :return: """ BleBase.run(self, context) result = self._api.ble_check_peripheral_advertising_supported() if result is not None: self._logger.error(result) raise DeviceException(DeviceException.OPERATION_FAILED, result)
def run(self, context): """ If no device is returned by the Agent filtered search, the the operation has failed :param context: :return: """ BleBase.run(self, context) found_devices = self._api.ble_scan_devices(self._pars.timeout) if len(found_devices) == 0: msg = "The LE Scan failed; no devices could be found" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ This test step will fail if at any point an error occurred and the advertising could not be stopped or you are attempting to stop an advertisement that was not start and the associated callback object is null :param context: :return: """ advertise_code = BleBase.check_advertise_code_valid(self, self._pars.advertise_code) BleBase.run(self, context) if (advertise_code is not False): self._api.ble_stop_advertising(advertise_code) else: msg = "You have not provided a valid code for ADVERTISE_CODE :" \ "advertiseCode: %s" % str(advertise_code) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ If the characteristic cannot be added, the the operation has failed :param context: :return: """ gatt_server_operation = BleBase.check_gatt_server_operation( self, self._pars.operation) BleBase.run(self, context) if gatt_server_operation is not False: output = self._api.ble_gatt_server_interaction_no_advertising( gatt_server_operation) self._logger.debug(output) else: msg = "You have not provided a valid code for OPERATION " \ " operation: %s" % gatt_server_operation self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ This test step will fail if at any point an error occurred and the advertising could not be started or the server was not created properly :param context: :return: """ gatt_server_type = BleBase.check_gatt_server_type( self, self._pars.gatt_server_type) BleBase.run(self, context) if gatt_server_type is not False: output = self._api.ble_gatt_start_server(gatt_server_type) self._logger.debug(output) else: msg = "You have not provided a valid code for GATT_SERVER_TYPE" \ " gatt_server_type: %s" % str(gatt_server_type) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ If the callback is not reached, the the operation has failed :param context: :return: """ advertise_mode = BleBase.check_advertise_mode_valid( self, self._pars.advertise_mode) tx_power_level = BleBase.check_tx_power_level_valid( self, self._pars.tx_power_level) BleBase.run(self, context) if (advertise_mode is not False) and (tx_power_level is not False): output = self._api.ble_gatt_server_read_characteristic_callback( tx_power_level, advertise_mode, self._pars.advertise_timeout) self._logger.debug(output) else: msg = "You have not provided a valid code for ADVERTISE_MODE and/or TX_POWER_LEVEL " \ " advertiseMode: %s tx_power_level: %s" % \ (str(advertise_mode), str(tx_power_level)) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ If no device is returned by the Agent filtered search, the the operation has failed :param context: :return: """ scan_mode = BleBase.check_scan_mode_valid(self, self._pars.scan_mode) BleBase.run(self, context) if scan_mode is not False: broadcasted_instances = self._api.ble_start_beacon_observer( scan_mode, self._pars.timeout) else: msg = "You have not provided a valid code for SCAN_MODE" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) if not broadcasted_instances: msg = "No broadcast was observed" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)
def run(self, context): """ If the characteristic cannot be read, the the operation has failed :param context: :return: """ which_characteristic = BleBase.check_notification_characteristic( self, self._pars.which_characteristic) BleBase.run(self, context) if which_characteristic is not False: notification_values = self._api.ble_gatt_client_read_notification( self._pars.address, which_characteristic, self._pars.read_timeout) else: msg = "You have not provided a valid value for WHICH_CHARACTERISTIC" self._logger(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) count_received_notifications = len(notification_values) self._logger.debug("Number of received notifications is: " + str(count_received_notifications))
def run(self, context): """ If no device is returned by the Agent filtered search, the the operation has failed :param context: :return: """ scan_mode = BleBase.check_scan_mode_valid(self, self._pars.scan_mode) BleBase.run(self, context) if scan_mode is not False: bluetooth_device = self._api.ble_scan_filter_manufacturer_data( self._pars.remote_man_id, scan_mode, self._pars.timeout) else: msg = "You have not provided a valid code for SCAN_MODE" self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) if not bluetooth_device: msg = "No device was found using the filter for manufactuerer id: " \ + str(self._pars.remote_man_id) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg)