Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed your readme #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@

Bluetooth serial port communication for Node.js


### Requirements

**This package require `node-gyp` installed .**
**This package requires `node-gyp` to be installed.**

#### Linux

You'll need libbluetooth-dev. On Ubuntu/Debian : ``` $ sudo apt-get install libbluetooth-dev```
You'll need `libbluetooth-dev` On Ubuntu/Debian : ``` $ sudo apt-get install libbluetooth-dev```

### Installation

```bash
$ npm install node-bluetooth --save
```

### Example
### Examples

#### create device
#### Create device
```js
const bluetooth = require('node-bluetooth');

// create bluetooth device instance
// Create a bluetooth device instance
const device = new bluetooth.DeviceINQ();
```

#### list already paired devices
#### List already paired devices
```js
device.listPairedDevices(console.log);
```
will output
Output:
```js
➜ node-bluetooth git:(master) ✗ node example/index.js
[ { name: 'Lsong’s Trackpad',
Expand All @@ -46,7 +45,7 @@ will output
```


#### find devices
#### Find devices

```js
device
Expand All @@ -55,24 +54,20 @@ device
console.log('Found: ' + address + ' with name ' + name);
}).scan();
```

will output

Output:
```
➜ node-bluetooth git:(master) ✗ node example/index.js
Found: 22-22-a3-0d-63-09 with name Meizu MX4 Pro
Found: dc-2b-2a-82-76-29 with name Lsong's iPhone
Found: 38-bc-1a-37-2d-d4 with name MEIZU MX5
finished
```

find serial port channel

Find serial port channel
```js
device.findSerialPortChannel(address, function(channel){
console.log('Found RFCOMM channel for serial port on %s: ', name, channel);

// make bluetooth connect to remote device
// Connect to a remote device
bluetooth.connect(address, channel, function(err, connection){
if(err) return console.error(err);
connection.write(new Buffer('Hello!', 'utf-8'), () => {
Expand All @@ -82,11 +77,9 @@ device.findSerialPortChannel(address, function(channel){

});
```

create connection to device, read and write

Create connection to a device, read and write
```js
// make bluetooth connect to remote device
// Connect to a remote device
bluetooth.connect(address, channel, function(err, connection){
if(err) return console.error(err);

Expand Down