Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [leshan-dev] help for creating object instances on client

Ah I see.  The key thing is that for the Leshan Client if an instance is not mandatory (as '3201' is) it will only be created in response to a create request by the managing server.  You can set the associated classes with the setClassForObject() that will be used to build these instances and I have a branch (https://github.com/eclipse/leshan/tree/client-instance-listener) that will allow a device to listen and receive instances (allowing the device to update them as it sees fit) when they are created (either as being mandatory or via create requests).  As of now those are the only way to access InstanceEnabler instances.

-JF

On Fri, Apr 24, 2015 at 9:54 PM, Foivos . <jfx666@xxxxxxxxxxx> wrote:
ok, that was helpful indeed but does not do exactly what I am looking for.
With the procedure you described I was able to include a custom object's model (eg. id=6666)
in the objects that the client supports. I am able to see that in the sandbox server page, and send from the server an instance creation request to the client.
What I try to do, is creating an instance of an object (regardless of wether this object is custom or is defined in
"oma-objects-spec.json" . In fact the object with id=3201 which I mentioned on my previous post is not custom but is defined in "oma-objects-spec.json".)
But calling the method:
       ObjectsInitializer.create(0,1,3,3201,6666);
will only make the client support these objects(id's = {0,1,3,3201,6666} ) but will NOT create any instance of them (with the exception of object with id=3 and that's because only this object has properties:
"instancetype": "single" AND   "mandatory": true.)
here I uploaded a picture of the server page which depicts the result:
https://dl.dropboxusercontent.com/u/58535035/leshanProb1.png

what I am looking for, must be a simple method like createInstance(int objectId, int instanceId);

Thanks for your time.
--------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 24 Apr 2015 09:53:39 -0400
> From: "J.F. Schloman" <john.schloman@xxxxxxxxx>
> To: leshan developer discussions <leshan-dev@xxxxxxxxxxx>
> Subject: Re: [leshan-dev] help for creating object instances on client
> initialisation
> Message-ID:
> <CAErtmQSBswqoaVYhg5WCnNn_OHr-xTXnDG58gyG8h0M5824UXg@xxxxxxxxxxxxxx>
> Content-Type: text/plain; charset="utf-8"
>
> Hello!
>
> So one thing that is not directly obvious is the leshan's LwM2mModel
> class. This class outlines the objects and resources that (in this case)
> the leshan-client will initialize with ObjectInitializer. It is also used
> by ObjectInitializer.createMandatory() which crawls through the LwM2mModel
> looking for objects with mandatory == true and
> ObjectInitializer.create(...) which crawls the model looking for the
> correct definition (in your case 3201). Using the default constructor of
> ObjectInitializer, it loads only the mandatory objects from the LWM2M
> specification from the oma-objects-spec.json. As object 3201 isn't in
> there neither of the create methods on ObjectInitializer will build it.
>
> In the short-term: as you want to create a LwM2mModel including the L2M2M
> specification and your custom object (3201), you can execute
> ObjectLoader.loadDefault()
> returning a List<ObjectModel>, add those to a Map along with your own
> ObjectModel (for 3201), and create a new LwM2mModel using the
> LwM2mModel(Map<Integer, ObjectModel> objectModels) constructor. Finally
> construct ObjectInitializer with this LwM2mModel.
>
> You can now execute createMandatory() and create(3201) (note: you'll
> probably want to join these lists to pass them into the LeshanClient
> constructor).
>
> In the long-term: it might be worthwhile to simplify the above sequence. I
> could see other devs running into similar issues as yourself. It might be
> more useful to extend ObjectInitializer.setClassForObject() to also take an
> ObjectModel that would then append to the LwM2mModel member. It would
> reduce the number of initialization steps as above in the short-term. And
> Leshan is always looking for contributions! So if you find the time to
> make a branch and come up with improvements, shoot out a PR (
> https://github.com/eclipse/leshan/blob/master/CONTRIBUTING.md)! :)
>
> Hope that was helpful,
>
> -JF
>
> On Thu, Apr 23, 2015 at 9:12 PM, ?????? . <jfx666@xxxxxxxxxxx> wrote:
>
> > hello to everybody. Very exciting for me to join leshan dev community!
> > I've imported leshan on eclipse and ran succesfully the client example.
> >
> > Now I want to create some object instances in client initialisation stage,
> > before registering to server
> > but I have a difficulty finding the way to do that.
> > On the client example the objects initialisation is just:
> >
> > List<ObjectEnabler> enablers = initializer.createMandatory();
> >
> > I try to replace this line of code with something like:
> >
> > List<ObjectEnabler> enablers = initializer.create(3201);
> >
> > but this does not create any instance of object with id=3201.
> >
> > Unfortunately, documentation is almost non existent so
> > any help will be really appreciated.


_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev



Back to the top