Skip to main content
Version: 6.3.0

Command

In some cases, you might be interested in a complete log of what the device was doing during its operation. All of your business or technical logs can be stored in our storage for later usage. You can identify which events happened or even trigger self-repairing logic.

All commands will be available in Applet Command REST API and can be downloaded historically as CSV export.

All methods

MethodsDescriptionSupported since
dispatch()Dispatch method for sending logs and data from device1.0.3
onCommand()Event listener for incoming commands from server1.0.3

dispatch()

Dispatch() is used for sending your custom logs or data from device to signageOS.

Parameters

ParameterTypeRequiredDescription
typeString
Yes
Event type; can be any string up to 100 characters
custom parameterStringNoCustom parameters and values that you need to be dispatched

Javascript example


/*
Example of dispatching information about file download
*/
await sos.command.dispatch({
type: 'Files.StartLoading', // mandatory *type* with custom value
fileName: 'my-file', // custom parameter and value
fileType: 'txt' // custom parameter and value
});

/*
Example of dispatching applet heartbeat
*/
await sos.command.dispatch({
type: 'Heartbeat' // mandatory *type* with custom value
});

/*
Example of dispatching applet new data
*/
const myCMSJSON = {playlist: "myPlaylist", items: [...]};

await sos.command.dispatch({
type: 'Content.update', // mandatory *type* with custom value
content: JSON.stringify(myCMSJSON) // custom parameter and value
});


GitHub Example

Errors

CodeTypeMessage
40401AppletCommandTypeErrorType contains invalid characters.
40402AppletCommandTypeErrorType is longer then 100 characters.
40403AppletCommandTypeErrorCommand type must be a string.

Usage with Typescript

interface ICommand {
type: string;
}
dispatch(command: ICommand): void;
GitHub Example

Rest API: Get Commands

Receiving your data dispatched from devices

GitHub Example

Rest API: Monitoring/Device Reports

Receiving historical data

onCommand()

Used for sending custom messages to online connected devices. This can be done through the REST API by POST new applet command. The command will be dispatched to the device & the applet can set up the logic by subscribing onCommand method.

Parameters:

ParamTypeRequiredDescription
commandobject
Yes
Any JS object with required property type.
appendHTMLElement
Yes
Type property must be string not longer then 50 characters and must contain only characters a-zA-Z0-9_- and .

Javascript

sos.command.onCommand((command) => {
// ... logic
});
GitHub Example

Usage with Typescript

interface ICommand {
type: string;
}
onCommand(listener: (command: ICommand) => void): void;
GitHub Example

Rest API: Monitoring

Creating monitoring data

Errors

Although we are doing our best, following errors may occur when working with the commands.

CodeTypeMessage
40401AppletCommandTypeErrorType contains invalid characters, allowed are /^[a-zA-Z0-9\.\-_]+$/g
40402AppletCommandTypeErrorType is longer then 100 characters.
40403AppletCommandTypeErrorCommand type must be a string.