@signalk/streams 2.0.3 → 2.2.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/mdns-ws.js CHANGED
@@ -34,12 +34,12 @@ function MdnsWs(options) {
34
34
  const createDebug = options.createDebug || require('debug')
35
35
  this.debug = createDebug('signalk:streams:mdns-ws')
36
36
  this.dataDebug = createDebug('signalk:streams:mdns-ws-data')
37
- debug(`deltaStreamBehaviour:${deltaStreamBehaviour}`)
37
+ this.debug(`deltaStreamBehaviour:${deltaStreamBehaviour}`)
38
38
 
39
39
  this.handleContext = () => {}
40
40
  if (options.selfHandling === 'manualSelf') {
41
41
  if (options.remoteSelf) {
42
- debug(`Using manual remote self ${options.remoteSelf}`)
42
+ this.debug(`Using manual remote self ${options.remoteSelf}`)
43
43
  this.handleContext = (delta) => {
44
44
  if (delta.context === options.remoteSelf) {
45
45
  delete delta.context
@@ -66,6 +66,7 @@ function MdnsWs(options) {
66
66
  autoConnect: false,
67
67
  deltaStreamBehaviour,
68
68
  rejectUnauthorized: !(options.selfsignedcert === true),
69
+ wsKeepaliveInterval: 10
69
70
  })
70
71
  this.connect(this.signalkClient)
71
72
  } else {
@@ -39,8 +39,9 @@ function Nmea0183ToSignalK(options) {
39
39
  Transform.call(this, {
40
40
  objectMode: true,
41
41
  })
42
- this.debug = (options.createDebug || require('debug'))('signalk:streams:nmea0183-signalk')
43
-
42
+ this.debug = (options.createDebug || require('debug'))(
43
+ 'signalk:streams:nmea0183-signalk'
44
+ )
44
45
 
45
46
  this.parser = new Parser(options)
46
47
  this.n2kParser = new FromPgn(options)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signalk/streams",
3
- "version": "2.0.3",
3
+ "version": "2.2.0",
4
4
  "description": "Utilities for handling streams of Signal K data",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  "homepage": "https://github.com/SignalK/signalk-server-node#readme",
24
24
  "dependencies": {
25
25
  "@canboat/canboatjs": "^1.4.0",
26
- "@signalk/client": "^2.1.0",
26
+ "@signalk/client": "^2.3.0",
27
27
  "@signalk/n2k-signalk": "^2.0.0",
28
28
  "@signalk/nmea0183-signalk": "^3.0.0",
29
29
  "@signalk/nmea0183-utilities": "^0.8.0",
package/simple.js CHANGED
@@ -80,6 +80,20 @@ function Simple(options) {
80
80
  getLogger(options.app, options.logging, discriminatorByDataType[dataType]),
81
81
  dataTypeMapping[mappingType](options)
82
82
  )
83
+ if (options.subOptions.overrideTimestamp) {
84
+ pipeline.push(
85
+ new Transform({
86
+ objectMode: true,
87
+ transform(delta, encoding, callback) {
88
+ if (delta.updates) {
89
+ const now = new Date().toISOString()
90
+ delta.updates.forEach((update) => (update.timestamp = now))
91
+ }
92
+ callback(null, delta)
93
+ },
94
+ })
95
+ )
96
+ }
83
97
 
84
98
  for (let i = pipeline.length - 2; i >= 0; i--) {
85
99
  pipeline[i].pipe(pipeline[i + 1])
@@ -239,7 +253,13 @@ function nmea2000input(subOptions, logging) {
239
253
  new Liner(subOptions),
240
254
  ]
241
255
  } else if (subOptions.type === 'ydwg02-udp-canboatjs') {
242
- return [new Udp(subOptions), new Liner(subOptions)]
256
+ return [
257
+ new Udp({
258
+ ...subOptions,
259
+ outEvent: 'ydwg02-out',
260
+ }),
261
+ new Liner(subOptions),
262
+ ]
243
263
  } else if (subOptions.type === 'navlink2-tcp-canboatjs') {
244
264
  return [
245
265
  new Tcp({
package/tcp.js CHANGED
@@ -38,6 +38,7 @@ function TcpStream(options) {
38
38
  this.noDataReceivedTimeout =
39
39
  Number.parseInt((this.options.noDataReceivedTimeout + '').trim()) * 1000
40
40
  this.debug = (options.createDebug || require('debug'))('signalk:streams:tcp')
41
+ this.debug(`noDataReceivedTimeout:${this.noDataReceivedTimeout}`)
41
42
  this.debugData = (options.createDebug || require('debug'))(
42
43
  'signalk:streams:tcp-data'
43
44
  )
package/udp.js CHANGED
@@ -41,6 +41,9 @@ function Udp(options) {
41
41
  })
42
42
  this.options = options
43
43
  this.debug = (options.createDebug || require('debug'))('signalk:streams:udp')
44
+ this.debugData = (options.createDebug || require('debug'))(
45
+ 'signalk:streams:udp-data'
46
+ )
44
47
  }
45
48
 
46
49
  require('util').inherits(Udp, Transform)
@@ -51,11 +54,21 @@ Udp.prototype.pipe = function (pipeTo) {
51
54
 
52
55
  const socket = require('dgram').createSocket('udp4')
53
56
  const self = this
57
+
58
+ if (this.options.outEvent && this.options.port !== undefined) {
59
+ this.options.app.on(this.options.outEvent, function (d) {
60
+ self.debug('sending over udp: %s', d)
61
+ socket.send(d, 0, d.length, self.options.port, '255.255.255.255')
62
+ })
63
+ }
64
+
54
65
  socket.on('message', function (message, remote) {
55
66
  self.debug(message.toString())
56
67
  self.push(message)
57
68
  })
58
- socket.bind(this.options.port)
69
+ socket.bind(this.options.port, function () {
70
+ socket.setBroadcast(true)
71
+ })
59
72
  }
60
73
 
61
74
  Udp.prototype._transform = function (chunk, encoding, done) {
Binary file