-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom object creation #597
Comments
Hi, But the good point is that your question motivate me to create documentation about that. I also add this to the F.A.Q.. I hope this help. (Please close this issue, if you get enough information) |
thank you very much for the help, I would like to know one more thing and excuse me if my question is dumb, how can I set different names for the different instances, meaning the names that will show up on the server? Thanks! |
In LWM2M, there is no name for instances. Instances is identified by number. And so in If you create your own object, you can imagine that one of its resources is the name. And so a server could read this resource to get the name of the instance. But this will be only for your custom objects. |
Is there a way to associate a particular number identifier for a certain instance? |
When the server create a new instance using CREATE request you can chose the Id. At initialization, you can not chose it too. 😞 Could you describe your use case, and we could think together how to modify the API to make it possible if needed? |
Ok thank you, |
How do you create those object instances using a |
Looking at the code of
Now I need to show in the server wich instance is associated with a certain device without adding a new resource. |
You are using different class for the same object ? I could not understand why you want to do that ? |
So let's say an object implements a certain type of resources X, and I would like to have access for this type of resources for each device. |
It's a bit clearer but not totally. (Just to let you know there are some IPSO objects with an |
Can you please elaborate on this? How will it be problematic? |
When the server send a CREATE request on an object, Leshan device should create a new instance of this object. Generally the |
I see what you mean and I honestly cannot understand the use of remote instance creation from the server if we already do that in the code using |
That's why I tried at the beginning to understand your "concrete" use case. |
I was going through this as I also need to have multiple instances of of a custom object. I can create it using below code: My question is how can we read /write these objects separately at once. Read/write api does not talk about instance ID. It only gives option for resourceId. I need to frame a json file using contents of resource Ids 1 and 2 Is there a way to find instance ID and get all values of that instance at once.
|
@sauravpratik I don't really understand what you want to do. At client side the idea is to provide a way to implement how to write or read a resource. But at server side you can target When object or object instances is targeted, leshan-client will call write/read methods for all resources of the instance and will return only 1 response with all the value. |
@sbernard31 I need to create multiple instance (lets say 2) of my custom defined object , say CustomEvent(). Its has 3 resource Ids which I have defined in CustomEvent() class. I can create it using below code:
This creates two instance of CustomEvent() on Leshan Server and Instance Ids are assigned as 0 and 1. Question 1: Is it possible to provide Instance Id to object from client rather that server assigning it as 0 and 1 ? Looks like answer is NO as mentioned in the same thread. Is there a possible way ? CustomEvent() handles read and write interfaces and returns ReadResponse/WriteResponse. When server writes the complete Instance (say 0) at once by filling all 3 resources , the client code handles it in .
Question 2 : Is it possible to get Instance Id (0 or 1) here ? This looks possible by modifying adding below function to public interface LwM2mInstanceEnabler
Here from
Do you suggest this approach ? Question 3:
This piece of client code is called for each resource Id. Is it possible that once complete instance is updated/written by server then the client can gather data of each resource Id at once rather than one by one by reading case 0, case 1 etc ? Thanks for your time for reading this P.s I am using Leshan Client and Server Demo source code for testing this out. |
Currently you can't, we could add this but currently I didn't really understand the need of this 😕
It seems your 2 instances have not exactly the same behavior. Why not using one of the resource to define the behavior and so you could use this resource to know what to do instead of the instance ID ? E.g. adding a
(I propose This way even at server side you can guess the type, you can even
using Anyway, the real contract to implement is
|
Thanks for your detailed response. Really appreciate it. And I completely agree that it's not possible to cover all use cases. Regarding your responses to Questions:
Thank You |
|
@sbernard31 1 - Using a type definitely helps. In future, it will be good to have this feature for unique requirements. Not urgent for sure. 3 - I will explore as well. Pls lemme know if you find a solution for it.. Thanks for your time and suggestions. Appreciated :) |
|
Thank You so much. |
@sbernard31 - Completely agree to your point. Starting implementing 1 will be better plan. #616 - It looks promising. I understand the changes. One input - It would be nice if both Read and Write operations are added together. ReadResponse read(ServerIdentity identity); & What do you suggest ? Thanks for adding this. This will greatly help |
I plan to do that for almost all operation. I also plan to add ServerIdentity parameter to "resource operation" to make it consistent. |
@sbernard31 Got your point. Thanks. |
@Yalayak, @sauravpratik
If you I have time to review this PR or give feedback about it, that would be really appreciated. |
Hi everyone,
I'm a beginner so please bare with me.
I would like to create a new custom object in Leshan. I would like to know if it is obligatory to only use the existing IPSO data models. Is it possible for me to create my own model and implement it? How can I make the server able to deal with the new objects/ressources?
The text was updated successfully, but these errors were encountered: