hub icon indicating copy to clipboard operation
hub copied to clipboard

Introduce a new notification announcing a device is ready-to-be-used after onboarding it into the plgd/hub

Open Michal-Svoboda opened this issue 3 years ago • 1 comments

Feature Request

What is the purpose of the feature?

A consumer code which asked for onboarding a device into the plgd/hub needs to be informed when it can "SAFELLY" start to access the device resources. It needs to know when the device is ready-to-be-used. It would be grat the plgd/hub would announce "READY" notification.

What specific challenge does this feature solve?

At this moment, there is several notifications coming from the plgd/hub after the device has been onboarded, non of it says it the "SAFE" to access the device's resources - it happen often the HTTP GET request of a resource response 404 (Not Found). At this moment there is no reliable and performant-enough way how to get know the device is ready to be used after onboarding.

What alternatives did I consider?

A kind of workaround we tried to use is to observe REGISTERED notification, then register and observe the notification RESOURCE_PUBLISHED where is a list of all published resources delivered (e.g. 250 items in the list). After that register and observe the notification RESOURCE_CHANGED and wait till it arrives many times (e.g. 250 times), depending on the number of published resources. After that we consider the device to be ready to be used. The downside of this workaround is the complexity and bad performance.

FYI: @ondrejtomcik @rafajpet @jkralik

Michal-Svoboda avatar Jun 14 '22 14:06 Michal-Svoboda

Hello @Michal-Svoboda.

Thank you for your feature request. The device can be "SAFELLY" accessed at any time. There is nothing like a corrupted state or device not being ready. You have to look at your device and its resources as on your application component - entity only you understand.

For plgd hub, devices are entities that at different moments have different resources with different representations. For us, opaque data. There is nothing like the beginning and end of the sync. When the device connects, indeed we are informed about available resources. But this information can be received in 1 message or even 10 messages. There is no transaction so we cannot at any point in time declare that now, that's all, the device won't send us anything new.

There are devices, that at the moment they are turned on and connected to the plgd hub, are being immediately reconfigured. This leads to the loop of publish/unpublish and resource change events, without the possibility to identify when it ends.

Basically, you have the same problem at this moment. You don't know how long to wait, or, actually, you know - you said the device has 250 resources, and based on your message, I assume it is not changing during the device's runtime. This is knowledge only you, an application developer, have as you know this device you integrate, which gives you a possibility to build logic around it and declare the device as synchronized when 250 events are received. Then you can inform the UI for example.

But we cannot do such a heuristic as it's very application specific and our device library has functionality like adding/removing resources during runtime (what might be during onboarding to the cloud) or splitting messages in case the RAM of MCU is too low.

I would question your use case and how you are solving it. Why do you need to know that the full device is "synchronized"? Do you have one webpage where you display to user all the data from all resources? Why do you have only "possible" / "impossible" to open device details? You can create progress bar, you can create disabled items / functionalities (resources) in your device until you receive event. You don't have to push resource events to UI. You have your own application API, which understands the device, what gives you the possibility to have it as granular as you application requires. "measurement channels available", "transfer options available", and based on that, have your UI reactive. But, this is application specific.

Hope this helps to understand why we are not able to identify start and end of sync as you described it. If not, feel free to reply.

ondrejtomcik avatar Jun 15 '22 19:06 ondrejtomcik

Hello @Michal-Svoboda. We found a solution which would fulfill your requirements. Are you still interested in this or it’s no more on your roadmap?

ondrejtomcik avatar Oct 21 '22 11:10 ondrejtomcik

Oh yes, sure, I am - we are - still interested in a solution of this :-) You will make Digital Hub people happy!!!

Michal-Svoboda avatar Oct 21 '22 11:10 Michal-Svoboda

Implemented via device twin - more info

jkralik avatar Oct 26 '23 06:10 jkralik