Ejemplo n.º 1
0
    def __init__(self, address, device='hci0', connect=True, debug=False):
        """Constructor."""
        self._address = address
        self._debug = debug

        if self._debug:
            add_stream_logger()
            log.info("Creating MetaWearClient for {0}...".format(address))

        self.mw = MetaWear(self._address, hci_mac=device)

        log.debug("Client started for BLE device {0}...".format(self._address))

        self.accelerometer = None
        #self.gpio = None
        self.gyroscope = None
        self.magnetometer = None
        self.barometer = None
        self.ambient_light = None
        self.switch = None
        self.settings = None
        self.temperature = None
        self.haptic = None
        self.led = None
        self.sensorfusion = None

        if connect:
            self.connect()
Ejemplo n.º 2
0
    def __init__(self, address, device='hci0', connect=True, debug=False):
        """Constructor."""
        self._address = address
        self._debug = debug

        if self._debug:
            add_stream_logger()
            log.info("Creating MetaWearClient for {0}...".format(address))

        self.mw = MetaWear(self._address, device=device)

        log.info("Client started for BLE device {0} on {1}...".format(
            self._address, device))

        self.accelerometer = None
        #self.gpio = None
        self.gyroscope = None
        self.magnetometer = None
        self.barometer = None
        self.ambient_light = None
        self.switch = None
        self.settings = None
        self.temperature = None
        self.haptic = None
        self.led = None
        self.sensorfusion = None

        if connect:
            self.connect()
Ejemplo n.º 3
0
    def __init__(self,
                 address,
                 backend='pygatt',
                 interface='hci0',
                 timeout=None,
                 connect=True,
                 debug=False):
        """Constructor."""
        self._address = address
        self._debug = debug
        self._initialized = False

        if self._debug:
            add_stream_logger()
            log.info("Creating MetaWearClient for {0}...".format(address))

        # Handling of timeout.
        if timeout is None:
            timeout = os.environ.get('PYMETAWEAR_TIMEOUT', None)
            if timeout is not None:
                try:
                    timeout = float(timeout)
                except:
                    timeout = None

        if backend == 'pygatt':
            self._backend = PyGattBackend(self._address,
                                          interface=interface,
                                          timeout=timeout,
                                          debug=debug)
        elif backend == 'pybluez':
            self._backend = PyBluezBackend(self._address,
                                           interface=interface,
                                           timeout=timeout,
                                           debug=debug)
        else:
            raise PyMetaWearException("Unknown backend: {0}".format(backend))

        log.info(
            "Backend starter with {0} for device address {1} with timeout {2}..."
            .format(backend, address, timeout))
        self.firmware_version = None
        self.model_version = None
        self.accelerometer = None
        #self.gpio = None
        self.gyroscope = None
        self.magnetometer = None
        self.barometer = None
        self.ambient_light = None
        self.switch = None
        self.settings = None
        self.temperature = None
        self.haptic = None
        self.led = None
        self.sensorfusion = None

        if connect:
            self.connect()