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
|
self._handler = handler
|
||||||
|
|
||||||
def handleNotification(self, cHandle, data):
|
def handleNotification(self, cHandle, data):
|
||||||
log.debug('Incoming notification')
|
log.debug('Incoming notification')
|
||||||
self._handler(cHandle, data)
|
self._handler(cHandle, data)
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class BluepyThreadedPeripheral(object):
|
|||||||
self._iface_number = _get_iface_number(controller)
|
self._iface_number = _get_iface_number(controller)
|
||||||
|
|
||||||
self._disconnect_event = Event()
|
self._disconnect_event = Event()
|
||||||
|
|
||||||
self._dispatcher_thread = Thread(target=self._dispatch_calls)
|
self._dispatcher_thread = Thread(target=self._dispatch_calls)
|
||||||
self._dispatcher_thread.setDaemon(True)
|
self._dispatcher_thread.setDaemon(True)
|
||||||
self._dispatcher_thread.setName("Bluepy call dispatcher")
|
self._dispatcher_thread.setName("Bluepy call dispatcher")
|
||||||
@ -70,7 +70,6 @@ class BluepyThreadedPeripheral(object):
|
|||||||
finally:
|
finally:
|
||||||
self._peripheral.disconnect()
|
self._peripheral.disconnect()
|
||||||
|
|
||||||
|
|
||||||
def write(self, handle, data):
|
def write(self, handle, data):
|
||||||
self._call_queue.put(lambda: self._peripheral.writeCharacteristic(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)
|
name = dev.getValueText(COMPLETE_LOCAL_NAME_ADTYPE)
|
||||||
log.debug("Found dev, name: {}, address: {}".format(name, address))
|
log.debug("Found dev, name: {}, address: {}".format(name, address))
|
||||||
|
|
||||||
if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address:
|
if address != "00:00:00:00:00:00":
|
||||||
logging.info("Found %s at %s", name, address)
|
if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address:
|
||||||
self._peripheral = BluepyThreadedPeripheral(address, addressType, self._controller)
|
logging.info("Found %s at %s", name, address)
|
||||||
break
|
self._peripheral = BluepyThreadedPeripheral(address, addressType, self._controller)
|
||||||
|
break
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -122,4 +122,3 @@ class BluepyConnection(Connection):
|
|||||||
|
|
||||||
def is_alive(self):
|
def is_alive(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -101,10 +101,11 @@ class GattConnection(Connection):
|
|||||||
address = dev.mac_address
|
address = dev.mac_address
|
||||||
name = dev.alias()
|
name = dev.alias()
|
||||||
logging.debug("Device %s at %s", name, address)
|
logging.debug("Device %s at %s", name, address)
|
||||||
if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address:
|
if address != "00:00:00:00:00:00":
|
||||||
logging.info("Found %s at %s", name, address)
|
if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address:
|
||||||
self._device = CustomDevice(address, self._manager)
|
logging.info("Found %s at %s", name, address)
|
||||||
break
|
self._device = CustomDevice(address, self._manager)
|
||||||
|
break
|
||||||
|
|
||||||
if not self._device:
|
if not self._device:
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
@ -70,10 +70,11 @@ class GattLibConnection(Connection):
|
|||||||
log.debug("Devices: %s", devices)
|
log.debug("Devices: %s", devices)
|
||||||
|
|
||||||
for address, name in devices.items():
|
for address, name in devices.items():
|
||||||
if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address:
|
if address != "00:00:00:00:00:00":
|
||||||
logging.info("Found %s at %s", name, address)
|
if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address:
|
||||||
self.requester = Requester(address, True, self._iface)
|
logging.info("Found %s at %s", name, address)
|
||||||
break
|
self.requester = Requester(address, True, self._iface)
|
||||||
|
break
|
||||||
|
|
||||||
if self.requester:
|
if self.requester:
|
||||||
break
|
break
|
||||||
|
@ -34,10 +34,10 @@ class GattoolConnection(Connection):
|
|||||||
address = dev['address']
|
address = dev['address']
|
||||||
name = dev['name']
|
name = dev['name']
|
||||||
if address != "00:00:00:00:00:00":
|
if address != "00:00:00:00:00:00":
|
||||||
if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address:
|
if (not hub_mac and name == LEGO_MOVE_HUB) or hub_mac == address:
|
||||||
logging.info("Found %s at %s", name, address)
|
logging.info("Found %s at %s", name, address)
|
||||||
self._conn_hnd = adapter.connect(address)
|
self._conn_hnd = adapter.connect(address)
|
||||||
break
|
break
|
||||||
|
|
||||||
if self._conn_hnd:
|
if self._conn_hnd:
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user