Skip to main content

Actions API

The Actions API exposes module functionality to ArmorLink tools.

Actions are discoverable through the configuration descriptor and can be triggered through normal ArmorLink Commands routed by the Gateway.

For the conceptual overview, see Actions.

Basic Example

module.actions()
.add("toggleFaceplate")
.label("Toggle Faceplate")
.section("Faceplate")
.command("Facemask", "toggle")
.stylePrimary()
.onExecute([] {
toggleFaceplate();
});

This defines an Action that:

  • Uses toggleFaceplate as internal identifier.
  • Is shown as Toggle Faceplate.
  • Appears in the Faceplate section.
  • Reacts to the Facemask / toggle Command.
  • Runs toggleFaceplate() when triggered.

add

module.actions().add("openHelmet");

The ID should be unique inside the module. Keep IDs stable because tools and profiles may reference them.

Metadata

MethodDescription
.label("...")User-facing label.
.section("...")Descriptor section where the action appears. Defaults to General.
.description("...")Longer help text for setup tools.
.command(entity, command)Command pair that triggers the action.
.enabled(false)Marks the action as unavailable in generated UIs.
.advanced()Marks the action as advanced.
.confirm("...")Requires confirmation before tools execute the action.
.stylePrimary()Preferred/main action styling.
.styleSecondary()Default action styling.
.styleDanger()Dangerous/destructive action styling.
.onExecute(...)Callback executed when the matching command is received.

Command Binding

.command("Facemask", "open")

An Action runs when the module receives a matching ArmorLink Command.

ArmorLink.sendCommand("Helmet", "Facemask", "open");

The target selects the module. The entity and command select the action.

Confirmation

Use .confirm(...) for potentially risky actions.

module.actions()
.add("factoryReset")
.label("Factory Reset")
.section("System")
.command("system", "factory_reset")
.styleDanger()
.confirm("Reset this node to factory defaults?")
.onExecute([] {
factoryReset();
});

Tools can use confirmText from the descriptor before sending the command.

Styling

Action style is UI metadata. It does not change firmware behavior.

StyleDescriptor valueIntended use
Secondaryomitted or secondaryNormal actions.
PrimaryprimaryMain/common actions.
DangerdangerDestructive or risky actions.

Descriptor Output

{
"id": "toggleFaceplate",
"label": "Toggle Faceplate",
"entity": "Facemask",
"command": "toggle",
"style": "primary"
}

Actions are emitted inside descriptor sections next to configuration fields.

Local Events vs Actions

A local button handler is normal application logic:

void btn1_handleClick()
{
ArmorLink.sendCommand("Helmet", "Facemask", "toggle");
}

The receiving module may then execute an Action with .command("Facemask", "toggle").

Summary

Actions define remote-controllable behavior. ArmorLink 0.4.0 descriptors include enough metadata for the App and Web Configurator to render grouped, styled and optionally confirmed action controls.