base: remove another register_mode in favour of DeviceMode
This commit is contained in:
parent
637f539194
commit
393056d5e8
14
tuhi/base.py
14
tuhi/base.py
|
@ -301,11 +301,10 @@ class Tuhi(GObject.Object):
|
||||||
# if the device has been 'hotplugged' in the bluez stack,
|
# if the device has been 'hotplugged' in the bluez stack,
|
||||||
# ManufacturerData is reliable. Else, consider the device not in
|
# ManufacturerData is reliable. Else, consider the device not in
|
||||||
# register mode
|
# register mode
|
||||||
register_mode = False
|
if hotplugged and Tuhi._device_in_register_mode(bluez_device):
|
||||||
if hotplugged:
|
mode = DeviceMode.REGISTER
|
||||||
register_mode = Tuhi._device_in_register_mode(bluez_device)
|
else:
|
||||||
|
mode = DeviceMode.LISTEN
|
||||||
if not register_mode:
|
|
||||||
if uuid is None:
|
if uuid is None:
|
||||||
logger.info(f'{bluez_device.address}: device without config, must be registered first')
|
logger.info(f'{bluez_device.address}: device without config, must be registered first')
|
||||||
return
|
return
|
||||||
|
@ -313,14 +312,15 @@ class Tuhi(GObject.Object):
|
||||||
|
|
||||||
# create the device if unknown from us
|
# create the device if unknown from us
|
||||||
if bluez_device.address not in self.devices:
|
if bluez_device.address not in self.devices:
|
||||||
d = TuhiDevice(bluez_device, self.config, uuid=uuid, registered=not register_mode)
|
d = TuhiDevice(bluez_device, self.config, uuid=uuid,
|
||||||
|
registered=(mode == DeviceMode.REGISTER))
|
||||||
d.dbus_device = self.server.create_device(d)
|
d.dbus_device = self.server.create_device(d)
|
||||||
d.connect('notify::listening', self._on_listening_updated)
|
d.connect('notify::listening', self._on_listening_updated)
|
||||||
self.devices[bluez_device.address] = d
|
self.devices[bluez_device.address] = d
|
||||||
|
|
||||||
d = self.devices[bluez_device.address]
|
d = self.devices[bluez_device.address]
|
||||||
|
|
||||||
if register_mode:
|
if mode == DeviceMode.REGISTER:
|
||||||
d.registered = False
|
d.registered = False
|
||||||
logger.debug(f'{bluez_device.objpath}: call Register() on device')
|
logger.debug(f'{bluez_device.objpath}: call Register() on device')
|
||||||
elif d.listening:
|
elif d.listening:
|
||||||
|
|
Loading…
Reference in New Issue