Manage all the things,
small and big,
with open source
LwM2M implementations
Benjamin Cabé* – Eclipse Foundation
* many th...
Device Management
● Configure the device
○ Reboot
○ Update APN, current date/time, …
● Update the software (and firmware)
...
Device Management
3
Device Management server
(not necessarily the server used for
IoT application data)
● Has security cre...
D.M. standards protocols
● Usual suspects:
○ TR-069
○ OMA-DM
○ Lightweight M2M
● Goals: provide a way to manage fleets of
...
Lightweight M2M
● A new Open Mobile Alliance standard
● An OMA-DM successor for M2M targets
● Built on top of CoAP
○ much ...
Lightweight M2M (LwM2M)
● An Open Mobile Alliance standard
● A « reboot » of OMA-DM for M2M
● Built on top of CoAP
○ much ...
LWM2M features
● Firmware upgrade (in band or over HTTP)
● Device monitoring and configuration
● Server provisioning (boot...
LWM2M: standard objects
● Device
● Server
● Connectivity monitoring
● Connectivity statistics
● Location
● Firmware
LwM2M ...
LWM2M URIs
URLs:
/{object}/{instance}/{resource}
Example:
/6/0 = whole position object (binary TLV)
/6/0/2 = only the alti...
Leshan
Open-source Lightweight M2M for Java
Leshan
A Java library for implementing LwM2M servers
(and clients)
Friendly for any Java developer (no framework,
few depe...
Features
Client initiated bootstrap
Registration/Deregistration
Read, Write, Create objects
TLV encoding/decoding
OSGi-fri...
Features (cont’d)
DTLS Pre shared key
DTLS Raw public key
Standalone web-UI for testing
Server
Simple Java library
Build using “mvn install”
Based on Californium and Scandium
Under refactoring for accepting oth...
Server API example
public void start() {
// Build LWM2M server
LeshanServerBuilder builder = new LeshanServerBuilder();
lw...
Server API example
// prepare the new value
LwM2mResource currentTimeResource = new LwM2mResource(13,
Value.newDateValue(n...
Client
Under construction! API will probably change
Create objects, answer to server requests
DTLS supported in master
Che...
Next steps
Eclipse.org migration
X.509 DTLS
CoAP shim, CoAP TCP
Stable API for June (inc. client polishing)
And also:
JSON...
Eclipse Wakaama
Lightweight M2M implementation in C
Photo credits: https://www.flickr.com/photos/30126248@N00/2890986348
Wakaama
A C client and server implementation of LwM2M
Not a shared library (.so/.dll)
POSIX compliant and embedded friendl...
Features
Register, registration update, deregister
Read, write resources
Read, write, create, delete object instances
TLV ...
lwm2m_object_t * get_object_device()
{
lwm2m_object_t * deviceObj;
deviceObj = (lwm2m_object_t *)lwm2m_malloc(sizeof(lwm2m...
objArray[0] = get_object_device();
if (NULL == objArray[0])
{
fprintf(stderr, "Failed to create Device objectrn");
return ...
while (0 == g_quit)
{
struct timeval tv;
tv.tv_sec = 60;
tv.tv_usec = 0;
/*
* This function does two things:
* - first it ...
Next?
Device initiated bootstrap
More examples:
https://github.com/kartben/Wakaama-mbed
Server?
Block transfer?
Hack it into real devices!
… DEMO TIME!
Spark Core
● Cortex-M3 STM32,
● RAM/ROM 20/128k, 72MHz
● WiFi
Wakaama + TinydTLS-0.5
Functions: dTLS (PSK)
LwM2M Objects: ...
U-blox MBed.org
● Cortex-M3 (NXP LPC1768),
● RAM/ROM 20/128k, 96MHz
● GPRS
Functions: observe, attribute:
Objects: server,...
Arduino Mega
● ATmega2560
● RAM/ROM 8/256k, 16MHz
● Ethernet
Functions: observe, attribute
Objects: server, security, devi...
Lua binding
https://github.com/sbernard31/lualwm2m
With DTLS support using:
https://github.com/sbernard31/luadtls
binding ...
How to help?
Use it! Report bugs, issue, missing features
Write documentation
Talk about Wakaama and Leshan, they are cool...
Thanks!
benjamin@eclipse.org
@kartben
http://iot.eclipse.org
Prochain SlideShare
Chargement dans…5
×

Manage all the things, small and big, with open source LwM2M implementations - FOSDEM 2015

11 312 vues

Publié le

LwM2M is a standard for device management that solves many of the issues M2M and IoT solutions makers have faced in the past (or, let's be realistic, are still facing), with custom protocols or even standards like OMA-DM: complex workflows, high bandwidth usage, lack of open-source implementations... Join this talk to get an overview of the LwM2M protocol, and to learn how you can start managing an embedded device with Eclipse Wakaama (yes, it fits in an Arduino, and yes, there will be a live demo!), or build your own device management server with Eclipse Leshan.

Publié dans : Technologie

Manage all the things, small and big, with open source LwM2M implementations - FOSDEM 2015

  1. 1. Manage all the things, small and big, with open source LwM2M implementations Benjamin Cabé* – Eclipse Foundation * many thanks to Julien Vermillard for most of the slides!
  2. 2. Device Management ● Configure the device ○ Reboot ○ Update APN, current date/time, … ● Update the software (and firmware) ● Manage the software ○ Change settings ○ Access logs ● Monitor and gather connectivity statistics ○ Amount of sent/received data ○ Number of SMS received/sent 2
  3. 3. Device Management 3 Device Management server (not necessarily the server used for IoT application data) ● Has security credentials for devices on the field (X.509 certificate, public key, …) ● Provides high-level API for batch updates ● May integrate with IT backendIoT Device ● Runs a device management agent, usually in the firmware ● Embeds a private/public key pair to cipher communication ● Has DM server’s public key to authenticate it is talking to intended server
  4. 4. D.M. standards protocols ● Usual suspects: ○ TR-069 ○ OMA-DM ○ Lightweight M2M ● Goals: provide a way to manage fleets of devices that is application-agnostic 4
  5. 5. Lightweight M2M ● A new Open Mobile Alliance standard ● An OMA-DM successor for M2M targets ● Built on top of CoAP ○ much lighter than OMA-DM or TRS-069 ○ enables the use of SMS for wakeup (or any REST interaction really!) 5
  6. 6. Lightweight M2M (LwM2M) ● An Open Mobile Alliance standard ● A « reboot » of OMA-DM for M2M ● Built on top of CoAP ○ much lighter than OMA-DM or TRS-069 ○ enables the use of SMS for wakeup (or any REST interaction really!) ● REST API for Device Management ● Standard objects for Security, Location, Firmware, … ○ and also: IPSO Smart Objects, 3rd party, …
  7. 7. LWM2M features ● Firmware upgrade (in band or over HTTP) ● Device monitoring and configuration ● Server provisioning (bootstraping) 7
  8. 8. LWM2M: standard objects ● Device ● Server ● Connectivity monitoring ● Connectivity statistics ● Location ● Firmware LwM2M objects have a numerical identifier (Device = 3, Location = 6, …) 8
  9. 9. LWM2M URIs URLs: /{object}/{instance}/{resource} Example: /6/0 = whole position object (binary TLV) /6/0/2 = only the altitude value 9
  10. 10. Leshan Open-source Lightweight M2M for Java
  11. 11. Leshan A Java library for implementing LwM2M servers (and clients) Friendly for any Java developer (no framework, few dependencies) But also a Web UI for discovering and testing the protocol
  12. 12. Features Client initiated bootstrap Registration/Deregistration Read, Write, Create objects TLV encoding/decoding OSGi-friendly
  13. 13. Features (cont’d) DTLS Pre shared key DTLS Raw public key Standalone web-UI for testing
  14. 14. Server Simple Java library Build using “mvn install” Based on Californium and Scandium Under refactoring for accepting other CoAP lib
  15. 15. Server API example public void start() { // Build LWM2M server LeshanServerBuilder builder = new LeshanServerBuilder(); lwServer = builder.build(); lwServer.getClientRegistry().addListener(new ClientRegistryListener() { @Override public void registered(Client client) { System.out.println("New registered client with endpoint: " + client.getEndpoint()); } @Override public void updated(Client clientUpdated) { System.out.println("Registration updated"); } @Override public void unregistered(Client client) { System.out.println("Registration deleted"); } }); // start lwServer.start(); System.out.println("Demo server started"); }
  16. 16. Server API example // prepare the new value LwM2mResource currentTimeResource = new LwM2mResource(13, Value.newDateValue(new Date())); // send a write request to a client WriteRequest writeCurrentTime = new WriteRequest(client, 3, 0, 13, currentTimeResource, ContentFormat.TEXT, true); ClientResponse response = lwServer.send(writeCurrentTime); System.out.println("Response to write request from client " + client.getEndpoint() + ": " + response.getCode());
  17. 17. Client Under construction! API will probably change Create objects, answer to server requests DTLS supported in master Check out: leshan-client-example
  18. 18. Next steps Eclipse.org migration X.509 DTLS CoAP shim, CoAP TCP Stable API for June (inc. client polishing) And also: JSON content-type SMS Server initiated bootstrap
  19. 19. Eclipse Wakaama Lightweight M2M implementation in C Photo credits: https://www.flickr.com/photos/30126248@N00/2890986348
  20. 20. Wakaama A C client and server implementation of LwM2M Not a shared library (.so/.dll) POSIX compliant and embedded friendly Plug your own IP stack and DTLS implementation
  21. 21. Features Register, registration update, deregister Read, write resources Read, write, create, delete object instances TLV or plain text Observe
  22. 22. lwm2m_object_t * get_object_device() { lwm2m_object_t * deviceObj; deviceObj = (lwm2m_object_t *)lwm2m_malloc(sizeof(lwm2m_object_t)); if (NULL != deviceObj) { memset(deviceObj, 0, sizeof(lwm2m_object_t)); deviceObj->objID = 3; deviceObj->readFunc = prv_device_read; deviceObj->writeFunc = prv_device_write; deviceObj->executeFunc = prv_device_execute; deviceObj->userData = lwm2m_malloc(sizeof(device_data_t)); if (NULL != deviceObj->userData) { ((device_data_t*)deviceObj->userData)->time = 1367491215; strcpy(((device_data_t*)deviceObj->userData)->time_offset, "+01:00"); } else { lwm2m_free(deviceObj); deviceObj = NULL; } } return deviceObj; } Create obje
  23. 23. objArray[0] = get_object_device(); if (NULL == objArray[0]) { fprintf(stderr, "Failed to create Device objectrn"); return -1; } objArray[1] = get_object_firmware(); if (NULL == objArray[1]) { fprintf(stderr, "Failed to create Firmware objectrn"); return -1; } objArray[2] = get_test_object(); if (NULL == objArray[2]) { fprintf(stderr, "Failed to create test objectrn"); return -1; } lwm2mH = lwm2m_init(prv_connect_server, prv_buffer_send, &data); if (NULL == lwm2mH) { fprintf(stderr, "lwm2m_init() failedrn"); return -1; } result = lwm2m_configure(lwm2mH, "testlwm2mclient", BINDING_U, NULL, OBJ_COUNT, objArray); ... result = lwm2m_start(lwm2mH); Configure Wakaama
  24. 24. while (0 == g_quit) { struct timeval tv; tv.tv_sec = 60; tv.tv_usec = 0; /* * This function does two things: * - first it does the work needed by liblwm2m (eg. (re)sending some packets). * - Secondly it adjust the timeout value (default 60s) depending on the * state of the transaction (eg. retransmission) and the * time between the next operation */ result = lwm2m_step(lwm2mH, &tv); if (result != 0) { fprintf(stderr, "lwm2m_step() failed: 0x%Xrn", result); return -1; } } Active loop
  25. 25. Next? Device initiated bootstrap More examples: https://github.com/kartben/Wakaama-mbed Server? Block transfer?
  26. 26. Hack it into real devices! … DEMO TIME!
  27. 27. Spark Core ● Cortex-M3 STM32, ● RAM/ROM 20/128k, 72MHz ● WiFi Wakaama + TinydTLS-0.5 Functions: dTLS (PSK) LwM2M Objects: device Footprint: “empty”-App: 75.6 KB Flash / 13.1 KB RAM simple-lwm2m: 107 KB Flash / 15.2 KB RAM (overhead = 32KB / 3.1kB!)
  28. 28. U-blox MBed.org ● Cortex-M3 (NXP LPC1768), ● RAM/ROM 20/128k, 96MHz ● GPRS Functions: observe, attribute: Objects: server, security, device, conn_m, firmware, location Footprint (RTOS + commandline + lwm2m stack): 84 KB Flash / 22 KB RAM
  29. 29. Arduino Mega ● ATmega2560 ● RAM/ROM 8/256k, 16MHz ● Ethernet Functions: observe, attribute Objects: server, security, device, conn_m, firmware, location Footprint (C++ wrapper + simulator + lwm2m stack): 67 KB Flash / 5 KB RAM
  30. 30. Lua binding https://github.com/sbernard31/lualwm2m With DTLS support using: https://github.com/sbernard31/luadtls binding on top of TinyDTLS (http://tinydtls.sf.net)
  31. 31. How to help? Use it! Report bugs, issue, missing features Write documentation Talk about Wakaama and Leshan, they are cool! Contribute code Questions? https://dev.eclipse.org/mailman/listinfo/leshan-dev https://dev.eclipse.org/mailman/listinfo/wakaama-dev
  32. 32. Thanks! benjamin@eclipse.org @kartben http://iot.eclipse.org

×