You are on page 1of 5

1. Entire flow from device to server and to iot hub.

LWM2M POC performed showcases how LWM2M Client(SmartWatchClient or any other client)
that host LwM2M servers can interface with Azure IoT Hub. This POC has 3 phases:

i. Device Discovery and Registration phase: In this process LWM2M Client (SmartWatchClient)
device lets the LWM2M Server know its existence. This device registers directly with the LwM2M
server, by creating a LeshanClient & starting it. The device(SmartWatchClient) is connected to the
server till it gets De-registered(LeshanClient stops).

ii. Device management: Once the registration process is complete we are performing device
management from LWM2M Server by performing various operations on Client.

iii.Azure IoT Hub: We are realying on LwM2M server that bridges interactions with a LWM2M
Client to a Azure IoT Hub. A JSON object is sent from LwM2M server to Azure IoT Hub. This was
done using two differnt means i. REST Client using HTTP protocol ii. Using MQTT protcocol

These can be verified using Devcie Explorer.

2. The exact lwm2m request that is being sent like 3/4/1 format n what each value represents

LWM2M provides a light interface that enables device management for M2M devices. Once the
registration process is complete device management is performed from LWM2M Server on
SmartWatchClient the device connected. This device has a data model that consists of three levels.
These are
-

Object - each Object represent some different concept of data accessible via the LwM2M Client.

Object Instance - some Objects are described as “single-instance” - such Objects always have
exactly one Instance with identifier 0. or Other Objects may have multiple Instances;

Resource - each Object Instance of a given Object supports the same set of Resources, as defined by
the Object definition. Within a given Object, each Resource ID (which may be in the range 0-
65535, inclusive) has a well-defined meaning, and represent the same concept. However, some
Resources may not be present in some Object Instances, and, obviously, their values and mapping
onto real-world entities may be different.

For example, a path /3/4/1 refers to Resource ID=1 in Object Instance ID=4 of Object ID=3.
3. How new device can be managed through our code and what rest apis are exposed by
server code.

This device registers directly with the LwM2M server, by creating a LeshanClient & starting it. The
device(SmartWatchClient) is connected to the server till it gets De-registered(LeshanClient stops).
Same process of registratio can be applied for any number of devices

For now we have following REST API's in place:

1. API that fetches the list the connected devices.

2. API to delete a resource

3. API to update a resource value.

4. API to observe a resource value.

more details on these APi's are found in DeviceController.java class

synbaas/syntel123$

LwM2M is a device management protocol that allows the remote manipulation of constrained
devices in the Internet of Things, IoT. LwM2M uses CoAP, Constrained Application Protocol as a
transport mechanism.

IoT LwM2M Client:

Overview: Example Describes LwM2M Client Set-up

Description:
Java environment & Eclipse Leshan are Required Tools

Concept
This part describes how to use & customize LwM2M client.
Module 'leshan-client-demo' module is used to represent sensors connected to the LwM2M Client
is Java Application.. This information is exposed to the LwM2M Server (Spring based project) can
be configured remotely or locally, this project manages the sensors connected to the LwM2M
Client. sensors connected constitues of Location details(MyLocation) of the sensor, Temperature
details(RandomTemperatureSensor) of the sensor and other device details (MyDevice). These
parameters are Managable from server & is customizable.
This is an example running LightweightM2M(LwM2M) client, provides core device management
features(device, connectivity, etc).

A REST API for Device Management and applications


Eclipse Leshan is an open source LWM2M programming framework in Java. This
document is showcases how LWM2M Client(SmartWatchClient or any other
client) that host REST based LWM2M servers can interface with Azure IoT Hub
using Eclipse Leshan. This tutorial uses Leshan version1.0.0-M1.

In this Document, we provide following guidelines for Leshan Installation and


Development using Eclipse IDE:

a. Download and install Java SE 8 JDK (which include JRE)

b. Download and install Eclipse IDE for Java Developer – 4.15.0

c. Download the zip distribution of eclipse/leshan from


https://github.com/eclipse/leshan

4. Extract the zip file into the Eclipse Workspace directory

5. Open Eclipse and import the Leshan project to Eclipse downloaded by


accessing File -> Import-> Maven
-> Existing Maven Projects and specify the directory of the project in the
Eclipse Workspace folder

6. Under the Installed JREs menu, which is the Execution Environment menu,
set the compatible JRE for JavaSE-1.8.

 Developing LWM2M Client using LeshanClientDemo

i. Open leshan-client-demo project: a sample of LWM2M client.

ii. In the package org.eclipse.leshan.client.demo, create classes for your


LWM2M objects extending the BaseInstanceEnabler class. In the leshan-client-
demo project, three object classes are created: MyDevice.java, MyLocation.java
and RandomTemperatureSensor.java. You can use one of these classes as a
template for your new device objects. These Objects are Managable.

Iii. Run the project as Java Application LeshanClientDemo. This device object
registers directly with the LwM2M server i.e,. REST Based Spring Boot
application, The device is connected to the server till it gets De-
registered(LeshanClient stops). Same process of registration can be applied for
any number of devices

 Developing REST Based LWM2M Server Spring Boot application


i. Open ladapterdemo project: a LWM2M server project.

ii. Following list of API's are developed:


GET http://server_ip_address/devices
This API returns a JSON file describing all the clients registered in the Leshan
POST http://server_ip_address/devices/registrations/push
This API pushes a JSON file describing all the clients registered in the Leshan to
Azure IoT Hub.
GET http://server_ip_address/devices/observe
This API returns a JSON file describing the value of a resource
DELETE http://server_ip_address/devices
This API deletes the resource returns the status.
PUT http://server_ip_address/devices
This API updates the value of a resource.
These device has a data model that consists of three levels. These are
Object - each Object represent some different concept of data accessible via
the LwM2M Client.
Object Instance - some Objects are described as “single-instance” - such
Objects always have exactly one Instance with identifier 0. or Other Objects
may have multiple Instances;
Resource - each Object Instance of a given Object supports the same set of
Resources, as defined by the Object definition.
For example, a path /3/4/1 refers to Resource ID=1 in Object Instance ID=4 of
Object ID=3.

POST http://server_ip_address/devices/updates/push
This API pushes updated value of a resource to Azure IoT Hub.

Iii. Run the AdapterdemoMainApplication.java as as Spring Boot App.

You might also like