forked from gtalusan/node-red-contrib-ignoble
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathignoble-node.html
244 lines (228 loc) · 7.08 KB
/
ignoble-node.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<script type="text/javascript">
RED.nodes.registerType('scanner', {
category: 'Bluetooth',
color: '#a6bbcf',
defaults: {
name: {
value: ""
},
timeout: {
value: 5000,
validate: function(v) {
return v >= 5000;
},
required: true
}
},
inputs: 1,
outputs: 1,
icon: "bluetooth.png",
label: function() {
return this.name || "scanner";
}
});
</script>
<script type="text/x-red" data-template-name="scanner">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="icon-tag"></i> Scan time</label>
<input type="text" id="node-input-timeout" placeholder="Time in milliseconds">
</div>
</script>
<script type="text/x-red" data-help-name="scanner">
<p>A node that performs a BLE scan for peripherals in the vicinity. Hook up a trigger to it and set the scan time!</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('peripheral', {
category: 'Bluetooth',
color: '#a6bbcf',
defaults: {
name: {
value: ""
},
mac: {
value: "",
required: true
},
timeout: {
value: 10000,
validate: function(v) {
return v >= 0;
},
required: true
}
},
inputs: 1,
outputs: 2,
icon: "bluetooth.png",
label: function() {
return this.name || "peripheral";
}
});
</script>
<script type="text/x-red" data-template-name="peripheral">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-mac"><i class="icon-tag"></i> MAC Address</label>
<input type="text" id="node-input-mac" placeholder="MAC Address">
</div>
<div class="form-row">
<label for="node-input-timeout"><i class="icon-tag"></i> Timeout</label>
<input type="text" id="node-input-timeout" placeholder="Timeout">
</div>
</script>
<script type="text/x-red" data-help-name="peripheral">
<p>A BLE node that matches a peripheral with a MAC address, performs a connection and interrogates it for services.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span>
</dt>
<dd> the output of a scanner node</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>connected
<dl class="message-properties">
<dt />
<dd> this port is called when services have been discovered</dd>
</dl>
</li>
<li>disconnected
<dl class="message-properties">
<dt />
<dd> this port is called when the peripheral has been disconnected</dd>
</dl>
</li>
</ol>
<h3>Details</h3>
<p>Hook this up to a scanner!</p>
<p>Set the timeout to 0 so that it will stay connected forever and you can subscribe to characteristic notification changes!</p>
<p>Use the <code>disconnected</code> output port to re-trigger a scan in the case of an unwanted disconnection, or to connect to another peripheral!</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('service', {
category: 'Bluetooth',
color: '#a6bbcf',
defaults: {
name: {
value: ""
}
},
inputs: 1,
outputs: 1,
icon: "bluetooth.png",
label: function() {
return this.name || "service";
}
});
</script>
<script type="text/x-red" data-template-name="service">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="service">
<p>A BLE node that shunts a peripheral's services to a characteristic node. Hook this up to a peripheral!</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('characteristic', {
category: 'Bluetooth',
color: '#a6bbcf',
defaults: {
name: {
value: ""
},
uuid: {
value: "",
required: true
},
subscribe: {
value: false
}
},
inputs: 1,
outputs: 1,
icon: "bluetooth.png",
label: function() {
return this.name || this.uuid || "characteristic";
}
});
</script>
<script type="text/x-red" data-template-name="characteristic">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-uuid"><i class="icon-tag"></i> UUID</label>
<input type="text" id="node-input-uuid" placeholder="UUID">
</div>
<div class="form-row">
<label for="node-input-subscribe"><i class="icon-tag"></i> Subscribe</label>
<input type="checkbox" id="node-input-subscribe" placeholder="Subscribe">
</div>
</script>
<script type="text/x-red" data-help-name="characteristic">
<p>A BLE node that matches a service's characteristic by UUID</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span>
</dt>
<dd> the output of a service node</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>
<dl class="message-properties">
<dt />
<dd> this port is called when the characteristic has been read</dd>
</dl>
</li>
</ol>
<h3>Details</h3>
<p>Hook this up to a service!</p>
<p>If the characteristic is notifiable then <code>subscribe</code> to it and don't forget to set the peripheral timeout to 0.</p>
<p>Use the output port to daisy chain <code>characteristic</code> nodes so they can be read sequentially.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('characteristic out', {
category: 'Bluetooth',
color: '#a6bbcf',
defaults: {
name: {
value: ""
},
uuid: {
value: "",
required: true
}
},
align: 'right',
inputs: 1,
outputs: 0,
icon: "bluetooth.png",
label: function() {
return this.name || this.uuid || "characteristic";
}
});
</script>
<script type="text/x-red" data-template-name="characteristic out">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-uuid"><i class="icon-tag"></i> UUID</label>
<input type="text" id="node-input-uuid" placeholder="UUID">
</div>
</script>
<script type="text/x-red" data-help-name="characteristic out">
<p>A BLE node that matches a service's characteristic by UUID. Hook this up to a service! You can use this node to write msg.payload to the characteristic! Make sure that the characteristic on your BLE peripheral has enough room for the data contained in msg.payload!</p>
</script>