hortinstein / node-dash-button

A small module to emit events when an Amazon Dash Button is pressed
949 stars 94 forks source link

Spurious and delayed events with multiple buttons #57

Open avparker opened 6 years ago

avparker commented 6 years ago

I have registered for the event for 3 buttons by passing an array of mac addresses (code below). I often see one or more of the following (often in combination)

Example scenario from my real testing

Another scenario from my real testing

Any idea what's going on? I am running inside an ubuntu 16.04 (xenial) chroot on an Asus Chromebook C302, with node version 8.3.0.

var b_wilkinson = 'b4:7c:9c:92:26:5b';
var b_attack = '34:d2:70:9d:60:31';
var b_genki = 'b4:7c:9c:31:e0:9d';

var dash = dash_button([b_wilkinson, b_attack, b_genki], 'wlan0', '3000', 'udp');

dash.on("detected", function (dash_id){
  if (dash_id === b_wilkinson) {
    console.log("*** WILKINSON ***");
  } else if (dash_id === b_attack) {
    console.log("*** ATTACK ***");
  } else if (dash_id === b_genki) {
    console.log("*** GENKI ***");
  }
  console.log("  detected at " + new Date().toLocaleString());
});`
avparker commented 6 years ago

I have reproduced the same behaviour with another version of the same script running on a ODROID C2 (ARM based, similar to a Raspberry Pi), running Ubuntu 16.04, Node version 8.2.1.

If I run the script on the two machines at the same time, the events are usually but not always printed at the same time. i.e. One machine will detect the button, but the other won't.

Furthermore, I hacked the bin/findbutton script, and ran it at the same time as the above app using node-dash-button (on the chromebook). Occasionally either the findbutton script or the app will print the event but the other won't print it until some other button is pressed (the app removes duplicates thanks to the code in node-dash-button, which the findbutton script doesn't).

I have also tried detecting only a single button (i.e. not passing an array), and also see similar behaviour.

I can only guess that the pcap "events" are getting "stuck" in a queue of some sort.