diff options
| author | lejeune quentin <qle@odoo.com> | 2019-04-03 14:21:54 +0000 |
|---|---|---|
| committer | lejeune quentin <qle@odoo.com> | 2019-07-03 08:14:28 +0000 |
| commit | f5676fabea8a09f5702d00e75f3cf55f01ed5b22 (patch) | |
| tree | aef01a974c767044063398f007d7811418132238 | |
| parent | 69ca6bd0a46e80e258db54f02bee2c03bd6bc909 (diff) | |
[IMP] hw_driver: inform the odoo instance of connected and disconnected devices
Before this commit, we only sent the list of connected devices to
the odoo instance (thanks to `self.send_alldevices`) when a device
is newly connected. Now, we also send this list when a device is
disconnected. We also try to call this method once if multiple devices
are connected/disconnected during an iteration.
task-id 1939338
closes odoo/odoo#32678
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
| -rwxr-xr-x | addons/hw_drivers/controllers/driver.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/hw_drivers/controllers/driver.py b/addons/hw_drivers/controllers/driver.py index 9d238227a38..4ed79871083 100755 --- a/addons/hw_drivers/controllers/driver.py +++ b/addons/hw_drivers/controllers/driver.py @@ -359,18 +359,23 @@ class Manager(Thread): added = updated_devices.keys() - devices.keys() removed = devices.keys() - updated_devices.keys() devices = updated_devices + send_devices = False for path in [device_rm for device_rm in removed if device_rm in iot_devices]: iot_devices[path].disconnect() + _logger.info('Device %s is now disconnected', path) + send_devices = True for path in [device_add for device_add in added if device_add not in iot_devices]: for driverclass in [d for d in drivers if d.connection_type == devices[path].connection_type]: if driverclass.supported(device = updated_devices[path].dev): - _logger.info('For device %s will be driven', path) + _logger.info('Device %s is now connected', path) d = driverclass(device = updated_devices[path].dev) d.daemon = True d.start() iot_devices[path] = d - self.send_alldevices() + send_devices = True break + if send_devices: + self.send_alldevices() time.sleep(3) class GattBtManager(Gatt_DeviceManager): |
