Skip to content

Conversation

programmarchy
Copy link
Contributor

This add support for listing already paired devices:

var BluetoothSerialPort = require("bluetooth-serial-port").BluetoothSerialPort;
var serial = new BluetoothSerialPort();

serial.listPairedDevices(function(pairedDevices) {
    pairedDevices.forEach(function(device) {
        console.log(device);
    });
});

Will print something like:

{ name: 'Moss-CMB',
  address: '00-04-3e-31-c9-d6',
  services: 
   [ { channel: 1, name: 'AMP-SPP' },
     { channel: 2, name: 'AMP-iAP' } ] }
{ name: 'Phi',
  address: '58-b0-35-98-c8-92',
  services: 
   [ { channel: 4, name: 'Headset Audio Gateway' },
     { channel: 4, name: 'Network Access Point Service' },
     { channel: 4, name: 'A2DP Audio Source' },
     { channel: 4, name: 'AVRCP Target' },
     { channel: 4, name: 'Apple Macintosh Attributes' },
     { channel: 10, name: 'OBEX Object Push' },
     { channel: 3, name: 'Bluetooth-Incoming-Port' },
     { channel: 15, name: 'OBEX File Transfer' },
     { channel: 2, name: 'Hands Free Audio Gateway' },
     { channel: 2, name: 'Group Ad-hoc Network Service' } ] }
{ name: 'MINIJAMBOX by Jawbone',
  address: 'e0-d1-e6-05-6b-3b',
  services: 
   [ { channel: 2, name: undefined },
     { channel: 3, name: 'Headset' },
     { channel: 3, name: undefined },
     { channel: 3, name: undefined },
     { channel: 1, name: 'SPP Dev' },
     { channel: 1, name: undefined },
     { channel: 2, name: 'Hands-Free unit' } ] }
{ name: 'Donald Ness\'s Trackpad',
  address: 'c8-bc-c8-fc-21-de',
  services: 
   [ { channel: 2, name: 'Apple Wireless Trackpad' },
     { channel: 2, name: undefined } ] }

So far, only support for OS X has been added. Linux and Windows are stubbed out, and return an empty array.

On OS X, this also makes it possible to find devices which already have a baseband connection established -- i.e. a device is connected to another app, or has auto-reconnected on its own to the host. Currently, connected devices do not appear in an inquiry, but can be listed from the paired devices list.

Also, connecting directly from the paired devices list is much quicker than performing a full discovery / inquiry.

@eelcocramer
Copy link
Owner

Useful. Will test and pull soon.

Thank you.

@eelcocramer eelcocramer merged commit 8219cf8 into eelcocramer:master Jun 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants