Closed NayangiriGoswamiGit closed 6 years ago
Ok that's not the right way.
The default LwM2mModelProvider
is static. It just returns all the model available at server side. This could change when we will try to support Object versioning but for now this is as simple as that !
So how to know how much objects and resources are there with a particular client when it is getting registered ?
Just use registration.getObjectLinks
or registration.getSortedObjectLinks()
. But I agree we could maybe provide a better API for this.
registration.getObjectLinks or registration.getSortedObjectLinks() returns output in this format [{"url":"/","attributes":{"rt":"oma.lwm2m"}},{"url":"/1/0","attributes":{}},{"url":"/3/0","attributes":{}},{"url":"/7/0","attributes":{}},{"url":"/32767/0","attributes":{}}], but my goal is to get all resources detail of all objects, like /7/0 is having START and STOP EXECUTABLE resources, /1/0 is having Short Server Id and Lifetime.
Once you have the objectLink you can retrieve the corresponding object model using server.getModelProvider()
but this will works only to know which object are supported. (That's here where we could provide a better API)
To know resources supported, I believe the only way with LWM2M is to use discover request on each object... :confused:
To know resources supported, I believe the only way with LWM2M is to use discover request on each object...
I tried Discover request on particular instance of particular object(for ex:/3/0/), in which I'm getting all resource URLs not a metadata like 3/0/13 is Current Time and it's data type and all other attributes.
To be more specific what I want is,I should/may get same output which I'm getting from http://localhost:8081/api/objectspecs API in leshan-server-demo.
I will try to be clearer.
The metadata (type, name, description ...) are only available in the model !
What is supported or not by the device is available thanks to ObjectLinks
and discover request
. (returning only URL)
Up to you to use both information to get what you want.
(Hoping this is more clear)
To be more specific what I want is,I should/may get same output which I'm getting from http://localhost:8081/api/objectspecs API in leshan-server-demo.
I don't think so, as this API return the whole model... this is at browser side (in javascript) that we create a tree with only supported objects : https://github.com/eclipse/leshan/blob/master/leshan-server-demo/src/main/resources/webapp/js/lw-resources-services.js#L90
Ok, This is now more clear, Thank you for your time, Simon, We really appreciate the great work you people are doing. You may close this issue.
:+1:
@NayangiriGoswamiGit I created a PR #657 to support object versioning. There is now new utility functions on Registration
to get supported version of an object for a registration. See https://github.com/eclipse/leshan/pull/657/files#diff-cd77b361911b907b7b59f79409eeb341R318
And a LwM2mModelProvider
which return only supported objects. See https://github.com/eclipse/leshan/pull/657/files#diff-5a532c30888fe3d248b10f6ffd3eef73R27
I want to know how much objects and resources are there with a particular client when it is getting registered. In register callback of Device Registration Interface I've written below code:
In output I'm getting details of Default object models (0 to 7) and I'm not getting detail about my custom object models. I tried understanding ObjectSpecServlet.java in leshan-server-demo code and ended up with above logic.