Overview – Sparkplug B

Sparkplug B is an industry-standard that enables common topic and payload definitions on top of a standard MQTT data transport layer.

OAS can be configured in a number of ways to act as a Primary Application, Secondary Application or Edge of Network (EoN) node. It can even be configured as both a host and an EoN to support scenarios such as acting as a data proxy and protocol conversion.

👉 See the following links to get started with Sparkplug B:

Mode

The OAS platform provides three different modes of operation when using a Sparkplug B driver:

  • Edge of Network (EoN) Node (Edge Node)
  • Primary Application (Host App)
  • Secondary Application (Client App)

Edge Node

To configure your OAS instance as an EoN node you will first create a Sparkplug B driver instance where the Mode parameter is set to Edge Node and configure the relevant properties such as the Host ID, Group ID and Edge Node ID. The driver will manage the connection to the Primary Application.

For each Tag that you wish to publish using the Sparkplug B interface, you have to set the Host Group ID, Host Edge Node ID, Host Device ID, and Host Metric properties. This works for any Tag that you have configured in your OAS instance irrespective of the data source configured on the Tag. This allows OAS to act as a gateway between various device protocols and convert data to MQTT.

With the Edge Node configuration you can also manage the Host Mode to be either Self Hosted or Remote Hosted. When self hosted, the state of the Tag will be managed by whether the OAS instance is in runtime mode or not. When remote hosted, the state is managed by the Primary Application.

Host App

To configure OAS as a Primary Application node you will first create a Sparkplug B driver instance where the Mode parameter is set to Host App and set the Host ID. In this mode, the driver will receive MQTT messages that are destined to the given Host ID.

If Add Client Tags Automatically is selected then OAS will automatically add tags to the Sparkplug B instance. You can further control which Tags are added based on Group, Edge Node and Device filters.

Client App

When the Mode parameters is set to Client App the node will act as a Secondary Application. This is similar to the Host App configuration, but it will only subscribe to the Tags and the data changes rather. It will not track the state of nodes.

MQTT Broker

When configuring a Sparkplug B driver, you can choose to connect to the internal OAS MQTT broker or you can use an external MQTT broker. The driver configuration provides properties that you can use to configure the connection and security parameters for your broker:

  • Host: The MQTT broker IP address or host name.
  • Port: The MQTT broker port number. [1883]
  • User Name: The username used to authenticate into the MQTT broker.
  • Password: The password used to authenticate into the MQTT broker.
  • Keep Alive Time: The MQTT broker connection keep-alive time in seconds. [60]
  • Reconnect Time: How long to wait before reconnecting if connection is lost in seconds. [1]
  • Buffer Timeout: The time in seconds the broker must respond after a write, if not responsive the buffer will be cleared. [0]
  • Max Buffer Messages: The maximum number of messages that can be queued before older messages are dropped. [30,000]
  • Protocol Version: The MQTT protocol version. [V311]
  • Client ID: The MQTT client ID.
  • Return to Online: The frequency in seconds to check for good communications when the interface is taken offline. [60]

The OAS MQTT broker can be configured using MQTT Broker tab in the Configure > Options screen. If you have the internal broker running, you can set the Host to localhost or to the IP or host name of another OAS instance that is running the MQTT broker. You will also need to configure the port, username, password and SSL/TLS parameters based on the broker configuration.

Failover

The Sparkplug B driver supports configuration of a failover MQTT broker. You can do this by setting the Enable Failover checkbox and then filling in the failover connection properties. The secondary connection will be used if the primary interface is deemed to be offline. It will switch back to the primary interface if it becomes available.