Using SparkplugCmd Utility as Sparkplug host application
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: consumer
The consumer command (shortened: c) contains sub-commands that allow you to consume Sparkplug data, i.e. act as a Sparkplug host application component in the Sparkplug system.
The argument that follows the consumer command is the resource descriptor for the Sparkplug broker that should be used. If omitted, it defaults to mqtt://localhost, i.e. it connects to the MQTT broker on your local machine, using unauthenticated TCP connection on port 1883.
If you simply enter the consumer command (optionally with a broker URL), the SparkplugCmd enters an interactive mode for this command, and you can continue by issuing one or more sub-commands, each on a separate line. Alternatively, you can include the sub-command directly following the consumer command (with its optional broker URL), in which case the sub-command will be performed immediately.
Examples:
consumer, or shortenedc
- This command will simply show the consumer> prompt, and allow you to enter further sub-commands. The sub-commands will all connect to "mqtt://localhost".
consumer mqtt://test.mosquitto.org, or shortenedc //test.mosquitto.org
- This command will show the consumer> prompt, and allow you to enter further sub-commands. The sub-commands will all connect to the specified MQTT broker.
consumer subscribePayload easyGroup, or shortenedc sp easyGroup
- This command will connect to "mqtt://localhost" and subscribe to all payloads from the Sparkplug group with ID "easyGroup". Details of the sub-command are explained further below.
Command: consumer subscribePayload
Use the subscribePayload command (shortened: sp) to subscribe to payload notifications from an edge node or device. The received payload are displayed in a table form.
Command: consumer subscribeMetric
Use the subscribeMetric command (shortened: sm) to subscribe to metric notifications from an edge node or device. Each received metric notification is displayed separately (the payloads are "unpacked").
Command: consumer publishMetric
Use the publishMetric (shortened: pm) command to publish a command metric to an edge node or device. The command has following arguments:
| metricName | Metric Name |
| typedValue | Value to be written |
| groupId | Group ID (default #) |
| edgeNodeId | Edge Node ID (default #) |
| deviceId | Device ID |
Omit the deviceId argument if you are publishing to an edge node metric. Include non-empty deviceId if you are publishing to a device metric.
Example: consumer publishMetric Static/Int32Value [Int32]3141 easyGroup easySparkplugDemo data
Command: consumer edgeNodeRebirth
Use the edgeNodeRebirth command (shortened: enr) to publish a command to rebirth an edge node. This is a shortcut for publishing a 'true' boolean value to the metric named "Node Control/Rebirth" on the given edge node. This metric is used to request a new NBIRTH and DBIRTH(s) from the edge node.
Example: consumer edgeNodeRebirth easyGroup easySparkplugDemo