diff --git a/modules/amt-lme.js b/modules/amt-lme.js index b7bea1d..bea0098 100644 --- a/modules/amt-lme.js +++ b/modules/amt-lme.js @@ -117,6 +117,7 @@ function lme_heci(options) { emitterUtils.createEvent('notify'); emitterUtils.createEvent('bind'); + this.on('newListener', function (name, func) { if (name == 'connect' && this._LME._connected == true) { func.call(this);} }); if ((options != null) && (options.debug == true)) { lme_port_offset = -100; } // LMS debug mode var heci = require('heci'); @@ -124,11 +125,14 @@ function lme_heci(options) { this._ObjectID = "lme"; this._LME = heci.create(); + this._LME._connected = false; this._LME.descriptorMetadata = "amt-lme"; this._LME._binded = {}; this._LME.LMS = this; this._LME.on('error', function (e) { this.LMS.emit('error', e); }); - this._LME.on('connect', function () { + this._LME.on('connect', function () + { + this._connected = true; this.on('data', function (chunk) { // this = HECI var cmd = chunk.readUInt8(0);