forked from clausbroch/node-red-contrib-noble-bluetooth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbluetooth.html
More file actions
executable file
·244 lines (228 loc) · 9.08 KB
/
Copy pathbluetooth.html
File metadata and controls
executable file
·244 lines (228 loc) · 9.08 KB
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("BLE scanner", {
category: "Bluetooth",
color: "#4d94ff",
defaults: {
name: { value: "" },
services: { value: "", validate: RED.validators.typedInput("servicesType") },
servicesType: { value: "str" },
continuous: { value: false },
duplicate: { value: false },
},
inputs: 1,
outputs: 1,
icon: "bluetooth.png",
label: function () {
return this.name || "BLE scanner";
},
oneditprepare: function () {
$("#node-input-services").typedInput({
default: "str",
typeField: $("#node-input-servicesType"),
types: ["str", "json"],
});
},
});
</script>
<script type="text/x-red" data-template-name="BLE scanner">
<div class="form-row">
<label for="node-input-services"><i class="fa fa-envelope"></i> Services</label>
<input type="text" id="node-input-services" style="width: 70%">
<input type="hidden" id="node-input-servicesType">
</div>
<div class="form-row">
<label for="node-input-continuous"> </label>
<input type="checkbox" id="node-input-continuous" style="display:inline-block; width:22px; vertical-align:baseline;">Continuous scanning
</div>
<div class="form-row">
<label for="node-input-duplicate"> </label>
<input type="checkbox" id="node-input-duplicate" style="display:inline-block; width:22px; vertical-align:baseline;">Duplicate scanning result
</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="BLE scanner">
<p>A bluetooth scanner node that will scan for devices in the vicinity.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>topic <span class="property-type">string</span></dt>
<dd>Define the scanner action. Must be either <code>start</code> or <code>stop</code></dd>
<dt class="optional">
services
<span class="property-type">array | string</span>
</dt>
<dd>Only scan for devices advertising these service UUID's.</dd>
<dt class="optional">
continuous
<span class="property-type">boolean</span>
</dt>
<dd>Set to <code>true</code> to continue scanning after discovering first device. <code>false</code> by default</dd>
<dt class="optional">
duplicate
<span class="property-type">boolean</span>
</dt>
<dd>Set to <code>true</code> to duplicate scanning result. <code>false</code> by default</dd>
<dt class="optional">
timeout
<span class="property-type">number</span>
</dt>
<dd>Timeout in milliseconds after which the scanner is automatically stopped</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>peripheral <span class="property-type">string</span></dt>
<dd>Internal reference for the discovered peripheral. Must be passed on to other BLE nodes</dd>
<dt>address <span class="property-type">string</span></dt>
<dd>The bluetooth MAC address of the peripheral</dd>
<dt>rssi <span class="property-type">number</span></dt>
<dd>The received signal strength (RSSI)</dd>
<dt>txPowerLevel <span class="property-type">number</span></dt>
<dd>The transmitter power level</dd>
<dt class="optional">connectable <span class="property-type">boolean</span></dt>
<dd>Indication if the peripheral is accepting connection</dd>
<dt class="optional">name <span class="property-type">string</span></dt>
<dd>Local name of the peripheral</dd>
<dt class="optional">manufacturerData <span class="property-type">buffer</span></dt>
<dd>Vendor specific data</dd>
<dt class="optional">services <span class="property-type">array</span></dt>
<dd>List of discovered service UUID's</dd>
<dt class="optional">serviceData <span class="property-type">array</span></dt>
<dd>List of discovered service data</dd>
</dl>
</script>
<script type="text/javascript">
RED.nodes.registerType("BLE device", {
category: "Bluetooth",
color: "#4d94ff",
defaults: {
name: { value: "" },
disconnect: { value: false },
},
inputs: 1,
outputs: 1,
icon: "bluetooth.png",
label: function () {
return this.name || "BLE device";
},
});
</script>
<script type="text/html" data-template-name="BLE device">
<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="BLE device">
<p>A bluetooth node that will connect to a peripheral device found by a BLE scanner node.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>peripheral <span class="property-type">string</span></dt>
<dd>Peripheral reference received from a BLE scanner node</dd>
<dt class="optional">disconnect <span class="property-type">boolean</span></dt>
<dd>Set to <code>true</code> to disconnect peripheral. <code>false</code> by default</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>topic <span class="property-type">string</span></dt>
<dd>Will be either <code>connected</code> or <code>disconnected</code></dd>
<dt>connected <span class="property-type">boolean</span></dt>
<dd>Status if currently connected to the peripheral</dd>
<dt class="optional">rssi <span class="property-type">number</span></dt>
<dd>The received signal strength (RSSI)</dd>
<dt class="optional">services <span class="property-type">array</span></dt>
<dd>List of discovered services</dd>
<dt class="optional">charateristics <span class="property-type">array</span></dt>
<dd>List of discovered charateristics</dd>
</dl>
</script>
<script type="text/javascript">
RED.nodes.registerType("BLE in", {
category: "Bluetooth",
color: "#4d94ff",
defaults: {
topic: { value: "" },
characteristic: { value: "" },
name: { value: "" },
},
inputs: 1,
outputs: 1,
icon: "bluetooth.png",
label: function () {
return this.name || "BLE in";
},
});
</script>
<script type="text/html" data-template-name="BLE in">
<div class="form-row">
<label for="node-input-topic" style="width: 120px"><i class="fa fa-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic" />
</div>
<div class="form-row">
<label for="node-input-characteristic" style="width: 120px"><i class="fa fa-envelope"></i> Characteristic</label>
<input type="text" id="node-input-characteristic" placeholder="Characteristic UUID" />
</div>
<div class="form-row">
<label for="node-input-name" style="width: 120px"><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="BLE in">
<p>A bluetooth node that will read or subscribe to data from a BLE peripheral.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>peripheral <span class="property-type">string</span></dt>
<dd>Peripheral reference received from a BLE scanner node</dd>
<dt>characteristic <span class="property-type">string</span></dt>
<dd>Characteristic UUID to read or subscribe to</dd>
<dt>topic <span class="property-type">string</span></dt>
<dd>Must be either <code>read</code>, <code>subscribe</code> or <code>unsubscribe</code></dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">buffer</span></dt>
<dd>Data received from the device</dd>
<dt>characteristic <span class="property-type">object</span></dt>
<dd>Characteristic the data originated from</dd>
</dl>
</script>
<script type="text/javascript">
RED.nodes.registerType("BLE out", {
category: "Bluetooth",
color: "#4d94ff",
defaults: {
characteristic: { value: "" },
name: { value: "" },
},
inputs: 1,
outputs: 0,
align: "right",
icon: "bluetooth.png",
label: function () {
return this.name || "BLE out";
},
});
</script>
<script type="text/html" data-template-name="BLE out">
<div class="form-row">
<label for="node-input-characteristic" style="width: 120px"><i class="fa fa-envelope"></i> Characteristic</label>
<input type="text" id="node-input-characteristic" placeholder="Characteristic UUID" />
</div>
<div class="form-row">
<label for="node-input-name" style="width: 120px"><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="BLE out">
<p>A bluetooth node that will write data to a BLE peripheral.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>peripheral <span class="property-type">string</span></dt>
<dd>Peripheral reference received from a BLE scanner node</dd>
<dt>characteristic <span class="property-type">object</span></dt>
<dd>Characteristic to read or subscribe to</dd>
<dt>payload <span class="property-type">buffer | string</span></dt>
<dd>data to write to the device</dd>
</dl>
</script>