node-lirc_client provides a lirc_client object so your nodejs application can receive lirc command.
It is based on the lirc_client example
npm install lirc_client
var lirc_client = require('lirc_client');
try {
lirc_client.connect("testone", true, "test1.lircrc",function(type, data, configFile){
console.log("Type:", type);
console.log("Data:", data);
switch (type) {
case "rawdata":
console.log("Rawdata received:",data);
break;
case "data":
console.log("Data received '%s' from configFile '%s'",data, configFile);
break;
case "closed":
console.log("Lircd closed connection to us.");
break;
}
});
console.log("lirc_client.isConnected:", lirc_client.isConnected);
console.log("lirc_client.mode:", lirc_client.mode);
console.log("lirc_client.configFiles:", lirc_client.configFiles);
console.close();
console.log("lirc_client.isConnected:", lirc_client.isConnected);
}
catch (err) {
console.log("Error on connect:",err);
}
See examples folder for more detailed example.
Module Functions
connect(< String >programName, [< Boolean >verbose], [< String >configFiles], < Function >callback(< String >type[, < String >data[, < String >configFile]])) - Should be called to connect to lircd.
connect(< String >programName, [< Boolean >verbose], [< Array >configFiles], < Function >callback(< String >type[, < String >data[, < String >configFile]])) - Should be called to connect to lircd.
close() - Closes the connection to lircd for this object.
reConnect() - Reconnects a closed connection to the lircd for this object. It will reuse arguments from connect call.
addConfig(< String >configFile | < Array >configFiles) - Add one or more lircrc config files.
clearConfig() - Will remove all lircrc config files from object. No more "data" events will be emited until at least one config has been added again.
Module properties
< Boolean >isConnected (read only) - When true is returned there is a connection to the lircd and the object will receive events. When false is returned the object is not connected to lircd and it will not receive events.
< String >mode (read/write) - Will perform lirc_getmode and lirc_setmode. Are not described on lirc website but were found in lirc_client.h file and on following page
< Array >configFiles (read only) - Will contain a list with config filenames currently active. When array is empty the lirc default lircrc config files are used.