node-dash-button
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -22,3 +22,6 @@ "use strict"; | ||
//Function to register the node button | ||
var register = function(mac_addresses, arp_interface) { | ||
var register = function(mac_addresses, arp_interface, timeout) { | ||
if (timeout === undefined || timeout === null) { | ||
timeout = 5000; | ||
} | ||
if (Array.isArray(mac_addresses)){ | ||
@@ -64,3 +67,3 @@ //console.log("array detected") | ||
just_emitted[mac_address] = true; | ||
setTimeout(function () { just_emitted[mac_address] = false; }, 3000); | ||
setTimeout(function () { just_emitted[mac_address] = false; }, timeout); | ||
} | ||
@@ -67,0 +70,0 @@ }); |
{ | ||
"name": "node-dash-button", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "a module for integrating amazon dash button presses into a node project", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -51,3 +51,3 @@ ![Blank Dash](http://i.imgur.com/PP0CJ3s.png?1) | ||
For a single dash | ||
**For a single dash** | ||
``` js | ||
@@ -63,3 +63,3 @@ //warning this may trigger multiple times for one press | ||
For multiple dashes: | ||
**For multiple dashes**: | ||
```js | ||
@@ -77,3 +77,3 @@ var dash_button = require('node-dash-button'); | ||
Binding To Specific Interface: | ||
**Binding To Specific Interface**: | ||
By default, the dash button is bound to the [first device with an address](https://github.com/mranney/node_pcap/blob/master/pcap_binding.cc#L89). To bind the button to a specific interface, such as `eth6`, pass the name of the interface as the 2nd argument to the invocation method. | ||
@@ -88,2 +88,13 @@ ``` js | ||
**Adjusting the Timeout (if multiple presses are detected)**: | ||
By default the timeout between presses is 5 seconds. Depending on the network this may not be enough. Use the following syntax to specify a new timeout in miliseconds: | ||
``` js | ||
var dash_button = require('node-dash-button'); | ||
var dash = dash_button("8f:3f:20:33:54:44", null, 60000); //address from step above | ||
dash.on("detected", function (){ | ||
console.log("omg found - on eth6!"); | ||
}); | ||
``` | ||
#### Running Tests: | ||
@@ -90,0 +101,0 @@ Due to the use of pcap permiscuous monitoring this was difficult to test in CI environments, so I ended up making two testing suites. One uses the live pcap library and does actual packet capturing/arp injections. The other uses [mockery](https://github.com/mfncooper/mockery) to fake pcap packets. I will have an upcoming blog post on how I did this, because it was interesting. |
@@ -95,3 +95,12 @@ process.env.NODE_ENV = 'test'; | ||
}); | ||
it('should adjust the timeout', function(done) { | ||
try { | ||
dash_button.register(hexes.first, null, 5000); | ||
pcap.getSession().emit('packet', packets.bad); | ||
} catch(err) { | ||
throw new Error("Did not catch the error"); | ||
} | ||
done(); | ||
}); | ||
}; | ||
startTests(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100414
349
139