eclipse-agail / agile-core

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

implement "last_seen" for discovered devices #73

Open cskiraly opened 6 years ago

cskiraly commented 6 years ago

Passing a last_seen attribute back with each discovered device would help the client (the ui) order by date and drop the opacity of inactive devices to show the user that haven't recently been connected.

See https://github.com/Agile-IoT/agile-core/issues/17 for related discussion

dpap commented 6 years ago

@cskiraly isn't it better to drop inactive devices after a specified time programmed via the api?

dpap commented 6 years ago

@cskiraly I have something working but it needs a change to add a lastSeen key to the DeviceOverview object or extend that class to add that key. DeviceOverview is used in a lot of places so a lot of testing is needed. Any other ideas?

cskiraly commented 6 years ago

Conceptually, lastSeen is overlapping partially with the status key, which anyway has a confusing semantics covering two dimensions (whether it is connected; whether available). We could try to override this status, but I think the best option is to add the explicit lastSeen key. What do you think?

dpap commented 6 years ago

actually I tested by passing the timestamp on the status key but agile-ui and other containers are watching this key. I'm currently looking into extending DeviceOverview but I'm not sure how jackson handles inheritance

cskiraly commented 6 years ago

Lets go with the extra field, it is anyway what we've proposed here: https://github.com/Agile-IoT/agile-api-spec/issues/15

dpap commented 6 years ago

The code is confusing The spec you refer to : String name: Human readable name String protocolId: unique protocol Id String deviceId: id assigned by the protocol String status: [CONNECTED/DISCONNECTED/AVAILABLE/UNAVAILABLE] Double lastSeen: unix timestamp + .millisec

In agile-dbus DeviceStatusType public enum DeviceStatusType { CONNECTED, DISCONNECTED, ON, OFF, ERROR, } DeviceOverview at least for BLE only contains AVAILABLE but

DeviceStatus method returns DeviceStatusType

Actually concatenated AVAILABLE+timestamp "sort of" works in agile-ui I've implemented a child class with the new field but changes need to be done in protocolmanager + agile-dbus + http.

dpap commented 6 years ago

The code is confusing The spec you refer to : String name: Human readable name String protocolId: unique protocol Id String deviceId: id assigned by the protocol String status: [CONNECTED/DISCONNECTED/AVAILABLE/UNAVAILABLE] Double lastSeen: unix timestamp + .millisec

In agile-dbus DeviceStatusType public enum DeviceStatusType { CONNECTED, DISCONNECTED, ON, OFF, ERROR, } DeviceOverview at least for BLE only contains AVAILABLE but

DeviceStatus method returns DeviceStatusType

Actually concatenated AVAILABLE+timestamp "sort of" works in agile-ui I've implemented a child class with the new field but changes need to be done in protocolmanager + agile-dbus + http.

dpap commented 6 years ago

I should also mention that changes are needed to the BLE container. Currently I have repurposed the ProtocolManager.FoundNewDeviceSignal signal to always send a signal when it receives the BLE device advertisement and let Protocol Manager do the new device filtering. So this signal should probably change names to reflect this new functionality. I'm not sure how other implementations use this signal but it should work with the initial functionality and even avoid showing duplicates of the same device when the BLE container crashes