potentially expanding to something that could be used like this:
dash_button = require('node-dash-button');
var dash = dash_button(["8f:3f:20:33:54:44","2e:3f:20:33:54:22"]); //address from step above
dash.on("8f:3f:20:33:54:44", function (){
console.log("omg found");
});
dash.on("2e:3f:20:33:54:22", function (){
console.log("omg found the other one!");
});
thoughts?
It looks like Amazon has ruined everything by changing the Dash application. The application will no longer save the WiFi credentials to the Dash if you don't complete the "this is what I want to order" step.
I tried this today and it worked fine. Instead of clicking "cancel" links in the app at step 3 I simply force quit the app.
import registerDashButton from 'node-dash-button';
import { toggleLights } from './lib/lights.js';
var lightSwitch = registerDashButton("74:c2:46:0c:4a:c9");
console.log("Listening for Dash button presses...");
lightSwitch.on("detected", () => {
console.log("Light switch pressed.", new Date());
toggleLights(1);
});
var lightSwitch = registerDashButton("74:c2:46:0c:4a:c9");
var playButton = registerDashButton("aa:bb:cc:dd:ee:ff");
lightSwitch.on("detected", () => { /* light switch stuff */ })
playButton.on("detected", () => { /* play button stuff */ })
import DashButtonListener from 'node-dash-button';
var dashButtonListener = new DashButtonListener(); //init pcap here, establish instance context
var lightSwitch = dashButtonListener.register("aa:bb:cc:dd:ee:ff");
var playButton = dashButtonListener.register("dd:ee:ff:aa:bb:cc");
process.setgid
/process.setuid
to drop root privileges.. but that doesn’t seem to put you in the same user space as launching an app as that user. somehow.