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
toggleFaceplateas internal identifier. - Is shown as
Toggle Faceplate. - Appears in the
Faceplatesection. - Reacts to the
Facemask/toggleCommand. - 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
| Method | Description |
|---|---|
.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.
| Style | Descriptor value | Intended use |
|---|---|---|
| Secondary | omitted or secondary | Normal actions. |
| Primary | primary | Main/common actions. |
| Danger | danger | Destructive 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.