-
Notifications
You must be signed in to change notification settings - Fork 15
Using Sparrow with Wakaama Bootstrap & LWM2M Server(DTLS)
This guide shows how to get sensor nodes(Zolertia's RE-MOTE) running Sparrow to work with Wakaama's bootstrap and LWM2M server.
tinydtls module is needed to enable DTLS support, if you wish to enable secure LWM2M communications.
In the Sparrow source root directory, retrieve the tinydtls source for Sparrow by :
$ git submodule init
$ git submodule update
$ cd examples/zoul/remote
$ make MAKE_WITH_IPSO=1 MAKE_WITH_DTLS=1 IMAGE=1
$ make rescue-image
NOTE: If your Zolertia RE-MOTE is Rev-B, please add BOARD=remote-revb in the make command.
Flash the image into Zolertia RE-MOTE. Note that Zolertia RE-MOTE will be able to connect to LWM2M server with or without security(DTLS).
$ git clone -b sparrow-lwm2m https://github.com/sics-iot/sparrow-wakaama.git
$ cd sparrow-wakaama
$ mkdir bootstrapserver-bin
$ mkdir lwm2mserver-bin
$ cd bootstrapserver-bin
$ cmake ../examples/bootstrap_server
$ make
bootstrap_server executable will be generated in current folder.
$ cd lwm2mserver-bin
$ cmake ../examples/server
$ make
lwm2mserver executable will be generated in current folder.
You can also build the LWM2M server with DTLS support. DTLS requires tinydtls submodule. Use the following commands to retrieve the sources:
$ git submodule init
$ git submodule update
In git root directory sparrow-wakaama, do the following:
$ mkdir lwm2mserver-dtls-bin
$ cd lwm2mserver-dtls-bin
$ cmake -DDTLS=1 ../examples/server
$ make
Copy the bootstrap server configuration file from the source directory to the bootstrap binary folder.
$ cd bootstrapserver-bin
$ cp ../examples/bootstrap_server/bootstrap_server.ini .
Below are the server settings in the bootstrap configuration file:
# Information on a LWM2M server running on localhost
# typically the wakaama test server
[Server]
id=1
uri=coap://[fd02::1]:5683
bootstrap=no
lifetime=300
security=NoSec
# Information for the Leshan sandbox server hosted by
# the Eclipse Foundation
[Server]
id=2
uri=coap://leshan.eclipse.org:5683
bootstrap=no
lifetime=300
security=NoSec
# Information on a LWM2M server running on localhost
# using Pre-Shared Key security
[Server]
id=3
uri=coaps://[fd02::1]:5684
bootstrap=no
lifetime=300
security=PSK
public=4f75724964656e74697479
secret=4F7572536563726574
Depending on your setting of wireless network prefix, you may need to replace the IPv6 address settings for server configurations with id 1 & 3.
By default, Sparrow's node is pre-configured to connect to the bootstrap & LWM2M server with IPv6 address fd02::1. The settings can be changed by adding the following:
#define LWM2M_SERVER_ADDRESS "youripv6address"
in Sparrow source for Zolertia's RE-MOTE (examples/zoul/remote/project-conf.h). Replace youripv6address with your own ipv6 address.
Assume the bootstrap & LWM2M servers are running in the same environment as the Sparrow border router. Use the same network prefix as the one specified when starting Sparrow border router. For example, if the Sparrow border router is started with fd00::/64 network prefix, the server IPv6 address should be fd00::1.
Next step is to configure which LWM2M server for the sensor nodes to connect. By default, it is configured to connect to the Leshan sandbox server (server with id=2)
# For any client, we delete all server accounts and
# provision the Leshan server info
[Endpoint]
Delete=/0
Delete=/1
Server=2
You need to either change it to use LWM2M server without security (no DTLS) by changing the setting to:
Server=1
Or using LWM2M server with security (DTLS enabled):
Server=3
To run bootstrap server, do the following:
$ cd bootstrapserver-bin
$ ./bootstrap_server -f bootstrap_server.ini
Start the LWM2M server according to the settings in bootstrap_server.ini.
To start LWM2M server (no DTLS), do the following:
$ cd lwm2mserver-bin
$ ./lwm2mserver
Or to start LWM2M server with DTLS, do the following:
$ cd lwm2mserver-dtls-bin
$ ./lwm2mserver
Any sensor nodes(Zolertia RE-MOTE) running Sparrow shall connect to the bootstrap server and then register to LWM2M server as shown below:
New Client #0 registered.
Client #0:
name: "Zolertia RE-M-4B00060DB265"
binding: "Not specified"
lifetime: 86400 sec
objects: /0/3, /3/0, /3200/0, /3303/0, /3311/0, /3311/1, /3311/2,
>
In the example above, the Zolertia RE-MOTE is registered as first LWM2M client in the LWM2M server which start with number '0'.
Here are a few basic examples to interact with the first LWM2M client(#0):
To get temperature reading:
> read 0 /3303/0/5700
Client #0 /3303/0/5700 : 2.05 (COAP_205_CONTENT)
5 bytes received of type text/plain:
33 32 2E 33 37 32.37
To turn on the red LED on Zolertia-REMOTE:
> write 0 /3311/0/5850 1
Client #0 /3311/0/5850 : 2.04 (COAP_204_CHANGED)
To turn off the red LED on Zolertia-REMOTE:
> write 0 /3311/0/5850 0
Client #0 /3311/0/5850 : 2.04 (COAP_204_CHANGED)
For green and blue LEDs just use /3311/1/5850 and /3311/2/5850 respectively.
To read button state on Zolertia-REMOTE:
> read 0 /3200/0/5500
Client #0 /3200/0/5500 : 2.05 (COAP_205_CONTENT)
1 bytes received of type text/plain:
30 0
If the button is pressed, the result will be '0' otherwise '1'.