Using SparkplugCmd Utility as Sparkplug Edge Node: Difference between revisions

From OPC Labs Knowledge Base
Line 8: Line 8:
== Command: '''edgeNode''' ==
== Command: '''edgeNode''' ==


This command creates a Sparkplug edge node with pre-defined content (metrics on the edge node itself, and devices with further metrics on them). By default, the edge node will connect (when started) to "mqtt://localhost" (unauthenticated TCP connection, using port 1883).
The <code>edgeNode</code> command (shortened: <code>en</code>) creates a Sparkplug edge node with pre-defined content (metrics on the edge node itself, and devices with further metrics on them). By default, the edge node will connect (when started) to "mqtt://localhost" (unauthenticated TCP connection, using port 1883).
=== Arguments ===
=== Arguments ===



Revision as of 10:11, 25 August 2025

For general information about the SparkplugCmd tool, see Category:SparkplugCmd Utility.

Commands, Arguments and Options

The commands described here can be entered at the SparkplugCmd> prompt, or directly on the command-line invoking the SparkplugCmd utility.

Command: edgeNode

The edgeNode command (shortened: en) creates a Sparkplug edge node with pre-defined content (metrics on the edge node itself, and devices with further metrics on them). By default, the edge node will connect (when started) to "mqtt://localhost" (unauthenticated TCP connection, using port 1883).

Arguments

The command has following arguments:

resourceDescriptor Sparkplug broker descriptor (default mqtt://localhost/)
groupId Group ID (default easyGroup)
edgeNodeId Edge Node ID

For further information on the URL syntax in resourceDescriptor, and the configurable parameters of the MQTT channel, see OpcLabs.MqttNet communication package.

The edgeNodeId argument sets the ID of the Sparkplug edge node. When this value is empty (which is the default), the component will auto-generate an edge node ID that is conformant with the Sparkplug syntactic rules. It also attempts to make it unique within the Sparkplug system. Sparkplug host applications use the edge node ID to subscribe to metrics from the edge node and its devices, and to send commands to them.

Options

The edgeNode command has following specific options:

-ci|--clientId <string> Client ID
-phi|--primaryHostId <string> Primary Host ID
-sv|--sparkplugVersion <sparkplugVersion> Sparkplug version

The clientId option sets the client ID that will be used for the connection to the MQTT broker. When this value is empty (which is the default), the component will generate the client ID automatically, attempting to make it unique in the Sparkplug system.

The primaryHostId option sets the Sparkplug host ID of the Sparkplug primary host application for this edge node. When this value is empty (which is the default), the edge node will not be tied to anyprimary host application, and it will publish data whenever it is connected to the broker. When this value is set to a non-empty string, the edge node will observer the status of the specified primary host application, and will only publish data when the primary host application is online.

With the sparkplugVersion option, you can set a combination of following flags: None|Specification22|Specification30|PayloadA|PayloadB . The flags represent the versions of the Sparkplug specification, payload encoding schemes and their versions.

Examples

  • edgeNode, or shortened en
This command will simply show the edgeNode prompt, and allow you to enter further sub-commands. The sub-commands will all connect to "mqtt://localhost".
  • edgeNode mqtt://test.mosquitto.org, or shortened en //test.mosquitto.org
This command will show the edgeNode> prompt, and allow you to enter further sub-commands. The sub-commands will all connect to the specified MQTT broker.
  • edgeNode mqtt://test.mosquitto.org easyGroup easySparkplugDemo start, or shortened en //test.mosquitto.org easyGroup easySparkplugDemo start
This command will connect to "mqtt://test.mosquitto.org" and act as an edge node with ID "easySparkplugDemo" in Sparkplug group with ID "easyGroup". The start sub-command is explained further below.

Command: edgeNode start

This command starts the Sparkplug edge node, using the parameters specified in the edgeNode command.

Sub-commands

By default, the edge node runs until the you press X on the keyboard. Use the !wait sub-command to specify a finite duration.