function LightwaveRF(callback) {
    var config = {};

    if (!(this instanceof LightwaveRF))  {
        return new LightwaveRF(config);
    }
    this.timeout = config.timeout || 1000;
    config.maxattempts = config.maxattempts || 200;
    this.queue = [];
    this.ready = true;

    this.devices = [];

    events.EventEmitter.call(this);

    //Counter
    this.messageCounter = 0;

    //Config
    this.config = config;

    //Response listeners
    this.responseListeners = {};

    //Send Socket
    this.sendSocket = dgram.createSocket("udp4");

    //Receive socket
    this.receiveSocket = dgram.createSocket("udp4");

    //Receive message
    this.receiveSocket.on("message", function (message, rinfo) {

        //Check this came from the lightwave unit
        if (rinfo.address !== this.config.ip) {
            //Came from wrong ip
            return false;
        }

        //Message
        message = message.toString("utf8");

        //Split off the code for the message
        var parts = message.split(",");
        var code = parts.splice(0,1);
        var content = parts.join(",").replace(/(\r\n|\n|\r)/gm,"");

        //Check to see if we have a relevant listener
        var responseListenerData = this.responseListeners[code.toString()];
        if (responseListenerData) {
            //Call the response listener
            responseListenerData.listener(code,content);
            delete this.responseListeners[code.toString()];
        }

    }.bind(this));
    this.receiveSocket.on("listening", function () {
        var address = this.receiveSocket.address();
        console.log("Receiver socket listening " + address.address + ":" + address.port);
    }.bind(this));

    //Bind to the receive port
    this.receiveSocket.bind(9761);
}
/**
 * LightwaveRF API
 *
 * @param object config The config
 *
 * An instance of the LightwaveRF API
 */
LightwaveRF API
@param object config The config

An instance of the LightwaveRF API
LightwaveRF API @param object config The config An instance of the LightwaveRF API
function LightwaveRF(callback) {
    var config = {};
    if (!(this instanceof LightwaveRF))  {
        return new LightwaveRF(config);
    }
    this.timeout = config.timeout || 1000;
    config.maxattempts = config.maxattempts || 200;
    this.queue = [];
    this.ready = true;
    this.devices = [];
    events.EventEmitter.call(this);
    this.messageCounter = 0;
    this.config = config;
    this.responseListeners = {};
    this.sendSocket = dgram.createSocket("udp4");
    this.receiveSocket = dgram.createSocket("udp4");
    this.receiveSocket.on("message", function (message, rinfo) {
        if (rinfo.address !== this.config.ip) {
            return false;
        }
        message = message.toString("utf8");
        var parts = message.split(",");
        var code = parts.splice(0,1);
        var content = parts.join(",").replace(/(\r\n|\n|\r)/gm,"");
        var responseListenerData = this.responseListeners[code.toString()];
        if (responseListenerData) {
            responseListenerData.listener(code,content);
            delete this.responseListeners[code.toString()];
        }
    }.bind(this));
    this.receiveSocket.on("listening", function () {
        var address = this.receiveSocket.address();
        console.log("Receiver socket listening " + address.address + ":" + address.port);
    }.bind(this));
    this.receiveSocket.bind(9761);
}
function LightwaveRF ( callback ) { var config = { } ; if ( ! ( this instanceof LightwaveRF ) ) { return new LightwaveRF ( config ) ; } this . timeout = config . timeout || 1000 ; config . maxattempts = config . maxattempts || 200 ; this . queue = [ ] ; this . ready = true ; this . devices = [ ] ; events . EventEmitter . call ( this ) ; this . messageCounter = 0 ; this . config = config ; this . responseListeners = { } ; this . sendSocket = dgram . createSocket ( "udp4" ) ; this . receiveSocket = dgram . createSocket ( "udp4" ) ; this . receiveSocket . on ( "message" , function ( message , rinfo ) { if ( rinfo . address !== this . config . ip ) { return false ; } message = message . toString ( "utf8" ) ; var parts = message . split ( "," ) ; var code = parts . splice ( 0 , 1 ) ; var content = parts . join ( "," ) . replace ( / (\r\n|\n|\r) / gm , "" ) ; var responseListenerData = this . responseListeners [ code . toString ( ) ] ; if ( responseListenerData ) { responseListenerData . listener ( code , content ) ; delete this . responseListeners [ code . toString ( ) ] ; } } . bind ( this ) ) ; this . receiveSocket . on ( "listening" , function ( ) { var address = this . receiveSocket . address ( ) ; console . log ( "Receiver socket listening " + address . address + ":" + address . port ) ; } . bind ( this ) ) ; this . receiveSocket . bind ( 9761 ) ; }
LightwaveRF API
 @param object config The config
LightwaveRF API @param object config The config
//Counter //Config //Response listeners //Send Socket //Receive socket //Receive message //Check this came from the lightwave unit //Came from wrong ip //Message //Split off the code for the message //Check to see if we have a relevant listener //Call the response listener //Bind to the receive port