eclipse-leshan / leshan

Java Library for LWM2M
https://www.eclipse.org/leshan/
BSD 3-Clause "New" or "Revised" License
648 stars 406 forks source link

No support for reusable resources #329

Open scop opened 7 years ago

scop commented 7 years ago

Leshan/LwM2mModel appears to have no support for reusable resources. See section 6.3.2 in the specification and http://www.openmobilealliance.org/wp/OMNA/LwM2M/LwM2MRegistry.html#resources and http://www.openmobilealliance.org/wp/OMNA/LwM2M/Common.xml

I suppose a starting point of an approach could be to use a special purpose DDF loader or mechanism for these files (special purpose because at least the above Common.xml has ObjectID 0 which would cause a clash with/overwrite of the Security object if just dumped into the LwM2mModel). Reusable resources could be represented as an object with null id in LwM2mModel.objects and Integer vs current int in ObjectModel.id, although this would cause quite a bit of changes needed for the code in the tree here and there. Or it could be put as a separate field in LwM2mModel, e.g. Map<Integer,ResourceModel> reusableResources.

Anyway, no matter where it is, it could be used for example so that when a resource is looked up for an object with id, if not found from within that specific object, the reusable resources Map could be used as a fallback to search from, with just the resource id used for the lookup.

sbernard31 commented 7 years ago

I prefer the second solution : a separate field in LwM2mModel, e.g. Map<Integer,ResourceModel> reusableResources.

boaks commented 7 years ago

I'm not sure, if there is really a common specification/understanding, how such reusable resources should be handled.

https://github.com/IPSO-Alliance/pub/issues/6

makes me belief, that the IPSO idea is, that "all object" can have such "optional resources" without explicitly declaring that at the object definition. So I will also rise an issue for that on the OMA page.

boaks commented 6 years ago

According the OMA:

https://github.com/OpenMobileAlliance/OMA_LwM2M_for_Developers/issues/205#issuecomment-333588120

In LwM2M 1.0 (1.0.1) there is no concept of "implicite" or "explicite" resource : the Resource of an Object can be either Mandatory or Optional; that's all So when an Object is defined any included Resource (whatever it is reusable or not) must be specified if it is Mandatory or not, multi-Instance or not .. The re-usable resource has an ID which is publicly registered at OMNA, and a set predefined characteristics (datatype, capability...), but otherwise it has to be handled as any other Resource when it is part of an Object definition. Thierry

So there is nothing to change in the implementation ...

sbernard31 commented 6 years ago

I suppose the benefits to "know" reusable resources in Leshan could be to help to handle unknown object. (as @scop explainedin this last paragraph)

This has some impact in the implementation but I don't know if this is really valuable.