-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetFIELDWebSocket.html
179 lines (156 loc) · 7.42 KB
/
netFIELDWebSocket.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<script type="text/javascript">
RED.nodes.registerType('websocket-in',{
category: 'netFIELD',
color:"rgb(215, 215, 160)",
defaults: {
name: {value:""},
websocket: {type:"websocket-config", required:true},
"deviceid": { value: "", required:true, validate:RED.validators.regex(/^[A-Za-z0-9]{24}$/)},
"topic": { value: "#"},
},
inputs:0,
outputs:1,
icon: "white-globe.svg",
label: function() {
return this.name||"netFIELD websocket in";
}
});
</script>
<script type="text/html" data-template-name="websocket-in">
<div class="form-row">
<label for="node-input-websocket"><i class="fa fa-globe"> </i> Websocket</label>
<input type="text" id="node-input-websocket">
</div>
<div class="form-row">
<label for="node-input-deviceid"><i class="fa fa-id-card-o"></i> Device ID</label>
<input type="text" id="node-input-deviceid" placeholder="e.g. 5f7b1bec199d7835e0928e9b">
<label for="node-input-topic"><i class="fa fa-hashtag"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="#">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/html" data-help-name="websocket-in">
<p>WebSocket listener input node to communicate with Hilscher 'netFIELD Cloud' technology based WebSocket interfaces.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt class="madatory">Device ID <span class="property-type">24 digit code</span></dt>
<dd>Specifies the device the node shall address. Get the Device ID from your cloud account.</dd>
<dt class="madatory">Topic <span class="property-type">string</span></dt>
<dd>Specifies the data object path within the device the node shall listen to. The value follows the format of a path e.g. /.../... . Get the topic from your cloud account. Using a wildcard '#' will inject all data objects matching the path+wildcard pattern. A single '#' as value will listen to all device data objects all at once.</dd>
</dl>
<h3>Output</h3>
<dl class="message-properties">
<dt class="mandatory">payload <span class="property-type">json</span></dt>
<dd>The JSON data object received through the WebSocket. Here is an example
<pre><code>
{
"createdAt":"2021-01-17T13:26:49.246Z",
"topic":"oi4/OTConnector/urn:hilscher.com/IO-Link-Adapter/IOLINKADAPTER/nd/pub/data/urn:ifm.com/TV7105/TV7105/000095619444.P1",
"chunk":null,
"data":{
"MessageId":"1610890009172-OTConnector/urn:hilscher.com/IO-Link-Adapter/IOLINKADAPTER/nd",
"MessageType":"ua-data",
"PublisherId":"OTConnector/urn:hilscher.com/IO-Link-Adapter/IOLINKADAPTER/nd",
"DataSetClassId":"d1390b10-d9af-430f-af77-8da528fa553b",
"Messages":[
{
"DataSetWriterId":"urn:ifm.com/TV7105/TV7105/000095619444.P1",
"Timestamp":"2021-01-17T13:26:49.172Z",
"Status":0,
"SequenceNumber":0,
"Payload":{
"pd_Temperature":346,
"pd_OUT2":false,
"pd_OUT1":false,
"o_Temperature":34.6,
"o_OUT2":false,
"o_OUT1":false
},
"MetaDataVersion":{
"majorVersion":1610890009172,
"minorVersion":1610890009172
}
}
],
"CorrelationId":""
}
}
</code></pre>
</dd>
</dl>
<h3>Config</h3>
<dl class="message-properties">
<dt class="madatory">Name <span class="property-type">string</span></dt>
<dd>Specifies a name of the configuration node.</dd>
<dt class="madatory">URL <span class="property-type">string</span></dt>
<dd>Specifies the WebSocket URL in the format wss://<url>. Default is <b>wss://api.netfield.io</b></dd>
<dt class="madatory">Timeout Period <span class="property-type">string</span></dt>
<dd>Specifies the inactivity time (ping) monitored. If expired the WebSocket connection is assumed as timed out and tried to get restabslished again. Default is <b>30</b> seconds</dd>
<dt class="madatory">Key <span class="property-type">JWT token</span></dt>
<dd>Specifies the authorization key. Copy and paste a key received from your cloud account.</dd>
</dl>
</script>
<script type="text/javascript">
RED.nodes.registerType('websocket-config',{
category: 'config',
defaults: {
name: {value:"",required:true},
"apiendpoint": {value:"wss://api.netfield.io",required:true,validate:RED.validators.regex(/^(wss?:\/\/)[a-zA-Z0-9\-]{1,64}\.[a-zA-Z0-9\.\-]{1,64}$/)},
"authorization": { value: "",required:true, validate:RED.validators.regex(/[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)$/)},
"inactivitytimeout" : { value: "30", required:true, validate:RED.validators.regex(/^[0-9]+$/)}
},
label: function() {
return this.name;
},
oneditprepare: function () {
var tabs = RED.tabs.create({
id: "node-config-netFIELD-websocket-tabs",
onchange: function(tab) {
$("#node-config-netFIELD-websocket-tabs-content").children().hide();
$("#" + tab.id).show();
}
});
tabs.addTab({
id: "netFIELD-websocket-tab-connection",
label: "Connection"
});
tabs.addTab({
id: "netFIELD-websocket-tab-security",
label: "Authorization"
});
setTimeout(function() { tabs.resize(); },10);
}
});
</script>
<script type="text/html" data-template-name="websocket-config">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
<br />
<br />
</div>
<div class="form-row">
<ul style="min-width: 600px; margin-bottom: 20px;" id="node-config-netFIELD-websocket-tabs"></ul>
</div>
<div id="node-config-netFIELD-websocket-tabs-content" style="min-height:150px;">
<div id="netFIELD-websocket-tab-connection" style="display:none">
<div class="form-row">
<label for="node-config-input-apiendpoint"><i class="fa fa-globe"></i> URL</label>
<input type="text" id="node-config-input-apiendpoint" placeholder="wss://api.netfield.io">
<br />
<br />
<label for="node-config-input-inactivitytimeout"><i class="fa fa-globe"></i> Timeout Period [s]</label>
<input type="text" id="node-config-input-inactivitytimeout" placeholder="30">
</div>
</div>
<div id="netFIELD-websocket-tab-security" style="display:none">
<div class="form-row">
<label for="node-config-input-authorization"><i class="fa fa-key"></i> Key</label>
<input type="text" id="node-config-input-authorization" placeholder="e.g. eyJhbGciOiJIUzI1NiIsInR5cCI69.eyJ1SWQiO...">
</div>
</div>
</div>
</script>