-
Notifications
You must be signed in to change notification settings - Fork 2
/
signalk-input-handler-next.js
46 lines (42 loc) · 1.08 KB
/
signalk-input-handler-next.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module.exports = function(RED) {
function SignalK(config) {
RED.nodes.createNode(this,config);
var node = this;
var app = node.context().global.get('app')
node.on('input', msg => {
let next = node.context().flow.get('signalk-input-handler.next')
if ( msg.next ) {
next = msg.next
}
if ( msg.topic ) {
let delta = {
context: msg.context,
updates: [
{
source: msg.source,
$source: msg.$source,
timestamp: msg.timestamp,
values: [
{
value: msg.payload,
path: msg.topic
}
]
}
]
}
/*
if ( msg.source && msg.source.length > 0 ) {
delta.updates[0].$source = msg.source
}
*/
//node.error(JSON.stringify(delta))
//console.log(JSON.stringify(delta))
next(delta)
} else {
//next(msg.payload)
}
})
}
RED.nodes.registerType("signalk-input-handler-next", SignalK);
}