0.2.1 • Published 3 years ago

cambridge-sound-qtpro v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

cambridge-sound-qtpro

Node package for communicating with Cambridge Sound Qt series sound masking systems through their telnet-based command line interface.

Tested with QtPro 300 but should work with any Qt series sound masking system that implements the telnet command line interface.

Basic testing has been done but there are likely to be uncaught edge cases. Issues and pull requests are welcome.

Install

npm install cambridge-sound-qtpro

Quick start

const QTPro = require('cambridge-sound-qtpro');

const params = {
    ip: '172.16.10.141', 
    model: 'QT300',
    port: 23, // default
    reconnect: true // default
};

const qtpro = new QTPro(params);

qtpro.on('ready', () => {
    const getSystemArgs = {
        parameter: 'ip_address'
    };
    qtpro.getSystemParam(getSystemArgs, (res) => {
        console.log(`The IP address of this Qt Pro unit is ${res[getSystemArgs.parameter]}`);
    });

    const getZoneArgs = {
        zone: 1, // 0-indexed zone number, so this is asking for Zone 2
        parameter: 'masking_max'
    };
    qtpro.getZoneParam(getZoneArgs, (res) => {
        console.log(`The maximum masking level for Zone 2 of this Qt Pro unit is ${res[getZoneArgs.parameter]}`);
    });

    const setSystemArgs = {
        parameter: 'unit_name',
        value: 'CommLink Integration Corp HQ'
    };
    qtpro.setSystemParam(setSystemArgs, (res) => {
        console.log(`The unit name was ${res ? '' : 'not'} set to ${setSystemArgs.value}`);
    });

    const setZoneArgs = {
        zone: 1,
        parameter: 'masking_min',
        value: 12
    };
    qtpro.setZoneParam(setZoneArgs, (res) => {
        console.log(`The minimum masking level for Zone 2 was ${res ? '' : 'not'} set to ${setZoneArgs.value}`);
    });

    qtpro.getAllSystemParams((res) => {
        console.log(`The system parameters are ${res}`);
    });

    qtpro.getAllZoneParams({zone: 0}, (res) => {
        console.log(`Zone 1 parameters are ${res}`);
    });
});

Classes

Typedefs

QTPro

Kind: global class

new QTPro(params)

Create a QTPro unit.

ParamTypeDefaultDescription
paramsObject
params.ipstringThe IP address of the unit
params.modelstringThe model of QTPro connecting to, options are 'QT300' or 'QT600'
params.portnumber23The port number the unit is listening on
params.reconnectbooleantrueIf the connection should attempt to re-establish after closing

qtPro.connect()

Attempts to connect to the Qt Pro unit. This is run automatically on class instantiation but can be used manually to reconnect if reconnect is set to false in the constructor params

Kind: instance method of QTPro

qtPro.reset(cb)

Sends a software reset command to the QtPro unit. If reconnect is set to false in the constructor params, the Qt Pro connection will be lost and not recovered

Kind: instance method of QTPro

ParamTypeDescription
cbsetCallbackThe callback to run against the response

qtPro.getAllSystemParams(cb)

A special request to get all of the system parameters for a Qt Pro unit

Kind: instance method of QTPro

ParamTypeDescription
cbgetAllCallbackThe callback to run against the response

qtPro.getSystemParam(parameter, cb)

Sends a get command to the QtPro unit and returns a parsed response object

Kind: instance method of QTPro

ParamTypeDescription
parameterstringThe parameter to get. Valid values are in api.system.get
cbgetOneCallbackThe callback to run against the response

qtPro.setSystemParam(parameter, value, cb)

Sends a set command to the QtPro unit

Kind: instance method of QTPro

ParamTypeDescription
parameterstringThe parameter to set. Valid values are in api.system.set
valuestringThe value the parameter will be set to
cbsetCallbackThe callback to run against the response

qtPro.getAllZoneParams(zone, cb)

A special request to get all of the parameters for a specific zone

Kind: instance method of QTPro

ParamTypeDescription
zoneNumberThe zone to get all parameters for
cbgetAllCallbackThe callback to run against the response

qtPro.getZoneParam(zone, parameter, cb)

Sends a get command to the QtPro unit and returns a parsed response object

Kind: instance method of QTPro

ParamTypeDescription
zoneNumberThe 0-indexed zone number the parameter will be set for
parameterstringThe parameter to get. Valid values are in api.zone.get
cbgetOneCallbackThe callback to run against the response

qtPro.setZoneParam(zone, parameter, value, cb)

Sends a set command to the QtPro unit

Kind: instance method of QTPro

ParamTypeDescription
zoneNumberThe 0-indexed zone number the parameter will be set for
parameterstringThe parameter to set. Valid values are in api.zone.set
valuestringThe value the parameter will be set to
cbsetCallbackThe callback to run against the response

getOneCallback : function

Callback for requesting one system or zone parameter

Kind: global typedef

ParamTypeDescription
resobjectan object with a single property, the value of the parameter property passed to the get* method, and it's current value according the QTPro unit

getAllCallback : function

Callback for requesting all system or zone parameters

Kind: global typedef

ParamTypeDescription
resobjectan object with a property for every system or zone entry in ./api.js and it's current value

setCallback : function

Callback for setting one system or zone parameter

Kind: global typedef

ParamTypeDescription
resbooleantrue if the set was successful, false otherwise

Authors

See also the list of contributors who participated in this project.

License

MIT License

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago