Skip to content

Commit

Permalink
feature: report connection write messages for the sk dashboard (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 authored Aug 16, 2024
1 parent fc208a8 commit 7a2b43d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/canbus.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(',')
Expand Down
2 changes: 2 additions & 0 deletions lib/ikonvert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 => {
Expand Down
2 changes: 2 additions & 0 deletions lib/w2k01.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/ydgw02.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 7a2b43d

Please sign in to comment.