eclipse-agail / agile-core

Source code repository for agile core components
Eclipse Public License 2.0
7 stars 16 forks source link

Device cannot be reregistered after being deleted #72

Open dpap opened 6 years ago

dpap commented 6 years ago

A device cannot be re-registered after being deleted.

05:26:38.612 [Thread-2] INFO i.a.devicemanager.DeviceManagerImp - Connection established: org.freedesktop.dbus.DBusConnection@623fc1bd 05:26:38.871 [Thread-2] INFO i.a.devicemanager.DeviceManagerImp - Creating new device: Dummy 05:26:38.959 [Thread-2] INFO i.a.devicemanager.DeviceManagerImp - Created new device: [iot.agile.object.DeviceDefinition<dummy001122334455, 00:11:22:33:44:55, Dummy, , iot.agile.protocol.Dummy, /iot/agile/Device/dummy001122334455, [iot.agile.object.DeviceComponent<DummyData, dum>]>] 05:26:38.986 [Thread-8] INFO i.a.devicemanager.DeviceManagerImp - Device connected 05:26:43.401 [Thread-2] INFO i.a.devicemanager.DeviceManagerImp - Deleting device dummy001122334455 05:26:43.406 [Thread-2] INFO i.a.devicemanager.DeviceManagerImp - Device deleted: dummy001122334455 05:26:45.285 [Thread-2] INFO i.a.devicemanager.DeviceManagerImp - Connection established: org.freedesktop.dbus.DBusConnection@623fc1bd 05:26:47.751 [Thread-2] INFO i.a.devicemanager.DeviceManagerImp - Device already registered: dummy001122334455 05:26:47.755 [Thread-9] INFO i.a.devicemanager.DeviceManagerImp - Device connected

dpap commented 6 years ago

@cskiraly By trying to fix #63 we don't deregister the device from dbus so we can't reregister the same device. The d-feet tool did help to clear up things ( but I'm not sure how it can connect to a socket file)

In DeviceManagerImp.java line 96 DeviceDefinition registeredDev = null; if (device != null) { registeredDev = device.Definition(); logger.info("Device already registered: {}", device.Id());

So if DeviceFactory doesn't delete the old device object a new device will never get registered

the Stop method in DeviceImp.java should include code to deregister the device. I'm not sure what dbusDisconnect() is supposed to do here

Proposed change in DeviceImp.java line 437 (I'll make a pull request later on) logger.info ("removing "+deviceID+ "object from " + connection.toString());
String devicePath = AGILE_DEVICE_BASE_BUS_PATH + deviceID; if (connection != null) connection.unExportObject(devicePath);

cskiraly commented 6 years ago

@dpap I've seen the same happening. Can you do the pull request?

dpap commented 6 years ago

@cskiraly I did the change before the namespaces changed. I'll see what I can do. Check #74