-
Notifications
You must be signed in to change notification settings - Fork 764
Tutorial: LWM2M and IPSO Objects
To make an application with LWM2M and IPSO Objects functionality you can start from the example: examples/ipso-objects/example-ipso-objects.c.
Build this example for instance on the TI Sensortag, as follows:
$ make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 example-ipso-objectsThen, program your device with the firmware (see documentation of the platform you are using).
After that your node will register with the default lwm2m server address: fd00::1.
To set a different address, define LWM2M_SERVER_ADDRESS from the project-conf.h file:
#define LWM2M_SERVER_ADDRESS "coap://[fd00::1]"If you want to enable bootstrapping you can set the following flag:
#define REGISTER_WITH_LWM2M_BOOTSTRAP_SERVER 1The node will then bootstrap via hardcoded server, and from there, obtain the server to actually register with.
In order to get anything registered you will need to setup a 6LoWPAN network with a border-router on an prefix and interface address such as fd00::1/64 (see tutorial:rpl-br).
Then also make sure that your LWM2M server is started and is listening on this interface (the tun interface corresponding to the 6LoWPAN network).
Another option is to set up a globally routable IPv6 network so that you can register with any IPv6 enabled LWM2M server.
Assuming that you have set up a border router with the fd00::1/64 address you should do the following:
$ wget https://hudson.eclipse.org/leshan/job/leshan/lastSuccessfulBuild/artifact/leshan-server-demo.jar
$ java -jar ./leshan-server-demo.jarThis will setup the Leshan LWM2M server which makes it possible for your device to register (will work with the default registration address fd00::1).
On OS-X you will need to add -lh fd00::1 to make it bind to the correct interface.
To access the demo server go to http://localhost:8080 and you should see the registration page of the Leshan server.
If you like to register with the demo server at Eclipse you can change the registration address in the code to the NAT64 format. Note: this requires your 6LoWPAN border router to have a NAT64 running on the same network (so that the IPv6 address is converted into an IPv4 address). You can use the Jool NAT64 for that (see doc:ip64).
#define LWM2M_SERVER_ADDRESS "coap://[64:ff9b::527:53ce]"When you run a successful registration here you should see your device at the URL: http://leshan.eclipse.org
DTLS is used to secure the communication with the registration server in LWM2M. Contiki-NG's LWM2M implementation supports using DTLS.
First some small changes in the configuration is needed, add the following to the project-conf.h:
#define LWM2M_SERVER_ADDRESS "coaps://[fd00::1]"
#define COAP_DTLS_PSK_DEFAULT_IDENTITY "Client_identity"
#define COAP_DTLS_PSK_DEFAULT_KEY "secretPSK"This will chabnge the registration to secure mode as it is coaps in the URI and identity and pre-shared key for DTLS is defined.
Then do a distclean:
>make distcleanfollowed by:
>make TARGET=zoul BOARD=firefly-reva MAKE_WITH_DTLS=1 MAKE_COAP_DTLS_KEYSTORE=MAKE_COAP_DTLS_KEYSTORE_SIMPLE example-ipso-objects.upload
If you did not already setup a leshan server and a 6LoWPAN border-router, do that (description above) and configure the same security Identity and keys in the leshan server. Remember to take note of the registration endpoint so that you can get the correct name on that in the security configuration in leshan. If you are using a Zolertia firefly it might look like the following:
Here are some references to used standards and LWM2M servers.