Giter Club home page Giter Club logo

jonmikeli / azureiotdevicesimulator5-pnp Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 1.56 MB

Azure IoT Device Simulator (.NET 5) integrating IoT Plug and Play (IoT PnP) capabilities. The simulator allows referencing DTDL v2 models and the telemetry, properties and commands will be created dynamically.

License: GNU Affero General Public License v3.0

C# 99.70% Dockerfile 0.30%
iot azure-iot iot-plug-and-play simulator iot-simulator dev-tools test-tools net5 dtdl iot-hub-sdk

azureiotdevicesimulator5-pnp's Introduction

Azure IoT Device Simulator 5 PnP - IoT Plug and Play version - Readme

This project has for purpose to help IoT developers and testers. The solution is an Azure IoT Device simulator coded with .NET 5 (C#) that implements different types of Cloud To Device (C2D) / Device To Cloud (D2C) flows between Microsoft Azure IoT Hub and the simulated device.

This version of the simulator is based on the regular version of the simulator, which in turn, completes the series of simulators created on top of:

IoT Plug and Play is meant to facilitate the integration of IoT devices with IoT solutions. It tries to imitate the concept of the already known Plug and Play experience at computers level.

The implementation follows a no-typed approach when it comes to DTDL parsing. The initial purpose was to protect the solution against possible changes in the DTDL definition. A not typed approach is less prone to structural updates when the model evolves frequently. However, DTDL v2 seems quite stable. So, I guess a new implementation following a typed approach would be more appropriate now.

Besides the aforementioned simulators, a version implementing Device Provisioning Service (DPS) features completes the family of simulators.

DTDL

This simulator allows to use DTDL, Digital Twins Definition Language models. These models describe the device capabilities via the next concepts:

  • components
  • interfaces
  • properties
  • telemetries
  • commands
  • relationships

All these are described in detail here.

DTDL is based on open standards (JSON-LD and RDF).

The concepts integrated in this simulator are:

  • components
  • interfaces
  • properties (the parser extracts writable and readble properties. The desired properties are checked with the writable properties to verify if they are coherent.)
  • telemetries
  • commands

Simulator process

Models

DTDL v2 does not allow using more than a schema per model. However, some devices may need sending different types of messages. To overcome this limitation, the similator may be used with a list of DTDL models. Only one model is charged at the time (default model) to keep coherence and integrity.

Additional details

Examples of use

  • development tool for developers working on Microsoft Azure IoT solutions (cloud)
  • tester tool in IoT-oriented projects
  • scalable IoT simulation platforms
  • fast and simple development of IoT devices
  • etc

Technical information

  • .NET 5 (C#)
  • Microsoft Azure IoT SDK (Device capabilities, including IoT Hub modules, a.k.a. module identities)
  • IoT Plug and Play
  • DTDL v2

IOT PLUG AND PLAY VS REGULAR SIMULATOR

You can find here a conventional version of the simulator (without IoT Plug and Play). The main difference with the IoT Plug and Play version is that it allows to easily handle with complex JSON Schemas and different types of mesages in one single device.

Which one to choose? The regular simulator is recommended in contexts where:

  • the device needs to send different types of messages.
  • the messages will follow complex formats.
  • you do not want implement DTDL models or use IoT Plug and Play features.
  • DTDL v2 does not allow to implement what you need (ex: different schemas for one single message)

The IoT PnP simulator is recommended in contexts where:

  • the DTDL models need to be tested
  • the IoT Plug and Play flows need to be tested
  • you already have one or many DTDL models and want to simulate the device fast and easily
  • you need to integrate your device with IoT solutions (cloud) with IoT Plug and Play capabilities

Azure IoT Device Simulator logs

Azure IoT Device Simulator Logs


Global features

  • device level simulation (C2D/D2C)
  • module level simulation (C2M/M2C)
  • device simulation configuration based on JSON files
  • module simulation configuration based on JSON files
  • no specific limitation on the number of modules (only limited by Microsoft Azure IoT Hub constraints)
  • simple and lightweight application, containerizable
  • implementation of full IoT flows (C2D, D2C, C2M, M2C) - see below for more details

Functional features

Device level (C2D/D2C)

Commands

  • request latency test
  • reboot device
  • device On/Off
  • read device Twin
  • generic command (with JSON payload)
  • generic command
  • update telemetry interval

Messages D2C: The device will send the telemetries according the referenced DTDL model.

C2D: Microsoft Azure IoT Hub can send messages to a given device.

Twin Any change in the Desired properties is notified and handled by the device.

Module level (C2M/M2C)

Commands have also been implemented at device module level.

NOTE

Latency tests will not be included at modules level.

Global technical features

Functional features are based on these generic technical features:

  • telemetry sent from a device.
  • a device may contain one or many modules.
  • each module behaves independently with its own flows (C2M/M2C) and its configuration settings.
  • the device that contains the modules has its own behavior (based on its own configuration file).
  • telemetry sent from a module.
  • messages received by a device.
  • messages received by a module.
  • commands received by a device.
  • commands received by a module.
  • Twin Desired properties changed notification (for devices).
  • Twin Desired properties changed notification (for modules).
  • Twin Reported properties updates from a device.
  • Twin Reported properties updates from a module.

More information

  • Details about HOW the solution WORKS are provided in the help section.
  • Details about HOW the solution can be USED are provided in the how to section.

azureiotdevicesimulator5-pnp's People

Contributors

jonmikeli avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

azureiotdevicesimulator5-pnp's Issues

AVNET model not compatible?

Hi Jon,

I just stumbled over your project. I think it's a great idea to use DTDL for data simulators!

I tried it using the ./DTDLModels/thermostat.json model. It worked fine. I then wanted to use https://raw.githubusercontent.com/Azure/iot-plugandplay-models/main/dtmi/avnet/mt3620starterkit-1.json model (for the Azure Sphere AVNET Device). Unfortunately, no telemetry data was generated (but no error message was output either).

The output just stops at:

dbug: IoT.Simulator.Services.DeviceSimulationService[0]
      08/23/2021 16:30:41::logType:c2dmessages::simulated-device::Device listening to cloud to device messages.

When I strip the mt3620starterkit-1.json to a bare minimum:

{
  "@id": "dtmi:avnet:mt3620Starterkit;1",
  "@type": "Interface",
  "displayName": "StarterKitOutOfBoxExample",
  "@context": "dtmi:dtdl:context;2",
  "description": "Implements the interface for the Avnet Azure Sphere Starter Kit Out of Box example",
  "contents": [
    {
      "@type": "Telemetry",
      "description": "WiFi Received Signal Strength",
      "displayName": "WiFi Received Signal Strength",
      "name": "rssi",
      "schema": "double"
    }]
}

It works and produces telemetry data. However, if the original value of the @type property is used in the minimal example above (i.e. ["Telemetry"] as an array), it does not work and shows the above behavior.

I guess this type notation is not supported in your simulator yet?

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.