diff --git a/pylgbst/comms/cbluepy.py b/pylgbst/comms/cbluepy.py index a5ce43b..243ed4c 100644 --- a/pylgbst/comms/cbluepy.py +++ b/pylgbst/comms/cbluepy.py @@ -29,7 +29,7 @@ class BluepyDelegate(btle.DefaultDelegate): self._handler = handler - def handleNotification(self, cHandle, data): + def handleNotification(self, cHandle, data): log.debug('Incoming notification') self._handler(cHandle, data) @@ -45,7 +45,7 @@ class BluepyThreadedPeripheral(object): self._iface_number = _get_iface_number(controller) self._disconnect_event = Event() - + self._dispatcher_thread = Thread(target=self._dispatch_calls) self._dispatcher_thread.setDaemon(True) self._dispatcher_thread.setName("Bluepy call dispatcher") @@ -70,7 +70,6 @@ class BluepyThreadedPeripheral(object): finally: self._peripheral.disconnect() - def write(self, handle, data): self._call_queue.put(lambda: self._peripheral.writeCharacteristic(handle, data)) @@ -103,10 +102,11 @@ class BluepyConnection(Connection): name = dev.getValueText(COMPLETE_LOCAL_NAME_ADTYPE) log.debug("Found dev, name: {}, address: {}".format(name, address)) - if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address: - logging.info("Found %s at %s", name, address) - self._peripheral = BluepyThreadedPeripheral(address, addressType, self._controller) - break + if address != "00:00:00:00:00:00": + if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address: + logging.info("Found %s at %s", name, address) + self._peripheral = BluepyThreadedPeripheral(address, addressType, self._controller) + break return self @@ -122,4 +122,3 @@ class BluepyConnection(Connection): def is_alive(self): return True - diff --git a/pylgbst/comms/cgatt.py b/pylgbst/comms/cgatt.py index ccfe534..0487d94 100644 --- a/pylgbst/comms/cgatt.py +++ b/pylgbst/comms/cgatt.py @@ -101,10 +101,11 @@ class GattConnection(Connection): address = dev.mac_address name = dev.alias() logging.debug("Device %s at %s", name, address) - if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address: - logging.info("Found %s at %s", name, address) - self._device = CustomDevice(address, self._manager) - break + if address != "00:00:00:00:00:00": + if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address: + logging.info("Found %s at %s", name, address) + self._device = CustomDevice(address, self._manager) + break if not self._device: sleep(1) diff --git a/pylgbst/comms/cgattlib.py b/pylgbst/comms/cgattlib.py index c515ced..bb6cf9c 100644 --- a/pylgbst/comms/cgattlib.py +++ b/pylgbst/comms/cgattlib.py @@ -70,10 +70,11 @@ class GattLibConnection(Connection): log.debug("Devices: %s", devices) for address, name in devices.items(): - if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address: - logging.info("Found %s at %s", name, address) - self.requester = Requester(address, True, self._iface) - break + if address != "00:00:00:00:00:00": + if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address: + logging.info("Found %s at %s", name, address) + self.requester = Requester(address, True, self._iface) + break if self.requester: break diff --git a/pylgbst/comms/cpygatt.py b/pylgbst/comms/cpygatt.py index 52e6209..570c6af 100644 --- a/pylgbst/comms/cpygatt.py +++ b/pylgbst/comms/cpygatt.py @@ -34,10 +34,10 @@ class GattoolConnection(Connection): address = dev['address'] name = dev['name'] if address != "00:00:00:00:00:00": - if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address: - logging.info("Found %s at %s", name, address) - self._conn_hnd = adapter.connect(address) - break + if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address: + logging.info("Found %s at %s", name, address) + self._conn_hnd = adapter.connect(address) + break if self._conn_hnd: break