-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnr-rf24input.html
138 lines (131 loc) · 6.26 KB
/
nr-rf24input.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
<script type="text/x-red" data-template-name="RF24input">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" />
</div>
<div class="form-row">
<label for="node-input-radio"><i class="fa fa-microchip"></i> Radio</label>
<input type="text" id="node-input-radio" />
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<input type="text" id="node-input-topic">
</div>
<div class="form-row">
<label for="node-input-pipeaddress"><i class="fa fa-key"></i> Remote Addr</label>
<input type="text" id="node-input-pipeaddress"
placeholder="Pipe address are 5 byte(40-bit) Hex number 0xhhhhhhhhhh"
style="width: 60%;"/>
</div>
<div class="form-row">
<label for="node-input-autoack"><i class="fa fa-check"></i> Auto Ack</label>
<input type="checkbox" id="node-input-autoack" style="width: 60%;" />
</div>
<div class="form-row">
<label for="node-input-outputstring"><i class="fa fa-check"></i> As string</label>
<input type="checkbox" id="node-input-outputstring" style="width: 60%;" />
</div>
<div class="form-row">
<label for="node-input-hidestats"><i class="fa fa-check"></i> Hide stats</label>
<input type="checkbox" id="node-input-hidestats" style="width: 60%;" />
</div>
<div class="form-row">
<label for="node-input-mergeframes"><i class="fa fa-archive"></i> Merge frames</label>
<input type="text" id="node-input-mergeframes">
</div>
<div class="form-row">
<label for="node-input-mergetimeout"><i class="fa fa-clock-o"></i> Merge timeout</label>
<input type="text" id="node-input-mergetimeout">
</div>
<div class="form-tips">
<b>Tip:</b>
<p>Remote address must be a 5 byte(40-bit) Hex number with format 0xhhhhhhhhhh</p>
<p>Merge Frames: Merge consecutive # frames within timeout(ms) defined.</p>
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType("RF24input", {
category: "nRF24l01",
color:"#A6BBCF",
icon:"radio.png",
defaults: {
name: {value:"", required: false},
topic: {value:"nrf24", required: false},
radio: {type:"RF24radio", required: true},
outputstring:{value:false, required: true},
hidestats: { value:false, required: true},
pipeaddress:{ value:"0x65646f4e31", required: true, validate: function(v){
return v.length==12 && v[0]=="0" && v[1].toUpperCase()=="X" && !isNaN(parseInt(v,16));
}},
autoack: {value:true , required: true},
mergeframes: {value:"1",required:true, validate: function(v) {
var n=parseInt(v);
return !isNaN(n) && n>=1 && n<=256;
}},
mergetimeout: {value:"1000",required:true, validate: function(v) {
var n=parseInt(v);
return !isNaN(n) && n>=10;
}}
},
inputs:0,
outputs:1,
label: function() {
return this.name ? this.name : "nRF24input";
},
labelStyle: function() { return this.name ? "node_label_italic" : "";},
outputLabels: ["Incoming Payloads"]
});
</script>
<script type="text/x-red" data-help-name="RF24input">
<p>Plain RF24 input node</p>
<p> This node enables node-red to receive nrf24 payloads. Once a payload
this node emitts a new message. Radio payloads are binary <code>Buffers</code> set on
output's <code>msg.payload</code> property.
</p>
<h3>Configuration</h3>
<ul>
<li><code>Name</code> - Name of the node for identification</li>
<li><code>Radio</code> - Radio node to use (reference to configuration node) </li>
<li><code>Topic</code> - Topic set in the output message <code>msg.topic</code></li>
<li><code>Remote Addr</code> - Listen to payloads on this nrf24l01 pipe address. Must be a a 40bit hex number with the following format:<code>0xhhhhhhhhhh</code></li>
<li><code>Auto Ack</code> - Configure the receiveing pipe to respond with <code>ACK</code> to sender.</li>
<li><code>As string</code> - tries to convert to string the radio payload</li>
<li><code>Hide stats</code> - Hides stats on node status bar</li>
<li><code>Merge frames</code> - Maximun number of frames to merge. if <code>1</code> no merge will be done</li>
<li><code>Merge time</code> - Max time in milliseconds avaiable to merge frames. Apply if <code>Merge frames</code>i is >1</li>
</ul>
<h3>Outputs</h3>
<ul>
<li><code>msg.payload</code> - <i>Buffer</i> - radio frame or merged frames</li>
<li><code>msg.topic</code> - <i>string</i> - configured topic</li>
<li><code>msg.pipeID</code> - <i>number</i> - internal nrf24l01 pipe number</li>
<li><code>msg.pipAddress</code> - <i>string</i> - configured input pipe address in hex format </li>
</ul>
<h3>Details</h3>
<p> Merging logic enable better streaming performance. To enable merging <code>Merge frames</code> should
be set with the expected number of frames in the period defined in <code>Merge time</code> in milliseconds.
If mergin is configured the node will emitt new message over the output when the number of
received frames is equal to <code>Merge frames</code> or if the at least one frame has been received in the
specified timeout. This imply that the there is <b>no guarantees</b> that the each msg.payload has the seam size or
number of frames merged are allways the same in each event.
</p>
<p> If more than one input nodes are used on the same radio.
All pipes address must share the first 4 bytes and only the last byte can be different.
For example if on input node is configured as <code>0xAB0035FF01</code> other
inputs nodes must have be configured with an address like <code>0xAB0035FFxx</code>
where <code>xx</code> is and address byte different from <code>01</code>.
<b>This limitation is due to hardware and can not changed</b>
</p>
<p>
When the radio receive a frame the input node will output a Node-RED message on it's output with the following structure:
<code>
{ _msgid: "...." ,
topic: "<configured topic>",
pipeID: <id number>,
pipeAddress: "00xhhhhhhhhhh with the pipe Address",
payload: <Buffer with the data> or "<string with the data>" if 'output as string is selected'
}
</code>
</p>
</script>
</script>