GithubHelp home page GithubHelp logo

hartl3y94 / oisp-mqtt-gw Goto Github PK

View Code? Open in Web Editor NEW

This project forked from open-iot-service-platform/oisp-mqtt-gw

0.0 0.0 0.0 131 KB

License: Apache License 2.0

Shell 3.92% JavaScript 95.90% Dockerfile 0.18%

oisp-mqtt-gw's Introduction

iotkit-gateway

FOSSA Status

==============

This repository contains a Bridge between MQTT and Kafka for OISP. The Bridge also handles the auth, acl and load-balancing for MQTT and MQTT with SparkplugB

1. To enable SparkplugB Data Ingestion capability only at GW

To enable sparkplugB functionality, add config related to sparkplugB in the config.js

  1. Add below section in the config section on file config.js

SparkplugB config which must be set when handling SparplugB standard message

  • @spBKafkaProduce: true -> will enable producing kafka message on topic "SparkplugB" with spB format data @ngsildKafkaProduce: true -> will enable producing kafka message on topic "ngsildSpB" with ngsild format data
  • @subscribe -> Subscribed to all the topic with "spBv1.0" at start
     "sparkplug": {
        "spBKafkaProduce": true, 
        "spBkafkaTopic": "sparkplugB",
        "ngsildKafkaProduce": false,
        "ngsildKafkaTopic": "ngsildSpB"
        "topics": {
            "subscribe": {
                "sparkplugb_data_ingestion": "spBv1.0/+/+/+/+"
            },
            "publish": {
            "error": "server/error/{accountId}/{deviceId}"
             }
        }
    },
  1. SpB-mqttgw uses different name of kafka client to get distinguished (ClientId: spBFrontend-metrics)
  2. CID is used as alias, as sparkplugB standard suggest unique id as alias in data metric element. Data message looks like below:
    var cid = "0c574252-31d5-4b76-bce6-53f2c56b544d";
    var DataMessage = {
            timestamp: 12345,
            metrics: [{
                name : "temp",
                alias : cid,
                timestamp : 12345,
                dataType : "float",
                value: 123
            }],
            seq: 1
         };

1. To enable NGSI-LD Data Ingestion capability over SpB at GW

  1. To enable NGSI-LD format data sharing, set flag of sparkplugB and NGSI-ld true as shown below

@ngsildKafkaProduce: true -> will enable producing kafka message on topic "ngsildSpB" with ngsild format data for metric whose names are like : name: "Relationship/xxxx" or "Properties/xxxx"

     "sparkplug": {
        "spBKafkaProduce": true, 
        "spBkafkaTopic": "sparkplugB",
        "ngsildKafkaProduce": true, 
        "ngsildKafkaTopic": "ngsildSpB"
        "topics": {
            "subscribe": {
                "sparkplugb_data_ingestion": "spBv1.0/+/+/+/+"
            },
            "publish": {
            "error": "server/error/{accountId}/{deviceId}"
             }
        }
    },
  • Config Table for Different flag setting when SparkplugB is enable "enabled": true;
spBKafkaProduce ngsildKafkaProduce KafkaTopic
true true SpB NGSI-LD format metric on "ngsildSpB" topic; Rest on "sparkplugB"
true false All message on "sparkplugB"
false true SpB NGSI-LD format metric on "ngsildSpB" topic; Rest ignored
false false All message on "metric"
  1. NGSI-LD message format converted from received SpB message format
  • For conversion of Relationship NGSI-LD Data

Eg. of SpB message payload containing NGSI-LD format Relationship Data:

{
    "timestamp":1655974018778,"
    "metrics":
	    [{
	    "name":"Relationship/https://industry-fusion.com/types/v0.9/hasFilter",
	    "alias":"fbb3b7cd-a5ff-491b-ad61-d43edf513b7a",
	    "timestamp":1655974018777,
	    "dataType":"string",
	    "value":"urn:filter:1"}],
    "seq":2
},

Eg. of SpB Converted into NGSI-LD Relationship data format:

{
  “id”: “urn:plasmacutter:1\\https://industry-fusion.com/types/v0.9/hasFilter”,
  “entityId”: “urn:plasmacutter:1”,
  “name”: “https://industry-fusion.com/types/v0.9/hasFilter”,
  “type”: “https://uri.etsi.org/ngsi-ld/Relationship”,
  “https://uri.etsi.org/ngsi-ld/hasObject”: “urn:filter:1”,
  “nodeType”: “@id”,
  “index”: 0
}
  • For conversion of Property NGSI-LD Data with nodeType @value(Means literals)
{
    "timestamp":1655974018778,"
    "metrics":
	    [{
	    "name":"Properties//https://industry-fusion.com/types/v0.9/state",
	    "alias":"fbb3b7cd-a5ff-491b-ad61-d43edf513b7a",
	    "timestamp":1655974018777,
	    "dataType":"string",
	    "value":"https://industry-fusion.com/types/v0.9/state_OFF"}],
    "seq":2
},

Eg. of SpB Converted into NGSI-LD Property data format:

{
  “id”: “urn:plasmacutter:1\\https://industry-fusion.com/types/v0.9/state”,
  “entityId”: “urn:plasmacutter:1”,
  “name”: “https://industry-fusion.com/types/v0.9/state”,
  “type”: “https://uri.etsi.org/ngsi-ld/Property”,
  “https://uri.etsi.org/ngsi-ld/hasValue”: “https://industry-fusion.com/types/v0.9/state_OFF”,
  “nodeType”: “@value”,
  “index”: 0
}
  • For conversion of Property NGSI-LD Data with nodeType @id (Means IRI type)

SpB message payload containing NGSI-LD format of Property with IRI type i.e @id Will be Template. It will be added in next release of it. Eg. of template Spb data can be as below:

timestamp: 12345,
	metrics: [{
                name : "propertyInstanceIRI",
                type : template,
                timestamp : 12345,
                value: {
		   “templateRef” : “propertyTemplate”
		   “isdefination”:  false,
		   “metrics”: [
		    {   “name”: "https://industry-fusion.com/types/v0.9/state",
                “dataType” : “string”-> always string
                “ valueType” : “@id”,
                “value”:  "https://industry-fusion.com/types/v0.9/state_OFF",
                "index": 0
            }]
		 }
	  }],
            seq: 1

License

FOSSA Status

oisp-mqtt-gw's People

Contributors

arkocal avatar fossabot avatar mericfeyz avatar oguzcankirmemis avatar wagmarcel avatar yshashix avatar

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.