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 initialisation

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.

> From: leshan-dev-request@xxxxxxxxxxx
> Subject: leshan-dev Digest, Vol 4, Issue 14
> To: leshan-dev@xxxxxxxxxxx
> Date: Thu, 23 Apr 2015 11:18:51 -0400
>
> Send leshan-dev mailing list submissions to
> leshan-dev@xxxxxxxxxxx
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://dev.eclipse.org/mailman/listinfo/leshan-dev
> or, via email, send a message with subject or body 'help' to
> leshan-dev-request@xxxxxxxxxxx
>
> You can reach the person managing the list at
> leshan-dev-owner@xxxxxxxxxxx
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of leshan-dev digest..."
>
>
> Today's Topics:
>
> 1. Re: Time for a milestone release (Julien Vermillard)
> 2. Re: Time for a milestone release (J.F. Schloman)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 23 Apr 2015 15:07:56 +0000
> From: Julien Vermillard <jvermillard@xxxxxxxxx>
> To: leshan developer discussions <leshan-dev@xxxxxxxxxxx>
> Subject: Re: [leshan-dev] Time for a milestone release
> Message-ID:
> <CAN9CcB99RxcWhYRx4VTpS=8fmKu=PL-Xv24Qu+udTJ7LQm9dtg@xxxxxxxxxxxxxx>
> Content-Type: text/plain; charset="utf-8"
>
> released 0.1.11-M2 milestone!
>
> On Wed, Apr 22, 2015 at 7:11 PM Kai <sophokles.kh@xxxxxxxxx> wrote:
>
> > Julien,
> >
> > that's fine with me :-)
> >
> > Julien Vermillard <jvermillard@xxxxxxxxx> schrieb am Mi., 22. Apr. 2015
> > 13:48:
> >
> >> Hi,
> >> This mean doing a Cf release and them modify leshan code?
> >> I would like to do a milestone before because we want to get the last
> >> Leshan bug-fixes into AirVantage.
> >>
> >> Milestones are free, if needed we can do another one once we managed to
> >> integrate with the new Sc identity API.
> >>
> >> WDYT?
> >> Julien
> >>
> >>
> >> On Wed, Apr 22, 2015 at 11:53 AM Hudalla Kai (INST/ESY) <
> >> Kai.Hudalla@xxxxxxxxxxxx> wrote:
> >>
> >>> I would love to see leshan use the newly provided API in Cf?s Request
> >>> to access the authenticated client?s identity for making authorization
> >>> decisions.
> >>>
> >>> However, in order to so we would need to create a new milestone release
> >>> of Scandium and Californium as well (which I think we should do as well
> >>> since I have made so many changes/improvements in Scandium).
> >>>
> >>> Do think it would be worthwhile to take advantage of the new API?
> >>>
> >>>
> >>>
> >>> Kai
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> *From:* leshan-dev-bounces@xxxxxxxxxxx [mailto:
> >>> leshan-dev-bounces@xxxxxxxxxxx] *On Behalf Of *Julien Vermillard
> >>> *Sent:* Wednesday, April 22, 2015 9:39 AM
> >>> *To:* leshan developer discussions
> >>> *Subject:* [leshan-dev] Time for a milestone release
> >>>
> >>>
> >>>
> >>> Hi,
> >>>
> >>> A lot of buxfix landed in the master, I think it's time for another
> >>> milestone release:
> >>>
> >>> WDYT?
> >>>
> >>> List of commits since last milestone:
> >>>
> >>> * a9eae6a - (HEAD, origin/master, origin/HEAD, master) renamed methods
> >>> because it's loading stream not files (il y a 6 minutes) <Julien Vermillard>
> >>> * e73facd - (origin/decode_tlv_one_instance, decode_tlv_one_instance)
> >>> Decode TLV for one instance object request (il y a 16 heures) <Julien
> >>> Vermillard>
> >>> * 49205f8 - don't shallow async response handling exceptions (il y a 18
> >>> heures) <Julien Vermillard>
> >>> * ef90727 - added object model for IPSO objects (il y a 6 jours) <Julien
> >>> Vermillard>
> >>> * 688e743 - #8: fix bug (== instead of !=) (il y a 6 jours) <Simon
> >>> Bernard>
> >>> * ce952b5 - Fix trace log (il y a 7 jours) <Manuel Sangoi>
> >>> * 29ac887 - Add some trace logs in the TLV decoder (il y a 7 jours)
> >>> <Manuel Sangoi>
> >>> * 0419f1b - bug464043: Tests fail on Windows (il y a 8 jours) <Simon
> >>> Bernard>
> >>> * ba70e4f - dump the TLV if a parse error occurs (il y a 8 jours)
> >>> <Julien Vermillard>
> >>> * 0d9694f - avoid maven warnings by providing plugin version (il y a 2
> >>> semaines) <Alexander Ellwein>
> >>> * 348b530 - adjustments in import / export packages in pom.xml for osgi
> >>> support (il y a 2 semaines) <ingo schaal>
> >>> * 1fd2cda - #8: Incorrect link objects are implicitly sent on update (il
> >>> y a 4 semaines) <Simon Bernard>
> >>> * b409bea - add some checks on link object payload for register
> >>> integration tests (il y a 4 semaines) <Simon Bernard>
> >>> * 19b0940 - add integration tests for discover (il y a 4 semaines)
> >>> <Simon Bernard>
> >>> * 58d051d - fix registration and implement discover (without attributes)
> >>> at client side. (il y a 4 semaines) <Simon Bernard>
> >>> * b32ac64 - ClientUpdate toString() (il y a 4 semaines) <Julien
> >>> Vermillard>
> >>> * 64968dd - add API to be able to load model from stream (il y a 4
> >>> semaines) <Simon Bernard>
> >>> * 90c7e2a - Merge LinkFormatUtils in LinkObject (il y a 4 semaines)
> >>> <Simon Bernard>
> >>> * 7a14736 - Remove the "close" of DTLS Session when register return
> >>> FORBIDDEN (il y a 5 semaines) <Simon Bernard>
> >>> * 144beac - add Security Tests (Test RPK and PSK connection via DTLS)
> >>> (il y a 5 semaines) <Simon Bernard>
> >>> * 834d61d - Refactor tests to prepare addition of SecurityTest (il y a 5
> >>> semaines) <Simon Bernard>
> >>> * 7d418e9 - restore RPK support (probably erased pending a previous
> >>> merge) (il y a 5 semaines) <Simon Bernard>
> >>> * 439ecfd - add some TODOs (il y a 5 semaines) <Simon Bernard>
> >>> * 43c64fa - Move ResponseCallback from leshan-client-core to
> >>> integration-tests (il y a 5 semaines) <Simon Bernard>
> >>> * bd5fec0 - Manage all exceptions in handleRequest (il y a 5 semaines)
> >>> <Simon Bernard>
> >>> * 9969792 - always use free port for tests. (il y a 5 semaines) <Simon
> >>> Bernard>
> >>> * a23e6a8 - fix java doc of LeshanClientExample (il y a 5 semaines)
> >>> <Simon Bernard>
> >>> * d86fdc5 - LwM2mPath constructor accept now path which does not start
> >>> by "/" (il y a 5 semaines) <Simon Bernard>
> >>> * b984fc5 - The client address setting is now optional. (il y a 5
> >>> semaines) <Simon Bernard>
> >>> * cf823de - fix licence and remove reference to github.com/jvermillard
> >>> (il y a 6 semaines) <Simon Bernard>
> >>> * 83a56aa - Remove unused dependencies (il y a 6 semaines) <Simon
> >>> Bernard>
> >>> * 05202b2 - Remove LwM2MServerMessageDeliverer (Use default
> >>> MessageDeliverer) (il y a 6 semaines) <Simon Bernard>
> >>> * adb154c - Split leshan-client in 2 projects
> >>> (leshan-client-core/leshan-client-cf) (il y a 6 semaines) <Simon Bernard>
> >>> * d1e9ec5 - Always run integration tests (remove integration profile for
> >>> tests) (il y a 6 semaines) <Simon Bernard>
> >>> * a326851 - New client API (il y a 6 semaines) <Simon Bernard>
> >>> _______________________________________________
> >>> 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
> >>>
> >> _______________________________________________
> >> 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
> >>
> > _______________________________________________
> > 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
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://dev.eclipse.org/mailman/private/leshan-dev/attachments/20150423/bd36e335/attachment.html>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 23 Apr 2015 11:18:15 -0400
> From: "J.F. Schloman" <john.schloman@xxxxxxxxx>
> To: leshan developer discussions <leshan-dev@xxxxxxxxxxx>
> Subject: Re: [leshan-dev] Time for a milestone release
> Message-ID:
> <CAErtmQTUdzxe2fo+TVWsW6p0az8gDdseAYwH73JsJKjOJ7xbwA@xxxxxxxxxxxxxx>
> Content-Type: text/plain; charset="utf-8"
>
> @Simon,
>
> I've created the PR here: https://github.com/eclipse/leshan/pull/12
>
> It adds a simple InstanceChangedListener on the client that allows for
> simple interaction with the code using the library. I updated the example
> client to show off how it can be used by allowing a user to change the
> error code (and, if they observe on it in the standalone, see it getting
> updated).
>
> -J
>
> On Thu, Apr 23, 2015 at 11:07 AM, Julien Vermillard <jvermillard@xxxxxxxxx>
> wrote:
>
> > released 0.1.11-M2 milestone!
> >
> > On Wed, Apr 22, 2015 at 7:11 PM Kai <sophokles.kh@xxxxxxxxx> wrote:
> >
> >> Julien,
> >>
> >> that's fine with me :-)
> >>
> >> Julien Vermillard <jvermillard@xxxxxxxxx> schrieb am Mi., 22. Apr. 2015
> >> 13:48:
> >>
> >>> Hi,
> >>> This mean doing a Cf release and them modify leshan code?
> >>> I would like to do a milestone before because we want to get the last
> >>> Leshan bug-fixes into AirVantage.
> >>>
> >>> Milestones are free, if needed we can do another one once we managed to
> >>> integrate with the new Sc identity API.
> >>>
> >>> WDYT?
> >>> Julien
> >>>
> >>>
> >>> On Wed, Apr 22, 2015 at 11:53 AM Hudalla Kai (INST/ESY) <
> >>> Kai.Hudalla@xxxxxxxxxxxx> wrote:
> >>>
> >>>> I would love to see leshan use the newly provided API in Cf?s
> >>>> Request to access the authenticated client?s identity for making
> >>>> authorization decisions.
> >>>>
> >>>> However, in order to so we would need to create a new milestone release
> >>>> of Scandium and Californium as well (which I think we should do as well
> >>>> since I have made so many changes/improvements in Scandium).
> >>>>
> >>>> Do think it would be worthwhile to take advantage of the new API?
> >>>>
> >>>>
> >>>>
> >>>> Kai
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> *From:* leshan-dev-bounces@xxxxxxxxxxx [mailto:
> >>>> leshan-dev-bounces@xxxxxxxxxxx] *On Behalf Of *Julien Vermillard
> >>>> *Sent:* Wednesday, April 22, 2015 9:39 AM
> >>>> *To:* leshan developer discussions
> >>>> *Subject:* [leshan-dev] Time for a milestone release
> >>>>
> >>>>
> >>>>
> >>>> Hi,
> >>>>
> >>>> A lot of buxfix landed in the master, I think it's time for another
> >>>> milestone release:
> >>>>
> >>>> WDYT?
> >>>>
> >>>> List of commits since last milestone:
> >>>>
> >>>> * a9eae6a - (HEAD, origin/master, origin/HEAD, master) renamed methods
> >>>> because it's loading stream not files (il y a 6 minutes) <Julien Vermillard>
> >>>> * e73facd - (origin/decode_tlv_one_instance, decode_tlv_one_instance)
> >>>> Decode TLV for one instance object request (il y a 16 heures) <Julien
> >>>> Vermillard>
> >>>> * 49205f8 - don't shallow async response handling exceptions (il y a 18
> >>>> heures) <Julien Vermillard>
> >>>> * ef90727 - added object model for IPSO objects (il y a 6 jours)
> >>>> <Julien Vermillard>
> >>>> * 688e743 - #8: fix bug (== instead of !=) (il y a 6 jours) <Simon
> >>>> Bernard>
> >>>> * ce952b5 - Fix trace log (il y a 7 jours) <Manuel Sangoi>
> >>>> * 29ac887 - Add some trace logs in the TLV decoder (il y a 7 jours)
> >>>> <Manuel Sangoi>
> >>>> * 0419f1b - bug464043: Tests fail on Windows (il y a 8 jours) <Simon
> >>>> Bernard>
> >>>> * ba70e4f - dump the TLV if a parse error occurs (il y a 8 jours)
> >>>> <Julien Vermillard>
> >>>> * 0d9694f - avoid maven warnings by providing plugin version (il y a 2
> >>>> semaines) <Alexander Ellwein>
> >>>> * 348b530 - adjustments in import / export packages in pom.xml for osgi
> >>>> support (il y a 2 semaines) <ingo schaal>
> >>>> * 1fd2cda - #8: Incorrect link objects are implicitly sent on update
> >>>> (il y a 4 semaines) <Simon Bernard>
> >>>> * b409bea - add some checks on link object payload for register
> >>>> integration tests (il y a 4 semaines) <Simon Bernard>
> >>>> * 19b0940 - add integration tests for discover (il y a 4 semaines)
> >>>> <Simon Bernard>
> >>>> * 58d051d - fix registration and implement discover (without
> >>>> attributes) at client side. (il y a 4 semaines) <Simon Bernard>
> >>>> * b32ac64 - ClientUpdate toString() (il y a 4 semaines) <Julien
> >>>> Vermillard>
> >>>> * 64968dd - add API to be able to load model from stream (il y a 4
> >>>> semaines) <Simon Bernard>
> >>>> * 90c7e2a - Merge LinkFormatUtils in LinkObject (il y a 4 semaines)
> >>>> <Simon Bernard>
> >>>> * 7a14736 - Remove the "close" of DTLS Session when register return
> >>>> FORBIDDEN (il y a 5 semaines) <Simon Bernard>
> >>>> * 144beac - add Security Tests (Test RPK and PSK connection via DTLS)
> >>>> (il y a 5 semaines) <Simon Bernard>
> >>>> * 834d61d - Refactor tests to prepare addition of SecurityTest (il y a
> >>>> 5 semaines) <Simon Bernard>
> >>>> * 7d418e9 - restore RPK support (probably erased pending a previous
> >>>> merge) (il y a 5 semaines) <Simon Bernard>
> >>>> * 439ecfd - add some TODOs (il y a 5 semaines) <Simon Bernard>
> >>>> * 43c64fa - Move ResponseCallback from leshan-client-core to
> >>>> integration-tests (il y a 5 semaines) <Simon Bernard>
> >>>> * bd5fec0 - Manage all exceptions in handleRequest (il y a 5 semaines)
> >>>> <Simon Bernard>
> >>>> * 9969792 - always use free port for tests. (il y a 5 semaines) <Simon
> >>>> Bernard>
> >>>> * a23e6a8 - fix java doc of LeshanClientExample (il y a 5 semaines)
> >>>> <Simon Bernard>
> >>>> * d86fdc5 - LwM2mPath constructor accept now path which does not start
> >>>> by "/" (il y a 5 semaines) <Simon Bernard>
> >>>> * b984fc5 - The client address setting is now optional. (il y a 5
> >>>> semaines) <Simon Bernard>
> >>>> * cf823de - fix licence and remove reference to github.com/jvermillard
> >>>> (il y a 6 semaines) <Simon Bernard>
> >>>> * 83a56aa - Remove unused dependencies (il y a 6 semaines) <Simon
> >>>> Bernard>
> >>>> * 05202b2 - Remove LwM2MServerMessageDeliverer (Use default
> >>>> MessageDeliverer) (il y a 6 semaines) <Simon Bernard>
> >>>> * adb154c - Split leshan-client in 2 projects
> >>>> (leshan-client-core/leshan-client-cf) (il y a 6 semaines) <Simon Bernard>
> >>>> * d1e9ec5 - Always run integration tests (remove integration profile
> >>>> for tests) (il y a 6 semaines) <Simon Bernard>
> >>>> * a326851 - New client API (il y a 6 semaines) <Simon Bernard>
> >>>> _______________________________________________
> >>>> 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
> >>>>
> >>> _______________________________________________
> >>> 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
> >>>
> >> _______________________________________________
> >> 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
> >>
> >
> > _______________________________________________
> > 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
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <https://dev.eclipse.org/mailman/private/leshan-dev/attachments/20150423/f79a2cfd/attachment.html>
>
> ------------------------------
>
> _______________________________________________
> 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
>
>
> End of leshan-dev Digest, Vol 4, Issue 14
> *****************************************

_______________________________________________
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