-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmeshtastic-msg.html
More file actions
475 lines (449 loc) · 18.1 KB
/
Copy pathmeshtastic-msg.html
File metadata and controls
475 lines (449 loc) · 18.1 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
<script type="text/javascript">
//-----------------------------------------------------------------------------
//Send text messages node
RED.nodes.registerType("meshtastic-msg-send", {
category: "Meshtastic",
color: "#67ea94",
defaults: {
name: { value: "" },
device: { value: "", type: "meshtastic-msg-device" },
},
inputs: 1,
outputs: 0,
icon: "Mesh_Logo_White.svg",
paletteLabel: "send text",
label: function () {
return this.name || "msh send text";
},
});
//-----------------------------------------------------------------------------
//Receive text messages node
RED.nodes.registerType("meshtastic-msg-receive", {
category: "Meshtastic",
color: "#67ea94",
defaults: {
name: { value: "" },
device: { value: "", type: "meshtastic-msg-device" },
},
inputs: 0,
outputs: 1,
icon: "Mesh_Logo_White.svg",
paletteLabel: "receive text",
label: function () {
return this.name || "msh receive text";
},
});
//-----------------------------------------------------------------------------
//Device status node
RED.nodes.registerType("meshtastic-msg-status", {
category: "Meshtastic",
color: "#67ea94",
defaults: {
name: { value: "" },
device: { value: "", type: "meshtastic-msg-device" },
},
inputs: 0,
outputs: 1,
icon: "Mesh_Logo_White.svg",
paletteLabel: "receive status",
label: function () {
return this.name || "msh receive status";
},
});
//-----------------------------------------------------------------------------
//Receive generic event node
RED.nodes.registerType("meshtastic-msg-receiveevent", {
category: "Meshtastic",
color: "#67ea94",
defaults: {
name: { value: "" },
device: { value: "", type: "meshtastic-msg-device" },
event: { value: "onDeviceStatus", required: true },
},
inputs: 0,
outputs: 1,
icon: "Mesh_Logo_White.svg",
paletteLabel: "receive event",
label: function () {
return this.name || "msh receive event";
},
oneditprepare: function (optionsList) {
$("#node-input-event").typedInput({
types: [
{
value: "event",
//Someday I need to populate this automatically
options: [
{
value: "onAtakForwarderPacket",
label: "onAtakForwarderPacket",
},
{ value: "onAtakPacket", label: "onAtakPacket" },
{ value: "onAtakPluginPacket", label: "onAtakPluginPacket" },
{ value: "onAudioPacket", label: "onAudioPacket" },
{
value: "onCannedMessageModulePacket",
label: "onCannedMessageModulePacket",
},
{ value: "onChannelPacket", label: "onChannelPacket" },
{
value: "onClientNotificationPacket",
label: "onClientNotificationPacket",
},
{ value: "onConfigPacket", label: "onConfigPacket" },
{
value: "onDetectionSensorPacket",
label: "onDetectionSensorPacket",
},
{ value: "onDeviceDebugLog", label: "onDeviceDebugLog" },
{
value: "onDeviceMetadataPacket",
label: "onDeviceMetadataPacket",
},
{ value: "onDeviceStatus", label: "onDeviceStatus" },
{ value: "onFromRadio", label: "onFromRadio" },
{ value: "onIpTunnelPacket", label: "onIpTunnelPacket" },
{ value: "onLogEvent", label: "onLogEvent" },
{ value: "onLogRecord", label: "onLogRecord" },
{ value: "onMapReportPacket", label: "onMapReportPacket" },
{ value: "onMeshHeartbeat", label: "onMeshHeartbeat" },
{ value: "onMeshPacket", label: "onMeshPacket" },
{ value: "onMessagePacket", label: "onMessagePacket" },
{ value: "onModuleConfigPacket", label: "onModuleConfigPacket" },
{ value: "onMyNodeInfo", label: "onMyNodeInfo" },
{ value: "onNeighborInfoPacket", label: "onNeighborInfoPacket" },
{ value: "onNodeInfoPacket", label: "onNodeInfoPacket" },
{ value: "onPaxcounterPacket", label: "onPaxcounterPacket" },
{
value: "onPendingSettingsChange",
label: "onPendingSettingsChange",
},
{ value: "onPingPacket", label: "onPingPacket" },
{ value: "onPositionPacket", label: "onPositionPacket" },
{ value: "onPrivatePacket", label: "onPrivatePacket" },
{ value: "onQueueStatus", label: "onQueueStatus" },
{ value: "onRangeTestPacket", label: "onRangeTestPacket" },
{
value: "onRemoteHardwarePacket",
label: "onRemoteHardwarePacket",
},
{ value: "onRoutingPacket", label: "onRoutingPacket" },
{ value: "onSerialPacket", label: "onSerialPacket" },
{ value: "onSimulatorPacket", label: "onSimulatorPacket" },
{ value: "onStoreForwardPacket", label: "onStoreForwardPacket" },
{ value: "onTelemetryPacket", label: "onTelemetryPacket" },
{ value: "onTraceRoutePacket", label: "onTraceRoutePacket" },
{ value: "onUserPacket", label: "onUserPacket" },
{ value: "onWaypointPacket", label: "onWaypointPacket" },
{ value: "onZpsPacket", label: "onZpsPacket" },
],
},
],
});
},
});
//-----------------------------------------------------------------------------
//Send generic packet node
RED.nodes.registerType("meshtastic-msg-sendpacket", {
category: "Meshtastic",
color: "#67ea94",
defaults: {
name: { value: "" },
device: { value: "", type: "meshtastic-msg-device" },
},
inputs: 1,
outputs: 0,
icon: "Mesh_Logo_White.svg",
paletteLabel: "send packet",
label: function () {
return this.name || "msh send packet";
},
});
//-----------------------------------------------------------------------------
//Receive Meshtastic.js log node
RED.nodes.registerType("meshtastic-msg-log", {
category: "Meshtastic",
color: "#67ea94",
defaults: {
name: { value: "" },
device: { value: "", type: "meshtastic-msg-device" },
},
inputs: 0,
outputs: 1,
icon: "Mesh_Logo_White.svg",
paletteLabel: "log",
label: function () {
return this.name || "msh log";
},
});
//-----------------------------------------------------------------------------
//Meshtastic device configuration node
RED.nodes.registerType("meshtastic-msg-device", {
category: "config",
defaults: {
fetch_interval: { value: 5000, required: true },
address: { value: "meshtastic.local", required: true },
connection_mode: { value: "http", required: true },
log_level: { value: "3", required: true },
},
label: function () {
if (this.connection_mode == "serial") return "serial: " + this.address;
else return this.connection_mode + "://" + this.address;
},
oneditprepare: function () {
$("#node-config-input-connection_mode").typedInput({
types: [
{
value: "http",
options: [
{ value: "http", label: "http" },
{ value: "https", label: "https (TLS)" },
{ value: "serial", label: "serial" },
],
},
],
});
$("#node-config-input-address").typedInput({
type: "str",
types: ["str"],
});
$("#node-config-input-fetch_interval").typedInput({
type: "num",
types: ["num"],
});
$("#node-config-input-log_level").typedInput({
types: [
{
value: "3",
options: [
{ value: "0", label: "0: Everything" },
{ value: "1", label: "1: Trace" },
{ value: "2", label: "2: Debug" },
{ value: "3", label: "3: Info" },
{ value: "4", label: "4: Warn" },
{ value: "5", label: "5: Error" },
{ value: "6", label: "6: Fatal" },
],
},
],
});
},
});
</script>
<!------------------------------------------------------------------------------------------->
<!-- Send text messages node -->
<script type="text/html" data-template-name="meshtastic-msg-send">
<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>
<div class="form-row">
<label for="node-input-device"
><i class="fa fa-tag"></i> Meshtastic device</label
>
<input type="text" id="node-input-device" placeholder="" />
</div>
</script>
<!------------------------------------------------------------------------------------------->
<!-- Receive text messages node -->
<script type="text/html" data-template-name="meshtastic-msg-receive">
<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>
<div class="form-row">
<label for="node-input-device"
><i class="fa fa-tag"></i> Meshtastic device</label
>
<input type="text" id="node-input-device" placeholder="" />
</div>
</script>
<!------------------------------------------------------------------------------------------->
<!-- Receive status node -->
<script type="text/html" data-template-name="meshtastic-msg-status">
<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>
<div class="form-row">
<label for="node-input-device"
><i class="fa fa-tag"></i> Meshtastic device</label
>
<input type="text" id="node-input-device" placeholder="" />
</div>
</script>
<!------------------------------------------------------------------------------------------->
<!-- Receive generic event -->
<script type="text/html" data-template-name="meshtastic-msg-receiveevent">
<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>
<div class="form-row">
<label for="node-input-device"
><i class="fa fa-tag"></i> Meshtastic device</label
>
<input type="text" id="node-input-device" placeholder="" />
</div>
<div class="form-row">
<label for="node-input-event"><i class="fa fa-tag"></i> Event</label>
<input type="text" id="node-input-event" placeholder="" />
</div>
</script>
<!------------------------------------------------------------------------------------------->
<!-- Send packet -->
<script type="text/html" data-template-name="meshtastic-msg-sendpacket">
<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>
<div class="form-row">
<label for="node-input-device"
><i class="fa fa-tag"></i> Meshtastic device</label
>
<input type="text" id="node-input-device" placeholder="" />
</div>
</script>
<!------------------------------------------------------------------------------------------->
<!-- Receive Meshtastic.js log node -->
<script type="text/html" data-template-name="meshtastic-msg-log">
<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>
<div class="form-row">
<label for="node-input-device"
><i class="fa fa-tag"></i> Meshtastic device</label
>
<input type="text" id="node-input-device" placeholder="" />
</div>
</script>
<!------------------------------------------------------------------------------------------->
<!-- Meshtastic device configuration node -->
<script type="text/html" data-template-name="meshtastic-msg-device">
<div class="form-row">
<label for="node-config-input-connection_mode"
><i class="fa fa-tag"></i> Connection mode</label
>
<input type="text" id="node-config-input-connection_mode" />
</div>
<div class="form-row">
<label for="node-config-input-address"
><i class="fa fa-tag"></i> IP, hostname or device</label
>
<input
type="text"
id="node-config-input-address"
placeholder="meshtastic.local"
/>
</div>
<div class="form-row">
<label for="node-config-input-fetch_interval"
><i class="fa fa-tag"></i> Fetch interval (ms)</label
>
<input
type="text"
id="node-config-input-fetch_interval"
placeholder="5000"
/>
</div>
<div class="form-row">
<label for="node-config-input-log_level"
><i class="fa fa-tag"></i> Log level</label
>
<input type="text" id="node-config-input-log_level" placeholder="3" />
</div>
</script>
<!------------------------------------------------------------------------------------------->
<!-- Send text message node -->
<script type="text/markdown" data-help-name="meshtastic-msg-send">
Send a text message to the mesh connected device
### Input
: msg.payload (string) : the text message to be sent to the network
: _msg.channel_ (integer): the Meshtastic channel number. Defaults to 0 (primary)
: _msg.destination_ (integer): the destination node number, _broadcast_ or _self_. Defaults to _broadcast_
: _msg.wantAck_ (boolean): if the receiving devices should acknowldege receipt. Defaults to _true_
</script>
<!------------------------------------------------------------------------------------------->
<!-- Receive text message node -->
<script type="text/markdown" data-help-name="meshtastic-msg-receive">
Receive a text message from the mesh connected device
### Outputs
: msg (json) : object with all package properties
: msg.payload (string): text content of the message
</script>
<!------------------------------------------------------------------------------------------->
<!-- Receive status node -->
<script type="text/markdown" data-help-name="meshtastic-msg-status">
Receive the status code of the Meshtastic device
### Outputs
: msg (json) : object with all status data
: msg.payload (integer): status code of the device
: msg.text (text): status label
### Status codes
- 0: idle
- 1: restarting
- 2: disconnected
- 3: connecting
- 4: reconnecting
- 5: connected
- 6: configuring
- 7: configured
- 8: error
</script>
<!------------------------------------------------------------------------------------------->
<!-- Receive generic event node -->
<script type="text/markdown" data-help-name="meshtastic-msg-receiveevent">
This node will watch for the defined event and output the payload received.
Typically, the output should be a JSON field but there are some events that report numbers or simple strings.
The events list comes from [Mesthastic.js Event System Class](https://js.meshtastic.org/classes/Utils.EventSystem.html)
### Settings
: event (string): select the event to monitor/watch
### Outputs
: msg (json): data from the event
</script>
<!------------------------------------------------------------------------------------------->
<!-- Send generic packet node -->
<script type="text/markdown" data-help-name="meshtastic-msg-sendpacket">
Send a packet to the mesh connected device.
Input packet can be either in the string format (_msg.payload_) or Uint8Array (_msg.byteData_) format.
### Input
: msgpayload (string): Will be converted to Uint8Array and used if _byteData_ field is not set
: _msg.byteData_ (json) : Data properly encoded as Uint8Array. If set, will be used instead of _payload_. Example [72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33]
: _msg.portNum_ (integer): Application number. Defaults to 1 (text messsage app)
: _msg.destination_ (integer string): Destination node number, _broadcast_ or _self_. Detaults to _broadcast_
: _msg.channel_ (integer): Channel number, defaults to _0_ (primary)
: _msg.wantAck_ (boolean): Confirmation, defaults to _true_
: _msg.wantResponse_ (boolean): Defaults to _false_
: _msg.echoResponse_ (boolean): Defaults to _false_
: _msg.replyId_ (integer): Defaults to _null_
: _msg.emoji_ (integer): Defaults to _null_
</script>
<!------------------------------------------------------------------------------------------->
<!-- Receive Meshtastic.js log node -->
<script type="text/markdown" data-help-name="meshtastic-msg-log">
Output the log from [Mesthastic.js](https://js.meshtastic.org) library. Usefull for debug purposes and connection status info.
**Note:** This is not Node-RED log neither the Lora device log.
### Outputs
: msg (json) : object with all log message properties
: msg.payload (string): text content of the log entry (fields \[0\] and \[1\] concatenated)
</script>
<!------------------------------------------------------------------------------------------->
<!-- Meshtastic device configuration node -->
<script type="text/markdown" data-help-name="meshtastic-msg-device">
This will setup the connection to the Meshtastic node.
The connection protocol can be HTTP or serial. Bluetooth or MQTT are not supported yet.
### Options
- `Connection mode`: Select the type of the connection. Default is _http_.
- `IP, hostname or device` (string) : IP address, hostname or device of the Meshtastic radio to connect. Examples: _192.168.0.15_, _meshtastic.local_, _/dev/ttyUSB0_
- `Fetch interval` (integer): Interval between polling data from the device. Default is _5000ms_.
- `Log level` (integer): Default is _3_. Recommended for production is _5_
### Log levels
- 0: everything
- 1: trace
- 2: debug
- 3: info
- 4: warn
- 5: error
- 6: fatal
</script>