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):
        """
        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)
示例#3
0
    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)