@brightsign/bsc
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -1287,2 +1287,34 @@ const fs = require('fs'); | ||
async function sendCec(argv) { | ||
// get player data from argv | ||
let playerData; | ||
try { | ||
playerData = await pullData(argv); | ||
// playerData[0] = playerUser, [1] = playerIP, [2] = playerPW | ||
} catch (err) { | ||
errorHandler(err); | ||
return; | ||
} | ||
logIfOption('Sending CEC command to ' + argv.playerName, argv.verbose); | ||
logIfOption(' IP address: ' + playerData[1] + ', username: ' + playerData[0] + ', password: ' + playerData[2], argv.verbose); | ||
let requestOptions = { | ||
method: 'POST', | ||
url: 'http://' + playerData[1] + '/api/v1/sendCecX', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({hexCommand: argv.command}) | ||
}; | ||
logIfOption('Sending ' + requestOptions.method + ' request to ' + requestOptions.url, argv.verbose); | ||
try { | ||
let response = await requestFetch(requestOptions, playerData[0], playerData[2]); | ||
logIfOption('Response received! => ', argv.verbose); | ||
if (!argv.rawdata) { | ||
console.log('CEC command sent: ' + response.data.result.success); | ||
} else if (argv.rawdata) { | ||
console.log(response.data.result); | ||
} | ||
} catch (err) { | ||
errorHandler(err); | ||
} | ||
} | ||
// General functions | ||
@@ -1687,3 +1719,4 @@ // confirm dangerous command | ||
checkConfigExists, | ||
helpChecker | ||
helpChecker, | ||
sendCec | ||
}; |
@@ -87,2 +87,5 @@ #!/usr/bin/env node | ||
// Send CEC command | ||
yargs.command('sendcec <playerName> <command>', 'Send CEC command. Note that this command will only work on players running the newest version of supervisor', (yargs) => {positionals.sendCecPositional(yargs)}, (argv) => {handlers.sendCec(argv)}); | ||
// define yargs options | ||
@@ -89,0 +92,0 @@ yargs.option('verbose', { |
@@ -299,2 +299,15 @@ function getDiPositional(yargs) { | ||
function sendCecPositional(yargs) { | ||
yargs.positional('playerName', { | ||
type: 'string', | ||
default: 'player1', | ||
describe: 'player name' | ||
}); | ||
yargs.positional('command', { | ||
type: 'string', | ||
default: '', | ||
describe: 'CEC command, direct passthrough' | ||
}); | ||
} | ||
module.exports = { | ||
@@ -322,3 +335,4 @@ getDiPositional, | ||
getPowerSavePositional, | ||
facResetPositional | ||
facResetPositional, | ||
sendCecPositional | ||
} |
{ | ||
"name": "@brightsign/bsc", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Simple Node CLI App to communicate with a BrightSign player over the LAN using the Local DWS REST HTTP APIs.", | ||
@@ -5,0 +5,0 @@ "main": "./bin/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123212
1898