MOD11: DNS SD listener - GoranErdeljan/TINF19C-Team-4-Service-Registry GitHub Wiki
Created by Benedict Wetzel
1. Introduction
The module searches for DNS-SD entries in the network and publishes their information at the MQTT-Broker so that they are registered at the OI4-Registry. To register a device at the OI4-registry, the Master-Asset-Model of the device is published on the MQTT-Broker. This module is a sub-module of MOD10, which is the main interface between the mDNS based service-discovery with DNS-SD and the MQTT based specifications used by the OI4.
2. Requirements
The following requirements are covered by this module:
3. Prerequisites
In order to use this module the following prerequisites should be met:
- The developer should have a working computer that can access the internet
- The developer should use a Linux-based Operating-System
- The developer should have Node.js version 12.14.1 or higher installed
- The developer should have NPM version 7.10.0 or higher installed
- The developer should have at least some basic experience with Node.js
4. Dependencies
This module depends on the following items:
5. Technical overview
This module is used to listen to DNS-SD services that might be announced in the Network and publish their information on the MQTT-Broker. To do so, it is needed to add a callback through the dnssdListener file, that calls the addDevice function of the addToRegistry file. In this callback you can use MOD13 to validate the TXT-Records and call addDevice accordingly. MOD13 can also be used to build the Master-Asset-Model, that is required by addDevice, from the TXT-Records.
dnssdListener.js
5.1This file handles discovery of DNS-SD services. To do that it sends a mDNS-Query requesting information on any services every 30 seconds. It also has functionalities to add callbacks that are called for every discovered service. It depends on the NPM package mqttjs.
Function | Description |
---|---|
start | This function is used to start the module. It registers a function to be called at an intervall of 30 seconds. That function sends a mDNS-Query requesting information on any services. For each service that is found, the registered callbacks are called. |
addCallback | Register a function as a callback |
addToRegistry.js
5.2This file handles registering services at the OI4-Registry by publishing their information on the MQTT-Broker. It also simulates Health, MAM and Profile-messages for those services. Added to that it publishes information about the application itself and sends Health, Profile, License, LicenseText, Config and PublicationList-messages for the application. This file depends on the NPM package multicast-dns.
Function | Description |
---|---|
setConfig | Set the configuration of this module |
start | Starts the module. If the configuration needs to be changed, setConfig must be called before start. Subscribes to all topics concerning this Application at the MQTT-Broker and registers a Handler function for messages on the MQTT-Broker that responds to those messages |
addDevice | Adds a new device, for which information should be published an the MQTT-Broker and therefore be added to the OI4-Registry |
pubHealth | This function is used to publish responses to Health-requests concerning the interface itself on the MQTT-Broker |
pubProfile | This function is used to publish responses to Profile-requests concerning the interface itself on the MQTT-Broker |
pubLicense | This function is used to publish responses to License-requests concerning the interface itself on the MQTT-Broker |
pubLicenseText | This function is used to publish responses to LicenseText-requests concerning the interface itself on the MQTT-Broker |
pubConfig | This function is used to publish responses to Config-requests concerning the interface itself on the MQTT-Broker |
pubPublicationList | This function is used to publish responses to PublicationList-requests concerning the interface itself on the MQTT-Broker |
buildmammessage | Builds the payload of the message which is used to publish the Master-Asset-Model |
buildmsg | Builds an OI4 compliant message which can be published on the MQTT-Broker |
package.json
5.3Sets the dependencies and is used by NPM to install the required NPM packages