@canboat/canboatjs 2.8.2 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/canbus.js CHANGED
@@ -220,6 +220,10 @@ CanbusStream.prototype.sendPGN = function (msg) {
220
220
 
221
221
  debug('sending %j', msg)
222
222
 
223
+ if ( this.options.app ) {
224
+ this.options.app.emit('connectionwrite', { providerId: this.options.providerId })
225
+ }
226
+
223
227
  let src = msg.pgn === 59904 || msg.forceSrc ? msg.src : this.candevice.address
224
228
  if ( _.isString(msg) ) {
225
229
  var split = msg.split(',')
package/lib/candevice.js CHANGED
@@ -96,6 +96,7 @@ class CanDevice extends EventEmitter {
96
96
  this.address = _.isUndefined(options.preferredAddress) ? 100 : options.preferredAddress
97
97
  this.cansend = false
98
98
  this.foundConflict = false
99
+ this.heartbeatCounter = 0
99
100
  this.devices = {}
100
101
 
101
102
  if ( !options.disableDefaultTransmitPGNs ) {
@@ -271,6 +272,23 @@ function handleProductInformation(device, n2kMsg) {
271
272
  device.devices[n2kMsg.src].productInformation = n2kMsg
272
273
  }
273
274
 
275
+ function sendHeartbeat(device)
276
+ {
277
+ device.heartbeatCounter = device.heartbeatCounter + 1
278
+ if ( device.heartbeatCounter > 252 )
279
+ {
280
+ device.heartbeatCounter = 0
281
+ }
282
+ sendPGN(device,{
283
+ pgn: 126993,
284
+ dst: 255,
285
+ prio:7,
286
+ "Data transmit offset": "00:01:00",
287
+ "Sequence Counter": device.heartbeatCounter,
288
+ "Controller 1 State":"Error Active"
289
+ })
290
+ }
291
+
274
292
 
275
293
  function sendAddressClaim(device) {
276
294
  if ( device.devices[device.address] ) {
@@ -287,6 +305,9 @@ function sendAddressClaim(device) {
287
305
  device.options.app.emit('nmea2000OutAvailable')
288
306
  }
289
307
  sendISORequest(device, 126996)
308
+ device.heartbeatInterval = setInterval(() => {
309
+ sendHeartbeat(device)
310
+ }, 60*1000)
290
311
  /*
291
312
  _.keys(device.devices).forEach((address) => {
292
313
  sendISORequest(device, 126996, undefined, address)
package/lib/ikonvert.js CHANGED
@@ -75,9 +75,11 @@ function iKonvertStream (options) {
75
75
  } else {
76
76
  that.sendPGN(msg)
77
77
  }
78
+ options.app.emit('connectionwrite', { providerId: options.providerId })
78
79
  })
79
80
  options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => {
80
81
  that.sendPGN(msg)
82
+ options.app.emit('connectionwrite', { providerId: options.providerId })
81
83
  })
82
84
 
83
85
  this.isSetup = false
package/lib/serial.js CHANGED
@@ -148,6 +148,7 @@ SerialStream.prototype.start = function () {
148
148
  buf = composeMessage(N2K_MSG_SEND, buf, buf.length)
149
149
  debugOut(buf)
150
150
  that.serial.write(buf)
151
+ that.options.app.emit('connectionwrite', { providerId: that.options.providerId })
151
152
  }
152
153
 
153
154
  function writeObject(msg) {
@@ -158,6 +159,7 @@ SerialStream.prototype.start = function () {
158
159
  buf = composeMessage(N2K_MSG_SEND, buf, buf.length)
159
160
  debugOut(buf)
160
161
  that.serial.write(buf)
162
+ that.options.app.emit('connectionwrite', { providerId: that.options.providerId })
161
163
  }
162
164
 
163
165
  this.options.app.on(this.options.outEevent || 'nmea2000out', msg => {
package/lib/w2k01.js CHANGED
@@ -49,10 +49,12 @@ function W2K01Stream (options, type, outEvent) {
49
49
  } else {
50
50
  this.sendPGN(msg)
51
51
  }
52
+ options.app.emit('connectionwrite', { providerId: options.providerId })
52
53
  })
53
54
 
54
55
  options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => {
55
56
  this.sendPGN(msg)
57
+ options.app.emit('connectionwrite', { providerId: options.providerId })
56
58
  })
57
59
  }
58
60
  }
package/lib/ydgw02.js CHANGED
@@ -55,10 +55,12 @@ function Ydgw02Stream (options, type) {
55
55
  } else {
56
56
  this.sendPGN(msg)
57
57
  }
58
+ options.app.emit('connectionwrite', { providerId: options.providerId })
58
59
  })
59
60
 
60
61
  options.app.on(options.jsonOutEvent || 'nmea2000JsonOut', (msg) => {
61
62
  this.sendPGN(msg)
63
+ options.app.emit('connectionwrite', { providerId: options.providerId })
62
64
  })
63
65
 
64
66
  //this.sendString('$PDGY,N2NET_OFFLINE')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canboat/canboatjs",
3
- "version": "2.8.2",
3
+ "version": "2.10.0",
4
4
  "description": "Native javascript version of canboat",
5
5
  "main": "index.js",
6
6
  "scripts": {