@canboat/canboatjs 2.8.2 → 2.9.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/candevice.js +21 -0
- package/package.json +1 -1
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)
|