@signalk/streams 3.0.0 → 3.1.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/gpsd.js +14 -9
- package/package.json +2 -2
package/gpsd.js
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
const Transform = require('stream').Transform
|
|
34
|
-
const
|
|
34
|
+
const GpsdClient = require('node-gpsd-client')
|
|
35
35
|
|
|
36
36
|
function Gpsd(options) {
|
|
37
37
|
Transform.call(this, {
|
|
@@ -40,6 +40,7 @@ function Gpsd(options) {
|
|
|
40
40
|
|
|
41
41
|
const port = options.port || 2947
|
|
42
42
|
const hostname = options.hostname || options.host || 'localhost'
|
|
43
|
+
const noDataReceivedTimeout = options.noDataReceivedTimeout || 0
|
|
43
44
|
|
|
44
45
|
function setProviderStatus(msg) {
|
|
45
46
|
options.app.setProviderStatus(options.providerId, msg)
|
|
@@ -47,9 +48,9 @@ function Gpsd(options) {
|
|
|
47
48
|
|
|
48
49
|
const createDebug = options.createDebug || require('debug')
|
|
49
50
|
|
|
50
|
-
this.listener = new
|
|
51
|
-
port,
|
|
52
|
-
hostname,
|
|
51
|
+
this.listener = new GpsdClient({
|
|
52
|
+
port: port,
|
|
53
|
+
hostname: hostname,
|
|
53
54
|
logger: {
|
|
54
55
|
info: createDebug('signalk:streams:gpsd'),
|
|
55
56
|
warn: console.warn,
|
|
@@ -61,12 +62,19 @@ function Gpsd(options) {
|
|
|
61
62
|
},
|
|
62
63
|
},
|
|
63
64
|
parse: false,
|
|
65
|
+
reconnectThreshold: noDataReceivedTimeout,
|
|
66
|
+
reconnectInterval: noDataReceivedTimeout / 2,
|
|
64
67
|
})
|
|
65
68
|
|
|
66
69
|
setProviderStatus(`Connecting to ${hostname}:${port}`)
|
|
67
70
|
|
|
68
|
-
this.listener.
|
|
71
|
+
this.listener.on('connected', () => {
|
|
69
72
|
setProviderStatus(`Connected to ${hostname}:${port}`)
|
|
73
|
+
this.listener.watch({
|
|
74
|
+
class: 'WATCH',
|
|
75
|
+
nmea: true,
|
|
76
|
+
json: false,
|
|
77
|
+
})
|
|
70
78
|
})
|
|
71
79
|
|
|
72
80
|
const self = this
|
|
@@ -74,10 +82,7 @@ function Gpsd(options) {
|
|
|
74
82
|
self.push(data)
|
|
75
83
|
})
|
|
76
84
|
|
|
77
|
-
this.listener.
|
|
78
|
-
class: 'WATCH',
|
|
79
|
-
nmea: true,
|
|
80
|
-
})
|
|
85
|
+
this.listener.connect()
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
require('util').inherits(Gpsd, Transform)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signalk/streams",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Utilities for handling streams of Signal K data",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"file-timestamp-stream": "^2.1.2",
|
|
33
33
|
"lodash": "^4.17.4",
|
|
34
34
|
"moment": "^2.24.0",
|
|
35
|
-
"node-gpsd": "^
|
|
35
|
+
"node-gpsd-client": "^1.4.1",
|
|
36
36
|
"reconnect-core": "^1.3.0",
|
|
37
37
|
"stream-throttle": "^0.1.3"
|
|
38
38
|
},
|