-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sparkplug): added DataTransport layer (#5077)
* feat(sparkplug): added DataTransportLayer Signed-off-by: Marcello Martina <[email protected]> * build: added Paho client JAR in lib Signed-off-by: Marcello Martina <[email protected]> --------- Signed-off-by: Marcello Martina <[email protected]>
- Loading branch information
1 parent
597bcf6
commit 5297748
Showing
15 changed files
with
1,474 additions
and
27 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
kura/org.eclipse.kura.cloudconnection.sparkplug.mqtt.provider/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
/target | ||
/bin | ||
/lib | ||
.vscode | ||
generated-sources/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ output.. = target/ | |
bin.includes = META-INF/,\ | ||
.,\ | ||
OSGI-INF/,\ | ||
about.html | ||
about.html,\ | ||
lib/ |
Binary file added
BIN
+217 KB
...a.cloudconnection.sparkplug.mqtt.provider/lib/org.eclipse.paho.client.mqttv3-1.2.1.k2.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
.../main/java/org/eclipse/kura/cloudconnection/sparkplug/mqtt/message/SparkplugPayloads.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech | ||
*******************************************************************************/ | ||
package org.eclipse.kura.cloudconnection.sparkplug.mqtt.message; | ||
|
||
import java.util.Date; | ||
|
||
import org.eclipse.tahu.protobuf.SparkplugBProto.DataType; | ||
import org.eclipse.tahu.protobuf.SparkplugBProto.Payload; | ||
|
||
public class SparkplugPayloads { | ||
|
||
private SparkplugPayloads() { | ||
} | ||
|
||
public static byte[] getNodeDeathPayload(long bdSeq) { | ||
return new SparkplugBProtobufPayloadBuilder().withBdSeq(bdSeq, new Date().getTime()).build(); | ||
} | ||
|
||
public static byte[] getNodeBirthPayload(long bdSeq, long seq) { | ||
long timestamp = new Date().getTime(); | ||
|
||
Payload.Builder protoMsg = Payload.newBuilder(); | ||
|
||
Payload.Metric.Builder bdSeqMetric = Payload.Metric.newBuilder(); | ||
bdSeqMetric.setName("bdSeq"); | ||
bdSeqMetric.setLongValue(bdSeq); | ||
bdSeqMetric.setDatatype(DataType.Int64.getNumber()); | ||
bdSeqMetric.setTimestamp(timestamp); | ||
protoMsg.addMetrics(bdSeqMetric.build()); | ||
|
||
Payload.Metric.Builder rebirthMetric = Payload.Metric.newBuilder(); | ||
rebirthMetric.setName("Node Control/Rebirth"); | ||
rebirthMetric.setBooleanValue(false); | ||
rebirthMetric.setDatatype(DataType.Boolean_VALUE); | ||
protoMsg.addMetrics(rebirthMetric.build()); | ||
|
||
protoMsg.setSeq(seq); | ||
protoMsg.setTimestamp(timestamp); | ||
|
||
return protoMsg.build().toByteArray(); | ||
} | ||
|
||
} |
Oops, something went wrong.