Introduction
wallcontrol10
is module for working with WallControll 10 command line interface over LAN-TCP. Decode responses from Wall Control 10 into JS values.
Main features
- connect over LAN-TCP
- execute native WallControl 10 commands
- decode responses into JS values
- command queue and time management
- events driven
- different schemas for connect-disconnect cycle
Usage
const WC10 = require('wallcontrol10');
//send-receive data using TCP socket
const dev = new WC10({host: '192.168.4.111'});
dev.emitter.on('responseFromDevice', data => console.log(data));
dev.process('wcmd -layouts'); //ask for layouts for default wall
dev.process('wcmd -layout="layout 1"'); //apply 'layout 1' for default wall
WC10cli Object
The primary exported object is WC10cli
. It uses RAW
object from raw-device
as its prototype.
new WC10cli(AddressObject, OptionsObject)
Constructor -
AddressObject <Object>
- required.-
name <string>
- default 'WC10' -
id <string>
- default 'blueprint' -
host <string>
- required. Use valid IP address -
port <number>
- default 23
-
-
OptionsObject <Object>
- optional, default is{encoding: 'ASCII', duration: 1400, disconnect: true, splitter: {timeout: 1200}}
-
encoding <string>
- default 'ASCII' -
duration <number>
- default 1400 ms. Inter-command period [ms]. A time for device to process command and to prepare and send a response. -
disconnect <boolean|number>
- default true. Connecion cycle scheme. Use true, false or timeout[ms]. True means close connection when command queue is empty, false means do not close connection, number means close connection after some ms. of connection inactivity. -
splitter <Object>
Used to select one among three supported transform streams which merge incoming data chunks and split it into valid messages. Only single property from delimiter, regex, timeout can be used. Default is{timeout: 1200}
-
delimiter <string>
- use@serialport/parser-delimiter
with string delimiter -
regex <Regex>
- use@serialport/parser-regex
with regex -
timeout <number>
- use@serialport/parser-inter-byte-timeout
with timeout. Response is completed if inter-byte time is longer then timeout. Please consider that timeout must be shorter than duration (inter-command period) and disconnect time (if disconnect use timeout scheme)
-
-
process(...commands)
Method Encode and send commands to controler. Commands will be queued and executed FIFO. You can use multiple commands in single call. Commands must be native WallControl 10 CLI commands as described in WallControl 10 Help/Tools/Command Line Interface or WallControl 10 User Guide. The most commonly used commands are:
-
wcmd [-wall=wall_name] -layouts
- Get layout names for given wall -
wcmd [-wall=wall_name] -layout=layout_name
- Apply layout for wall -
wcmd [-wall=wall_name] -layout
- Get current layout name for given wall -
wcmd -inputs
- Get list of sources -
wcmd [-wall=wall_name] -openwindows
- Get list of opened windows with their properties -
wcmd -wallstate
- Get list of defined walls with their properties
Internal commands
There are some internal commands which start with #
. They are not sent to controller, but are processed by WC10cli object itself.
-
#pause duration
- Append additional pause between neighboring commands as number of miliseconds.
responseFromDevice
Event: Emited when response from controller is properly decoded.
-
response <Object>
-
dev <string>
- controler name -
id <string>
- wall name -
raw <string>
- not decoded response -
status <string>
- response status. If command is executed OK, returned status is 'Success' -
value <string|[string]|Object>
- decoded response value. Returned type depends on request id (req). -
req <string>
- request id, used to identify response value. Currently following request are implemented:-
req:'layouts'
(available layouts), response forwcmd -layouts
command -
req:'layout'
(current layout), response for wcmd -layout -
req:'inputs'
(available inputs), response forwcmd -inputs
-
req:'providers'
(installed source providers), response forwcmd -providers
-
req:'windows'
(opened windows), response forwcmd -openwindows
-
req:'walls'
(available walls), response forwcmd -wallstate
-
req:'favourities'
(available favourities), response forwcmd -favourities
-
-
commandForDevice
Event: Emited when command is properly encoded and sent to controler. Of course only encoded
property is sent to controler itself.
-
command <Object>
-
name <string>
- device name -
command <string>
- a command itself, not parsed or encoded -
encodedstr <string>
- command encoded as string -
encoded <Buffer>
- command encoded as Buffer -
duration <number>
- time [ms] for device to process the command.
-
connectionData
Event: A data which comes directly from controler port "as is". Not decoded, merged or chopped by splitter
data <Buffer>
connectionStatus
Event: Emited when device connection status changes.
-
statusObj <Object>
-
dev <string>
- device name -
address <string>
- device address as string -
status <string>
- connection status -
more <string|Object>
- additional status information
-