forked from noble/node-bluetooth-hci-socket
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (30 loc) · 972 Bytes
/
Copy pathindex.js
File metadata and controls
33 lines (30 loc) · 972 Bytes
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
33
const os = require('os');
const platform = os.platform();
function loadDriver (driverType) {
switch (driverType) {
case 'uart':
return require('./lib/uart.js');
case 'usb':
return require('./lib/usb.js');
case 'native':
return require('./lib/native.js');
case 'default':
return getDefaultDriver();
default:
return require('./lib/unsupported.js');
}
}
// Default driver selection logic
function getDefaultDriver () {
if (process.env.BLUETOOTH_HCI_SOCKET_UART_PORT || process.env.BLUETOOTH_HCI_SOCKET_FORCE_UART) {
return loadDriver('uart');
} else if (process.env.BLUETOOTH_HCI_SOCKET_FORCE_USB || platform === 'win32' || platform === 'freebsd') {
return loadDriver('usb');
} else if (platform === 'linux' || platform === 'android') {
return loadDriver('native');
} else {
return loadDriver('unsupported');
}
}
module.exports = loadDriver('default');
module.exports.loadDriver = loadDriver;