Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ is used to generate the code for each specific language.
In addition to Protobuf datatypes and native programming language datatypes there are also
'Sparkplug datatypes'. These are defined in the
link:#payloads_b_google_protocol_buffer_schema[Sparkplug Protobuf Schema]. These datatypes are those
that are used for Sparkplug Metrics. Every Metric must include a Sparkplug Datatype in the NBIRTH or
DBIRTH message depending on whether the Metric is a 'Node level' or 'Device level' metric. Each of
that are used for Sparkplug Metrics. Every Metric must include a Sparkplug Datatype in the NMETA or
DMETA message depending on whether the Metric is a 'Node level' or 'Device level' metric. Each of
the Sparkplug Datatypes is then represented by a Google Protobuf datatype.

[[introduction_normative_references]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ Sparkplug Edge Node.

A Sparkplug Command is a strongly typed, callable function exposed by a Sparkplug Edge Node or
Device. A command declares a typed signature consisting of the input arguments it accepts and the
output results it returns, and it is included in the BIRTH certificate alongside the Edge Node's
or Device's other metrics. A Host Application invokes a command using a correlated request/response
exchange so that returned data and error codes can be reliably matched back to the request. Commands
output results it returns, and it is included in the NMETA or DMETA alongside the Edge Node's
or Device's other metric definitions. A Host Application invokes a command using a correlated
request/response exchange so that returned data and error codes can be reliably matched back to the
request. Commands
are optional. An Edge Node or Device may expose no commands at all. The structure and behavior of
commands are defined in the link:#payloads_p_command[Command Section] and the
link:#operational_behavior_commands_typed[Typed Commands and Command Responses Section].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1645,9 +1645,10 @@ long as they have different timestamps.
all metrics where is_historical=false, NBIRTH and NDATA messages MUST keep metric values in
chronological order in the list of metrics in the payload.*#
* [tck-testable tck-id-operational-behavior-data-publish-node-metric-datatype]#[yellow-background]*[tck-id-operational-behavior-data-publish-node-metric-datatype] For
all metrics in an NBIRTH, the datatype and corresponding protobuf datatype MUST NOT change in
subsequent NDATA messages. If it does, the Host Application MUST send a rebirth request to the
offending Edge Node.*#
all metrics defined in an NMETA, the value carried in subsequent NDATA messages MUST use the
TypedValue field that the datatype declared for that metric in the NMETA maps to. If it does not,
the Host Application MUST send a rebirth request to the offending Edge Node, following the rules in
the link:#operational_behavior_rebirth[Rebirth Requests] section.*#

Rules for Device data (DBIRTH and DDATA) messages:

Expand All @@ -1671,17 +1672,23 @@ long as they have different timestamps.
all metrics where is_historical=false, DBIRTH and DDATA messages MUST keep metric values in
chronological order in the list of metrics in the payload.*#
* [tck-testable tck-id-operational-behavior-data-publish-device-metric-datatype]#[yellow-background]*[tck-id-operational-behavior-data-publish-device-metric-datatype] For
all metrics in an DBIRTH, the datatype and corresponding protobuf datatype MUST NOT change in
subsequent DDATA messages. If it does, the Host Application MUST send a rebirth request to the
offending Edge Node.*#
all metrics defined in a DMETA, the value carried in subsequent DDATA messages MUST use the
TypedValue field that the datatype declared for that metric in the DMETA maps to. If it does not,
the Host Application MUST send a rebirth request to the offending Edge Node, following the rules in
the link:#operational_behavior_rebirth[Rebirth Requests] section.*#
** Non-normative comment: a mismatch is evaluated against the declaration in the NMETA or DMETA,
which a rebirth does not change, so an Edge Node that keeps publishing the same mismatched value
will keep mismatching after the rebirth it triggered. A Host Application is expected to limit the
rate at which it requests rebirths for this condition rather than to request one for every offending
message.

[[operational_behavior_commands]]
=== Commands

Commands are used in Sparkplug to allow Sparkplug Host Applications to send data to Sparkplug Edge
Nodes. Examples include writing to outputs of Sparkplug Edge Nodes and Devices or to call 'Node
Control' or 'Device Control' commands. Custom command endpoints can be declared in an NBIRTH or
DBIRTH message by an Edge Node or Device that may support functionality such as rebooting an Edge
Control' or 'Device Control' commands. Custom command endpoints can be declared in an NMETA or
DMETA message by an Edge Node or Device that may support functionality such as rebooting an Edge
Node or Device. This is up to the Sparkplug implementor to define what functionality can be exposed.

Security and access is an important aspect of commands. It may be the case that not all Sparkplug
Expand Down Expand Up @@ -1768,10 +1775,10 @@ For Edge Node level commands, the following rules must be followed.
* [tck-testable tck-id-operational-behavior-commands-ncmd-verb]#[yellow-background]*[tck-id-operational-behavior-commands-ncmd-verb] An
Edge Node level command MUST use the NCMD Sparkplug verb.*#
* [tck-testable tck-id-operational-behavior-commands-ncmd-metric-name]#[yellow-background]*[tck-id-operational-behavior-commands-ncmd-metric-name] An
NCMD message SHOULD include a metric name that was included in the associated NBIRTH message for the
Edge Node.*#
** Sparkplug Edge Node Applications should be resilient to receiving metrics names that were not
included in the NBIRTH message.
NCMD message SHOULD identify a metric that was defined in the associated NMETA for the Edge
Node.*#
** Sparkplug Edge Node Applications should be resilient to receiving metrics that were not defined
in the NMETA.
* [tck-testable tck-id-operational-behavior-commands-ncmd-metric-value]#[yellow-background]*[tck-id-operational-behavior-commands-ncmd-metric-value] An
NCMD message MUST include a compatible metric value for the metric name that it is writing to.*#
** In other words, if the metric has a datatype of a boolean the value must be true or false.
Expand All @@ -1781,10 +1788,9 @@ For Device level commands, the following rules must be followed.
* [tck-testable tck-id-operational-behavior-commands-dcmd-verb]#[yellow-background]*[tck-id-operational-behavior-commands-dcmd-verb] A
Device level command MUST use the DCMD Sparkplug verb.*#
* [tck-testable tck-id-operational-behavior-commands-dcmd-metric-name]#[yellow-background]*[tck-id-operational-behavior-commands-dcmd-metric-name] A
DCMD message SHOULD include a metric name that was included in the associated DBIRTH message for the
Device.*#
** Sparkplug Edge Node Applications should be resilient to receiving metrics names that were not
included in the DBIRTH message.
DCMD message SHOULD identify a metric that was defined in the associated DMETA for the Device.*#
** Sparkplug Edge Node Applications should be resilient to receiving metrics that were not defined
in the DMETA.
* [tck-testable tck-id-operational-behavior-commands-dcmd-metric-value]#[yellow-background]*[tck-id-operational-behavior-commands-dcmd-metric-value] A
DCMD message MUST include a compatible metric value for the metric name that it is writing to.*#
** In other words, if the metric has a datatype of a boolean the value must be true or false.
Expand All @@ -1793,7 +1799,7 @@ DCMD message MUST include a compatible metric value for the metric name that it
==== Typed Commands and Command Responses

In addition to writing to output metrics, a Host Application can invoke strongly typed commands that
an Edge Node or Device includes as Command metrics in its BIRTH. A command is a callable function
an Edge Node or Device includes as Command metrics in its META. A command is a callable function
with a typed signature: it declares the inputs it accepts and the outputs it returns. Invoking a
command follows a correlated request/response pattern so that the result, including any returned
data or error code, can be reliably matched back to the request that produced it. The structure of a
Expand All @@ -1804,17 +1810,18 @@ includes the argument values and a correlation_id. The Edge Node executes the co
Node publishes an NRESP or DRESP that echoes the correlation_id and carries the execution status and
any results.

* [tck-testable tck-id-operational-behavior-command-definition-birth]#[yellow-background]*[tck-id-operational-behavior-command-definition-birth] An
Edge Node MUST include every command it supports as a Command metric in the NBIRTH (for Edge Node
level commands) or DBIRTH (for Device level commands).*#
* [tck-testable tck-id-operational-behavior-command-definition-meta]#[yellow-background]*[tck-id-operational-behavior-command-definition-meta] An
Edge Node MUST include every command it supports as a Command metric in the NMETA (for Edge Node
level commands) or DMETA (for Device level commands).*#
* [tck-testable tck-id-operational-behavior-command-request-correlation]#[yellow-background]*[tck-id-operational-behavior-command-request-correlation] A
Host Application that invokes a command MUST include a correlation_id in the Command object of the
NCMD or DCMD message.*#
** The correlation_id SHOULD be unique among the Host Application's outstanding command requests so
that each response can be unambiguously matched to its request.
* [tck-testable tck-id-operational-behavior-command-request-arg-datatype]#[yellow-background]*[tck-id-operational-behavior-command-request-arg-datatype] A
Host Application that invokes a command MUST supply argument values whose datatypes are compatible
with the argument definitions supplied in the corresponding BIRTH Command Definition.*#
with the argument definitions supplied in the corresponding Command Definition in the NMETA or
DMETA.*#
* [tck-testable tck-id-operational-behavior-command-response-verb]#[yellow-background]*[tck-id-operational-behavior-command-response-verb] On
receiving a command, an Edge Node MUST publish a command response using the NRESP Sparkplug verb for
Edge Node level commands and the DRESP Sparkplug verb for Device level commands.*#
Expand All @@ -1823,7 +1830,8 @@ command response MUST include the same correlation_id that was included in the c
produced it.*#
* [tck-testable tck-id-operational-behavior-command-response-results]#[yellow-background]*[tck-id-operational-behavior-command-response-results] On
successful execution of a command that defines results, the command response MUST include a result
value for every result that was included in the corresponding BIRTH Command Definition.*#
value for every result that was included in the corresponding Command Definition in the NMETA or
DMETA.*#
* [tck-testable tck-id-operational-behavior-command-error-status]#[yellow-background]*[tck-id-operational-behavior-command-error-status] If
a command cannot be executed because it is unknown, its arguments are incompatible, or its execution
fails, the Edge Node MUST publish a command response with a non-zero status code rather than silently
Expand Down
Loading
Loading