-
Notifications
You must be signed in to change notification settings - Fork 409
Getting Started : Client
Here you will see how to code your own LWM2M client with Leshan.
To develop your client you need to use the leshan-client-cf
module.
To know the last version.
<dependencies>
<dependency>
<groupId>org.eclipse.leshan</groupId>
<artifactId>leshan-client-cf</artifactId>
<version><!-- use the last version --></version>
</dependency>
<!-- add any slf4j backend, here we use one of the smallest one: slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.10</version>
<scope>runtime</scope>
</dependency>
</dependencies>
You need to use Leshan builder to create client.
LeshanClientBuilder builder = new LeshanClientBuilder("myClient");
LeshanClient client = builder.build();
client.start();
You should see something like this in your log :
[main] INFO org.eclipse...LeshanClient - Leshan client[endpoint:myClient] started at coap://0.0.0.0/0.0.0.0:46535 coaps://0.0.0.0/0.0.0.0:36490
[RegistrationEngine#0] INFO org.eclipse...RegistrationEngine - Trying to register to coap://leshan.eclipse.org:5683 ...
[RegistrationEngine#0] INFO org.eclipse...RegistrationEngine - Registered with location '/rd/w50JjnP76l'.
[RegistrationEngine#0] INFO org.eclipse...RegistrationEngine - Next registration update in 270.0s...
That's means that you are successfully register your client to the leshan sandbox. You can check if you see your "myClient" device in the web UI and you can play with it (Read or Write on Device object).
All contributions you make to our web site (including this wiki) are governed by our Terms of Use, so please take the time to actually read it. Your interactions with the Eclipse Foundation web properties and any information you may provide us about yourself are governed by our Privacy Policy.