Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)