Skip to content

Commit

Permalink
Merge pull request #35 from a3qz/manufacturer-listing
Browse files Browse the repository at this point in the history
Create Manufacturer Listing Feature in findbutton
  • Loading branch information
hortinstein authored Jul 27, 2016
2 parents 40b0905 + 5cd36fa commit 36e0990
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bin/findbutton
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ process.env.NODE_ENV = 'test'

var int_array_to_hex = require('../index.js').int_array_to_hex;
var create_session = require('../index.js').create_session;
var manufacturer_directory = require('../stor.js').manufacturer_directory;
var pcap = require('pcap');
var arp_interface = undefined;
var last_argument = process.argv[process.argv.length - 1];
Expand All @@ -13,14 +14,18 @@ if (last_argument.indexOf('findbutton') === -1) {
}
var pcap_session = create_session(arp_interface);

console.log("Watching for arp requests on your local network, please try to press your dash now");
console.log("Watching for arp requests on your local network, please try to press your dash now\nDash buttons should appear as manufactured by 'Amazon Technologies Inc.' ");

pcap_session.on('packet', function(raw_packet) {
var packet = pcap.decode.packet(raw_packet); //decodes the packet
if(packet.payload.ethertype === 2054) { //ensures it is an arp packet
possible_dash = packet.payload.payload.sender_ha.addr; //getting the hardware address of the possible dash
possible_dash = int_array_to_hex(possible_dash);
console.log("possible dash hardware address detected: ", possible_dash);
possible_dash = packet.payload.payload.sender_ha.addr; //getting the hardware address of the possible dash
possible_dash = int_array_to_hex(possible_dash);
if(manufacturer_directory.hasOwnProperty(possible_dash.slice(0,8).toString().toUpperCase().split(':').join('')
)){
console.log("Possible dash hardware address detected: ", possible_dash, " Manufacturer: ", manufacturer_directory[possible_dash.slice(0,8).toString().toUpperCase().split(':').join('')]);
} else {
console.log("Possible dash hardware address detected: ", possible_dash, " Manufacturer: ", "unknown");
}
}
});

5 changes: 5 additions & 0 deletions stor.js

Large diffs are not rendered by default.

0 comments on commit 36e0990

Please sign in to comment.