Get or set Bluetooth state on OS X systems
$ npm install --save osx-bluetooth
const osxBluetooth = require('osx-bluetooth');
osxBluetooth.isOn().then(state => {
console.log(state);
//=> false
});
osxBluetooth.on().then(() => {
console.log('Bluetooth state changed to on');
});
osxBluetooth.off().then(() => {
console.log('Bluetooth state changed to off');
});
osxBluetooth.toggle().then(() => {
console.log('Bluetooth state changed to on');
});
Check if bluetooth is on or off. Returns a promise for a boolean.
Turn bluetooth on. Returns a promise.
Turn bluetooth off. Returns a promise.
Toggle the bluetooth state. Returns a promise.
Type: boolean
Force a state when toggling.
See the bluetooth CLI.
MIT © Andreas Gillström