GithubHelp home page GithubHelp logo

isabella232 / iot-hub-lwm2m-bridge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/iot-hub-lwm2m-bridge

0.0 0.0 0.0 273 KB

A bridge that enables OMA LWM2M devices to interact with cloud back-end applications through Azure IoT Hub device twin and methods.

License: Other

JavaScript 100.00%

iot-hub-lwm2m-bridge's Introduction

services platforms author
iot-hub
node
juanjperez

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

LwM2M 1.0 to Azure IoT Hub Bridge Sample

Overview

The LwM2M to Azure IoT Hub bridge sample provides a model for how to enable LwM2M 1.0 devices to leverage capabilities of IoT Hub without any modifications.

Conceptually, the bridge hosts a LwM2M server and bridges interactions with a LwM2M device to a cloud back-end application through Azure IoT Hub. This enables cloud back-end applications (e.g. IoT operator portals) to have a single pane-of-glass for all devices managed through IoT Hub, including devices that have LwM2M clients and are managed by a LwM2M server.

This sample also showcases how products that host LwM2M servers can interface with Azure IoT Hub to very quickly benefit from the benefits of cloud (e.g. scale, high availability, region availability, and Azure's data pipline for warm and cold path analytics and machine learning, among others).

LwM2M IoT Hub Bridge Architecture Diagram

LwM2M Device

The LwM2M device in this sample uses the LwM2M Node Lib Node.js library to register as a device with the LwM2M server that is hosted inside the bridge.

This device can be replaced with a physical or simualted device that uses LwM2M, including devices that use Eclipse Wakaama or Eclipse Leshan.

Bridge

The bridge component provides the following blocks that interact to enable communications from LwM2M devices to IoT Hub.

  • LwM2M Server: A LwM2M server using LwM2M Node Lib is hosted and available for LwM2M devices to register and unregister. When a LwM2M device registers, the bridge will use the IoT Hub client to connect a IoT Hub client to IoT Hub. This enables the cloud back-end application to call direct methods on the bridge that will get translated to LwM2M/CoAP requests on the device.

  • IoT Hub Client: The IoT Hub client, once connected to IoT Hub on behalf of a registering LwM2M device, becomes availabe for the cloud back-end application to make LwM2M/CoAP requests on the device.

  • Device Map: A JSON object in lwm2mgw.js maps a LwM2M device ID to a IoT Hub device connection string. When a LwM2M device registers with the LwM2M server, the register handler uses the device map to find the corresponding IoT Hub device connection string.

Back-end application

The back-end application uses the IoT Hub service client and uses direct methods to trigger LwM2M operations on the bridge.

Setup and config

  1. Create identity for devices in IoT Hub using device explorer. You can use iothubDevice1 and iothubDevice2 to show the difference between LwM2M devices and IoT Hub devices.

  1. Open lwm2mgw.js and edit the deviceList array to include the IoT Hub device connection string for each device for which you created an IoT Hub identity in the previous step.

  1. Open iotbackend/backend.js and enter your IoT Hub connection string into the 'connectionString' variable, which can be found in the Azure portal:

  1. Install NPM dependencies:

npm install lwm2m-node-lib

npm install async

npm install azure-iot-device-mqtt

npm install azure-iot-device

Running through the scenario

  1. Start the bridge, which will start the LwM2M server and listen for LwM2M devices to register.

node gateway/lwm2mgw.js

  1. Start the LwM2M device in a new terminal window, which will register with the LwM2M server hosted in the bridge and connect an IoT Hub client to the mapped IoT Hub device ID.

node lwm2mdevice/device.js lwm2mDevice1

  1. Start the back-end application in a new terminal window, which will initiate LwM2M gestures (e.g. Get, Execute, Write, Observe) on the devices by using direct methods.

node iotbackend/backend.js iothubDevice1

Current gaps that need work

The following are areas for improvement for this sample:

  • Support DTLS. LwM2M-Node-Lib does not have support for DTLS.
  • Support observe on the device and the bridge. When a device does a Notify (from an observed resource) the bridge should both update the device twin reported properties and send a telemetry message with the update.
  • Show how the back-end application can use device twin queries to find devices based on LwM2M resources and resource values. E.g. Find all LwM2M devices that have firmwareVersion = 1.2.
  • Support LwM2M Update Registration gestures from a device.
  • Show how a back-end application can use IoT Hub jobs to scale out LwM2M execute actions on LwM2M devices (e.g. reboot, firmware update, etc...).
  • Support Azure Key Vault to manage keys in the device map.

iot-hub-lwm2m-bridge's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.