@dderevjanik/termux-api
Version:
This library allows you to interact with your Android device from Node.js using termux-api
27 lines (26 loc) • 925 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.infraredTransmit = infraredTransmit;
const child_process_1 = require("child_process");
/**
* Transmit an infrared pattern.
*
* **Note:** This API can be used only on devices that have infrared transmitter
*/
async function infraredTransmit(options) {
return new Promise((resolve, reject) => {
if (options.pattern.length === 0) {
return reject(`Error: Pattern to transmit is empty`);
}
const command = `termux-infrared-transmit -f ${options.frequency} "${options.pattern.join(",")}"`;
(0, child_process_1.exec)(command, (error, stdout, stderr) => {
if (error) {
return reject(`Error: ${error.message}`);
}
if (stderr) {
return reject(`Error: ${stderr}`);
}
return resolve();
});
});
}