ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
sparkplug.h File Reference

Sparkplug B topic and payload codec (PROTOCORE_ENABLE_SPARKPLUG) - a zero-heap builder and reader for the Sparkplug B topic namespace and its Google Protocol Buffers payload. More...

#include "protocore_config.h"

Go to the source code of this file.

Detailed Description

Sparkplug B topic and payload codec (PROTOCORE_ENABLE_SPARKPLUG) - a zero-heap builder and reader for the Sparkplug B topic namespace and its Google Protocol Buffers payload.

The governing standard is not IETF. Sparkplug is an Eclipse Foundation specification: Sparkplug 3.0.0, Eclipse Sparkplug Contributors. It rides MQTT, which is an OASIS standard - Sparkplug 3.0.0 sec 1.5 (Normative References) names MQTT Version 3.1.1 Plus Errata 01, OASIS Standard Incorporating Approved Errata 01, and MQTT Version 5.0, OASIS Standard. No RFC governs either one, and none is cited here.

Sparkplug 3.0.0 sec 4.1 gives the topic:

namespace/group_id/message_type/edge_node_id/[device_id]

The namespace element is the UTF-8 constant spBv1.0 (sec 4.1.1). group_id (sec 4.1.2), edge_node_id (sec 4.1.4) and device_id (sec 4.1.5) are UTF-8 excluding the reserved +, / and #. sec 4.1.3 defines nine message_type values. sec 4.1.5 states device_id MUST be included with DBIRTH, DDEATH, DDATA and DCMD, and MUST NOT be included with NBIRTH, NDEATH, NDATA, NCMD and STATE. The separator between elements is the MQTT topic level separator (MQTT Version 5.0 sec 4.7.1.1).

Sparkplug 3.0.0 sec 6.4.1 (Google Protocol Buffer Schema) gives the payload. Payload carries timestamp(1), metrics(2, repeated), seq(3), uuid(4) and body(5). Each Metric carries name(1), alias(2), timestamp(3), datatype(4), is_historical(5), is_transient(6), is_null(7), metadata(8), properties(9), and one member of the value oneof - int_value(10), long_value(11), float_value(12), double_value(13), boolean_value(14), string_value(15), bytes_value(16), dataset_value(17), template_value(18), extension_value(19).

This codec covers name, alias, timestamp, datatype and the first six value members. is_historical, is_transient, is_null, metadata, properties, bytes_value, dataset_value, template_value and extension_value are neither written nor reported.

Built on the Protocol Buffers codec (services/iot/protobuf) and published with the MQTT client.

The module exports one symbol, Sparkplug. Everything in sparkplug.c has internal linkage.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file sparkplug.h.