mirror of
https://github.com/undera/pylgbst.git
synced 2020-11-18 19:37:26 -08:00
Make all backends aware of zero address
This commit is contained in:
parent
5deafe9d4a
commit
a6a5f12e6c
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user