Skip to content

Commit

Permalink
Added the possibility to list bluetooth interfaces. (#20)
Browse files Browse the repository at this point in the history
* Integrated abilities to bring an interface up and spoof a MAC address.

* Fixed indentation.

* Removed a useless part which brought up an interface before attempting to spoof a MAC address.

* Added the possibility to list bluetooth interfaces.
  • Loading branch information
narke authored and virtualabs committed Jun 16, 2017
1 parent 4b7d3ed commit 3a76ac4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions bin/cmd_btlejuice.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ parser.addArgument(['-m', '--mac'], {
help: 'Spoof the MAC address with a new one',
required: false,
});
parser.addArgument(['-l', '--list'], {
help: 'List bluetooth interfaces',
required: false,
action: 'storeTrue',
default: false
});


args = parser.parseArgs();

Expand Down Expand Up @@ -136,6 +143,41 @@ if (args.mac != null && args.iface != null) {
}
}

if (args.list) {
function display_interface(item) {
for (property in item) {
console.log(util.format('%s\tType: %s Bus: %s BD Address: %s ' +
'ACL MTU: %s SCO MTU: %s\n\t%s\n\t' +
'RX: bytes: %s ACL: %s SCO: %s events: %s errors: %s\n\t' +
'TX: bytes: %s ACL: %s SCO: %s events: %s errors: %s\n',
property,
item[property]['Type'],
item[property]['Bus'],
item[property]['BD Address'],
item[property]['ACL MTU'],
item[property]['SCO MTU'],
item[property]['status'],
item[property]['RX']['bytes'],
item[property]['RX']['ACL'],
item[property]['RX']['SCO'],
item[property]['RX']['events'],
item[property]['RX']['errors'],
item[property]['TX']['bytes'],
item[property]['TX']['ACL'],
item[property]['TX']['SCO'],
item[property]['TX']['events'],
item[property]['TX']['errors']).bold);
}
}

console.log(util.format('[info] Listing bluetooth interfaces...\n').green);
var interfaces = JSON.parse('[' + btim.list() + ']');

for (var i = 0; i < interfaces.length; i++) {
display_interface(interfaces[i]);
}
}

/* Set advertisement interval to minimum value (20ms). */
process.env.BLENO_ADVERTISING_INTERVAL = 20;

Expand Down

0 comments on commit 3a76ac4

Please sign in to comment.