diff --git a/lib/canbus.js b/lib/canbus.js index edaf31b..47d6b1d 100644 --- a/lib/canbus.js +++ b/lib/canbus.js @@ -220,6 +220,10 @@ CanbusStream.prototype.sendPGN = function (msg) { debug('sending %j', msg) + if ( this.options.app ) { + this.options.app.emit('connectionwrite', { providerId: this.options.providerId }) + } + let src = msg.pgn === 59904 || msg.forceSrc ? msg.src : this.candevice.address if ( _.isString(msg) ) { var split = msg.split(',') diff --git a/lib/ikonvert.js b/lib/ikonvert.js index a5d1381..8a3bb29 100644 --- a/lib/ikonvert.js +++ b/lib/ikonvert.js @@ -75,9 +75,11 @@ function iKonvertStream (options) { } else { that.sendPGN(msg) } + options.app.emit('connectionwrite', { providerId: options.providerId }) }) options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => { that.sendPGN(msg) + options.app.emit('connectionwrite', { providerId: options.providerId }) }) this.isSetup = false diff --git a/lib/serial.js b/lib/serial.js index 9855df2..d27cd77 100644 --- a/lib/serial.js +++ b/lib/serial.js @@ -148,6 +148,7 @@ SerialStream.prototype.start = function () { buf = composeMessage(N2K_MSG_SEND, buf, buf.length) debugOut(buf) that.serial.write(buf) + that.options.app.emit('connectionwrite', { providerId: that.options.providerId }) } function writeObject(msg) { @@ -158,6 +159,7 @@ SerialStream.prototype.start = function () { buf = composeMessage(N2K_MSG_SEND, buf, buf.length) debugOut(buf) that.serial.write(buf) + that.options.app.emit('connectionwrite', { providerId: that.options.providerId }) } this.options.app.on(this.options.outEevent || 'nmea2000out', msg => { diff --git a/lib/w2k01.js b/lib/w2k01.js index 45acf99..4a11575 100644 --- a/lib/w2k01.js +++ b/lib/w2k01.js @@ -49,10 +49,12 @@ function W2K01Stream (options, type, outEvent) { } else { this.sendPGN(msg) } + options.app.emit('connectionwrite', { providerId: options.providerId }) }) options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => { this.sendPGN(msg) + options.app.emit('connectionwrite', { providerId: options.providerId }) }) } } diff --git a/lib/ydgw02.js b/lib/ydgw02.js index e7a9b6a..490f06d 100644 --- a/lib/ydgw02.js +++ b/lib/ydgw02.js @@ -55,10 +55,12 @@ function Ydgw02Stream (options, type) { } else { this.sendPGN(msg) } + options.app.emit('connectionwrite', { providerId: options.providerId }) }) options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => { this.sendPGN(msg) + options.app.emit('connectionwrite', { providerId: options.providerId }) }) //this.sendString('$PDGY,N2NET_OFFLINE')