Exemple #1
0
    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))
Exemple #2
0
    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())
Exemple #3
0
    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 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)