Modbus-XMPP Bridge

The IoTBridgeModbus repository provides an IoT bridge between devices connected to Modbus, for use in closed intra-networks or enterprise networks, and the harmonized XMPP-based Neuro-Foundation network, for open and secure cross-domain interoperation on the Internet.

Bridge topology
Bridge topology

To run the bridge, you need access to both a Modbus gateway, and an XMPP broker, that supports the Neuro-Foundation extensions. You can use the TAG Neuron for XMPP.

Running and configuring the bridge

The code is written using .NET Standard, and compiled to a .NET Core console application that can be run on most operating systems. Basic configuration is performed using the console interface during the first execution, and persisted. You can also provide the corresponding configuration using environment variables, making it possible to run the bridge as a container. If an environmental variable is missing, the user will be prompted to input the value on the console.

Environmental Variable Type Description
XMPP_HOST String XMPP Host name
XMPP_PORT Integer Port number to use when connecting to XMPP (default is 5222)
XMPP_USERNAME String User name to use when connecting to XMPP.
XMPP_PASSWORD String Password (or hashed password) to use when connecting to XMPP. Empty string means a random password will be generated.
XMPP_PASSWORDHASHMETHOD String Algorithm or method used for password. Empty string means the password is provided in the clear.
XMPP_APIKEY String API Key. If provided together with secret, allows the application to create a new account.
XMPP_APISECRET String API Secret. If provided together with key, allows the application to create a new account.
MODBUS_HOST String Modbus Gateway Host name
MODBUS_TLS String If TLS encryption is to be used when connecting to the Modbus gateway.
MODBUS_PORT String Port number to use when connecting to the Modbus gateway (default is 502).
REGISTRY_COUNTRY String Country where the bridge is installed.
REGISTRY_REGION String Region where the bridge is installed.
REGISTRY_CITY String City where the bridge is installed.
REGISTRY_AREA String Area where the bridge is installed.
REGISTRY_SRTEET String Street where the bridge is installed.
REGISTRY_STREETNR String Street number where the bridge is installed.
REGISTRY_BUILDING String Building where the bridge is installed.
REGISTRY_APARTMENT String Apartment where the bridge is installed.
REGISTRY_ROOM String Room where the bridge is installed.
REGISTRY_NAME String Name associated with bridge.
REGISTRY_LOCATION Boolean If location has been completed. (This means, any location-specific environment variables not provided, will be interpreted as intensionally left blank, and user will not be prompted to input values for them.

Claiming ownership of bridge

Once the bridge has been configured, it will generate an iotdisco URI, and save it to its programd data folder. It will also create a file with extension .url, containing a shortcut with the iotdisco URI inside. A .png file with a QR code will also be generated. All three files contain information about the bridge, and allows the owner to claim ownership of it. This can be done by using the Neuro-Access App. This app is also downloadable for Android and iOS. You scan the QR code (or enter it manually), and claim the device. Once the device is claimed by you, you will receive notifications when someone wants to access the deice. They will only be able to access it with the ownerโ€™s permission. For more information, see:

Configuring the bridge

The bridge can be configured in detail by a client that implements the concentrator interface. Concentrators consist of data sources, each containing tree structures of nodes. Nodes may be partitioned into partitions, which permits the nesting of subsystems seamlessly into container systems. Each node can be of different types, and have different properties and underlying functionality. They can each implement then sensor interface and actuator interface.

You can use the Simple IoT Client to configure concentrators and their nodes in detail. An initial setup is done using the initial configuration of the bridge. The client is also available in the IoTGateway repository, in the Clients folder.

Node Types

The bridge includes several different node types that can be used to configure its operation:

  • The Modbus Gateway maintains a connection to a Modbus Gateway using TCP/IP, and converts requests into binary Modbus TCP/IP communication.

  • The XMPP Broker maintains a connection to an XMPP Broker. It allows the bridge to connect to other entities on the federated network and communicate with them. It supports communication with remote standalone sensors and actuators, as well as remote concentrators embedding devices into data sources and nodes. Such concentrators can be bridges to other protocols and networks.

    Note: The bridge has a client-to-server connection by default, setup during initial configuration. Through this connection, the bridge acts as a concentrator. Through the use of XMPP Broker nodes you can setup additional XMPP connections to other brokers. In these cases the bridge will only act as a client, to connect to remove devices for the purposes of interacting with them.

  • IP Host nodes allow you to monitor network hosts accessible from the bridge.

  • Script nodes allow you to create nodes with custom script logic. They can be used to interface bespoke devices in the network accessible from the bridge, for example.

  • Virtual nodes are placeholders where external logic (or script logic) can aggregate information in a way that makes them accessible by others in the federated network.

#new, #repository, #iot, #modbus, #xmpp, #bridge


MQTT-XMPP Bridge

The IoTBridgeMqtt repository provides an IoT bridge between devices connected to MQTT, for use in closed intra-networks or enterprise networks, and the harmonized XMPP-based Neuro-Foundation network, for open and secure cross-domain interoperation on the Internet.

Bridge topology
Bridge topology

To run the bridge, you need access to both an MQTT broker, and an XMPP broker, that supports the Neuro-Foundation extensions. You can use the Mosquitto broker for MQTT, and the TAG Neuron for XMPP.

Running and configuring the bridge

The code is written using .NET Standard, and compiled to a .NET Core console application that can be run on most operating systems. Basic configuration is performed using the console interface during the first execution, and persisted. You can also provide the corresponding configuration using environment variables, making it possible to run the bridge as a container. If an environmental variable is missing, the user will be prompted to input the value on the console.

Environmental Variable Type Description
XMPP_HOST String XMPP Host name
XMPP_PORT Integer Port number to use when connecting to XMPP (default is 5222)
XMPP_USERNAME String User name to use when connecting to XMPP.
XMPP_PASSWORD String Password (or hashed password) to use when connecting to XMPP. Empty string means a random password will be generated.
XMPP_PASSWORDHASHMETHOD String Algorithm or method used for password. Empty string means the password is provided in the clear.
XMPP_APIKEY String API Key. If provided together with secret, allows the application to create a new account.
XMPP_APISECRET String API Secret. If provided together with key, allows the application to create a new account.
MQTT_HOST String MQTT Host name
MQTT_TLS String If TLS encryption is to be used when connecting to the MQTT broker.
MQTT_PORT String Port number to use when connecting to MQTT (default is 1883 for unencrypted MQTT and 8883 for encrypted MQTT).
MQTT_USERNAME String User name to use when connecting to MQTT. Can be empty if no user credentials are provided.
MQTT_PASSWORD String Password to use when connecting to XMPP. Can be empty if no user credentials are provided.
REGISTRY_COUNTRY String Country where the bridge is installed.
REGISTRY_REGION String Region where the bridge is installed.
REGISTRY_CITY String City where the bridge is installed.
REGISTRY_AREA String Area where the bridge is installed.
REGISTRY_SRTEET String Street where the bridge is installed.
REGISTRY_STREETNR String Street number where the bridge is installed.
REGISTRY_BUILDING String Building where the bridge is installed.
REGISTRY_APARTMENT String Apartment where the bridge is installed.
REGISTRY_ROOM String Room where the bridge is installed.
REGISTRY_NAME String Name associated with bridge.
REGISTRY_LOCATION Boolean If location has been completed. (This means, any location-specific environment variables not provided, will be interpreted as intensionally left blank, and user will not be prompted to input values for them.

Claiming ownership of bridge

Once the bridge has been configured, it will generate an iotdisco URI, and save it to its programd data folder. It will also create a file with extension .url, containing a shortcut with the iotdisco URI inside. A .png file with a QR code will also be generated. All three files contain information about the bridge, and allows the owner to claim ownership of it. This can be done by using the Neuro-Access App. This app is also downloadable for Android and iOS. You scan the QR code (or enter it manually), and claim the device. Once the device is claimed by you, you will receive notifications when someone wants to access the deice. They will only be able to access it with the ownerโ€™s permission. For more information, see:

Configuring the bridge

The bridge can be configured in detail by a client that implements the concentrator interface. Concentrators consist of data sources, each containing tree structures of nodes. Nodes may be partitioned into partitions, which permits the nesting of subsystems seamlessly into container systems. Each node can be of different types, and have different properties and underlying functionality. They can each implement then sensor interface and actuator interface.

You can use the Simple IoT Client to configure concentrators and their nodes in detail. An initial setup is done using the initial configuration of the bridge. The client is also available in the IoTGateway repository, in the Clients folder.

Node Types

The bridge includes several different node types that can be used to configure its operation:

  • The MQTT Broker maintains a connection to an MQTT Broker, and allows the bridge to subcribe to content published on topics, as well as publish content to topics on the broker. The topic hierarchy will be modelled using MQTT Topic nodes, or derivatives. Common data types are recognized and parsed. You can read each topic individually, or a parent topic, and receive information from all child topics, as field values.

  • The XMPP Broker maintains a connection to an XMPP Broker. It allows the bridge to connect to other entities on the federated network and communicate with them. It supports communication with remote standalone sensors and actuators, as well as remote concentrators embedding devices into data sources and nodes. Such concentrators can be bridges to other protocols and networks.

    Note: The bridge has a client-to-server connection by default, setup during initial configuration. Through this connection, the bridge acts as a concentrator. Through the use of XMPP Broker nodes you can setup additional XMPP connections to other brokers. In these cases the bridge will only act as a client, to connect to remove devices for the purposes of interacting with them.

  • IEEE 1451 nodes are derivatives of MQTT nodes, and implement support for the IEEE 1451 family of standards, of which IEEE 1451.1.6 manages communication over MQTT.

  • IP Host nodes allow you to monitor network hosts accessible from the bridge.

  • Script nodes allow you to create nodes with custom script logic. They can be used to interface bespoke devices in the network accessible from the bridge, for example.

  • Virtual nodes are placeholders where external logic (or script logic) can aggregate information in a way that makes them accessible by others in the federated network.

#new, #repository, #iot, #mqtt, #xmpp, #bridge


Data Sheets in Digital Sensor Twins

The LegalLab repository contains an example smart contract for creating digital sensor twins. This template, together with the LegalLab utility, has been updated to support uploading and presentation of data sheets for the underlying sensors being mirrored digitally.

The process of attaching such data sheets is straight-forward:

  • Publish the new digital sensor template to your Neuron®, and get it approved.

  • Create a smart contract based on this template, pointing to the sensor you want to mirror.

  • Before signing the contract, upload any number of data-sheets appropriate for the digital twin. If these attachments are in the following formats, they will be presented together with sensor data from the sensor:

    • Plain text file (*.txt)
    • Markdown text file (*.md)
    • Image files (*.jpg, *.png, *.webp, and other supported formats)
    • Microsoft Word files, in the interoperable OpenXML format (*.docx)
    • Microsoft Excel files, in the interoperable OpenXML format (*.xlsx)
  • Once data sheets have been uploaded, sign the contract accordingly.
  • Once the token has been created, create a Present Report to view sensor data, together with associated data sheets.

Note: For performance reasons, it might be less resource-intensive and quicker to pre-convert MS Word files to Markdown, and upload the Markdown file.

Note 2: For security reasons, only files (actually Internet Content-Types) recognized by both LegalLab and the Neuron® will be accepted.

Note 3: To be able to upload and process Microsoft Word documents and Excel spreadsheets, you need to install the Microsoft Interoperability package. You can also check microsoft for more information related to Microsoft interoperability.

#new, #features, #contracts, #legallab, #sensor, #iot


Stockholm weather station for testing and development purposes

There’s a harmonized weather station of the Stockholm Weather available for anyone who needs to test or develop services that include sensor communication. The sensor is a bridge to the OpenWeatherMap API, and bridges incoming requests on XMPP to requests to the API, and back, live.

You can connect to it here:

stockholm.openweathermap@lab.tagroot.io
stockholm.openweathermap@lab.tagroot.io

Capabilities

Following is a brief list of some of the capabilities of the sensor:

  • It contains momentary, identity, status, peak, computed and historical values, so it is suitable for testing different categories of data.
  • It maintains a historical log of sensor data, so it can be used to test historical plots.
  • It reports a variety of physical units: Speed, Time, Temperature, Distance, Angles, Pressure, Percentage.
  • It reports a variety of field types: Numerical, physical quantities (i.e. numerical with precision and physical units), date and time, strings, links.

Authorization

The sensor will accept all connection requests, and all sensor data readout request, but will reject, by default, configuration requests. The owner of the node will receive notifications when someone wants to configure it, and may approve such requests on demand.

Setting up your own weather station sensor

You can setup your own OpenWeatherMap sensor, publishing weather station information for your location. Just follow the steps in the article Creating a harmonized and provisioned sensor for test.

#demo, #iot, #sensor, #api


Creating a harmonized and provisioned sensor for test

The OpenWeatherMapSensor repository contains a bridge between https://openweathermap.org/ and XMPP, and provides regular readouts, local storage of historical values, as well as harmonized interfaces for sensor data, control and provisioning. It can be used for testing purposes, or to introduce weather information into your smar city projects.

The sensor is provisioned, meaning it can be claimed by an owner. Access to, and authorization to read data (wholly or partially), as well as to enable or disable it, is controlled by the owner. You can use any client that supports IoT Harmonization to control the sensor. Examples include the TAG ID App, or the Simple IoT Client in the IoT Gateway repository. You can also access the sensor programmatically, via NuGets, as described in Mastering Internet of Things.

Download

You don’t need to clone and compile the OpenWeatherMapSensor repository repository to run the sensor on your machine. You can download it directly from the following link, and install it. Note that you may need to approve running the file on your machine, depending on what protection software you use: https://lab.tagroot.io/Downloads/OpenWeatherMapSensor/setup.exe

Configuration

Once the application is installed, it will run in a terminal window (it’s a console application). It will ask you for the following information in order. Correct information will be saved, and you will not be asked again. If you need to reconfigure the sensor later, you need to delete the Data folder that is generated in the folder of the application, and restart it.

Note: If running intro trouble during the configuration, you can always stop the console application using CTRL-Z, and resume where you left off, by running the console application again. You will find the application in the Start menu, under the name OpenWeatherMapSensorConsole.

API parameters

First, you need to provide information on how to connect to the API:

Open Weather Map API Key
You must get this API Key from https://home.openweathermap.org/api_keys, once you’ve created an account on their web page. Enter the API key when the app prompts you for it.
Location
This is the location you wish to publish weather for. It must be a recognizable location name, such as the name of the city you wish to get the weather from.
Country Code
This is the 2-letter country code in which the Location above is located.

Once these three parameters have been provided, the app will attempt to connect to the API and read data for the current location. If successful, the configuration will be saved, and you don’t have to enter it again. If not successful, you will be prompted to enter the information again.

XMPP parameters

The next step is to provide configuration for XMPP connectivity. The folllowing parameters have to be provided:

XMPP Broker
This is the domain name of the broker you wish the sensor to connect to.
Port
This is the port to connect to. (Application does not perform a DNS SRV lookup.). Default port is 5222.
User Name
The name of the account you wish to use.
Password
The password necessary to login to the account provided.

Once these parameters have been provided, the app will attempt to login to the XMPP network. If successful, parameters are saved, and you can continue. If not, you will be provided an opportunity to correct your entries.

Thing Registry

Next step is to provide locale-information for the Thing Registry. A Thing Registry is a service that allows the owner to find the device, and if the owner chooses to, also let other users find the device. The following parameters are optional, and are used when other users try to find devices of interest, based on location.

Country
Country code associated with device.
Region
Region (or state)
City
Name of the city
Area
Area within city.
Street
Name of street (without number)
StreetNr
Street number, including sub-numbering letters, etc.
Building
Building number
Apartment
Apartment number
Room
Room number
Name
Name associated with location

Ownership

Once the device has registered itself in the registry, it is time for you to claim ownership of the device. Ownership allows you to control who has access to the device, and what data they are permitted to read.

Ownership is claimed, by presenting the Thing Registry with exactly the same information as the device has presented to the Thing Registry. Apart from the information you’ve already entered, there are information about make and model, etc., as well as a secret key. To help you provide this information, the application presents you with a QR code, with all the information included. The QR-code is available in three different ways:

  • First, it is presented using block-characters, in the terminal window. If your terminal window supports block characters, you can simply scan the QR code from there.

  • The application also saves a Sensor.iotdisco text file in the installation folder. (You can find the installation folder, by simply clicking on the tab of the terminal window, and requesting to rename it.) Open this file in a text editor, and you’ll find the contents of the QR-code. If you’re a developer, you can paste this link manually into the app, to claim the device.

  • There is also a Sensor.iotdisco.url file saved in the installation folder. Click it to open a tab in your browser, showing a QR-code. Scan this QR code with your app, to claim the device.

Note: When claiming the device, you have the option to let the device be public. This does not mean everyone has access to the data in the device, or can control it. It just means anyone with access to the Thing Registry, is permitted to find it. If they want to read data from it, you, as an owner, will be asked if this is OK before any data can actually be read.

Connecting to device

Once the device has been claimed, you, or anyone else, can try to connect to it using the XMPP Address (JID) created when the application connected to the XMPP network. The format of the JID is UserName@Domain, where the Domain is the domain name (or host name) of the XMPP broker.

You connect to the device, by subscribing to presence of the device. At first, this request will be rejected by the device. At the same time as the request is rejected, a notification is sent to the owner, who can manually choose to accept, reject or ignore the request. Once accepted, your application will either automatically connect to the device, or you will have to manually subscribe to presence again. This second time, after the owner has accepted the request, the sensor app will accept the request. This does not mean you can read it yet however.

Reading device

Once you’re connected to the sensor, and can see it is online (i.e you have its full JID), you can request to read the sensor-data from it. As earlier, the first request will be rejected, if no formal approval has been given before. The first attempt, will generate a notification to the owner, who can choose how to handle this request. The owner can choose to deny access, or grant access, either fully, or partially (i.e. only to partial content). The decision can be based on your network identity, or based on other principles. Once granted access, you can try to read again, and this time, you will get access to the sensor data in the device.

Chat

The sensor app also supports chat. Once you’ve added the device to your contacts list, you can chat with it to read sensor data, or perform control actions. Try sending hi, or # to it, via chat, to see what happens.

#iot, #api, #repository


Posts tagged #iot

No more posts with the given tag could be found. You can go back to the main view by selecting Home in the menu above.