Skip to content

Commit 73e4ae5

Browse files
author
Dave Conway-Jones
committed
Set WOL node to use more generic broadcast address byt default
1 parent 7113598 commit 73e4ae5

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

io/wol/39-wol.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<input type="text" id="node-input-mac" placeholder="e.g. DE:AD:BE:EF:FE:ED">
66
</div>
77
<div class="form-row">
8-
<label for="node-input-host"><i class="fa fa-globe"></i> Host Address</label>
9-
<input type="text" id="node-input-host" placeholder="e.g. 255.255.255.255">
8+
<label for="node-input-host"><i class="fa fa-globe"></i> Target Address</label>
9+
<input type="text" id="node-input-host" placeholder="e.g. 192.168.1.255 or 10.255.255.255">
1010
</div>
1111
<div class="form-row">
1212
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
@@ -18,7 +18,9 @@
1818
<script type="text/x-red" data-help-name="wake on lan">
1919
<p>Sends a Wake-On-LAN magic packet to the mac address specified.</p>
2020
<p>You may instead set <code>msg.mac</code> to dynamically set the target device mac to wake up.</p>
21-
<p>The target host address can optionally be set using <code>msg.host</code></p>
21+
<p>The address of the target machine can optionally be set using <code>msg.host</code></p>
22+
<p>Setting the target address to the broadcast address of the subnet that the target machine is attached to works best.
23+
For a class C address this is usually just the first three parts of the ip address followed by 255. eg 192.168.1.255.</p>
2224
</script>
2325

2426
<script type="text/javascript">

io/wol/39-wol.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ module.exports = function(RED) {
1313
this.on("input", function(msg) {
1414
var mac = this.mac || msg.mac || null;
1515
var host = this.host || msg.host || '255.255.255.255';
16+
var h = host.split('.');
17+
h.pop();
18+
h.push('255');
19+
host = h.join('.');
1620
if (mac != null) {
1721
if (chk.test(mac)) {
1822
try {
@@ -35,7 +39,7 @@ module.exports = function(RED) {
3539
}
3640
else { node.warn("WOL: no mac address specified"); }
3741
});
38-
42+
3943
this.on("close", function () {
4044
node.status({});
4145
})

io/wol/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name" : "node-red-node-wol",
3-
"version" : "0.0.9",
3+
"version" : "0.0.10",
44
"description" : "A Node-RED node to send Wake-On-LAN (WOL) magic packets",
55
"dependencies" : {
66
"wake_on_lan" : "1.0.0"

0 commit comments

Comments
 (0)