forked from lsongdev/node-bluetooth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (29 loc) · 907 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const EventEmitter = require('events');
const BluetoothSerialPort = require('bindings')('BluetoothSerialPort.node');
/**
* [Bluetooth description]
*/
class Bluetooth extends EventEmitter {
/**
* [connect description]
* @param {[type]} address [description]
* @param {[type]} channel [description]
* @param {Function} callback [description]
* @return {[type]} [description]
*/
static connect(address, channel, callback) {
const { BTSerialPortBinding } = BluetoothSerialPort;
const port = new BTSerialPortBinding(address, channel, function (err) {
callback && callback(err, new Bluetooth.Connection(port, address));
}, callback);
return port;
}
}
Bluetooth.DeviceINQ = require('./lib/device');
Bluetooth.Connection = require('./lib/connection');
/**
* [exports description]
* @type {[type]}
*/
module.exports = Bluetooth;