cambridge-sound-qtpro

0.2.1 • Public • Published

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

QTPro

Typedefs

getOneCallback : function

Callback for requesting one system or zone parameter

getAllCallback : function

Callback for requesting all system or zone parameters

setCallback : function

Callback for setting one system or zone parameter

QTPro

Kind: global class

new QTPro(params)

Create a QTPro unit.

Param Type Default Description
params Object
params.ip string The IP address of the unit
params.model string The model of QTPro connecting to, options are 'QT300' or 'QT600'
[params.port] number 23 The port number the unit is listening on
[params.reconnect] boolean true If 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

Param Type Description
[cb] setCallback The 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

Param Type Description
[cb] getAllCallback The 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

Param Type Description
parameter string The parameter to get. Valid values are in api.system.get
[cb] getOneCallback The callback to run against the response

qtPro.setSystemParam(parameter, value, [cb])

Sends a set command to the QtPro unit

Kind: instance method of QTPro

Param Type Description
parameter string The parameter to set. Valid values are in api.system.set
value string The value the parameter will be set to
[cb] setCallback The 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

Param Type Description
zone Number The zone to get all parameters for
[cb] getAllCallback The 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

Param Type Description
zone Number The 0-indexed zone number the parameter will be set for
parameter string The parameter to get. Valid values are in api.zone.get
[cb] getOneCallback The 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

Param Type Description
zone Number The 0-indexed zone number the parameter will be set for
parameter string The parameter to set. Valid values are in api.zone.set
value string The value the parameter will be set to
[cb] setCallback The callback to run against the response

getOneCallback : function

Callback for requesting one system or zone parameter

Kind: global typedef

Param Type Description
res object an 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

Param Type Description
res object an 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

Param Type Description
res boolean true if the set was successful, false otherwise

Authors

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

License

MIT License

Package Sidebar

Install

npm i cambridge-sound-qtpro

Weekly Downloads

0

Version

0.2.1

License

MIT

Unpacked Size

34.7 kB

Total Files

7

Last publish

Collaborators

  • commlink-integration