Use MuseClient in Node.js
masterSince muse-js relies on the Web Bluetooth API, you must use a package like bleat to emulate Web Bluetooth in a Node.js environment. This requires noble to handle the underlying Bluetooth hardware. You should wait for the noble state to be poweredOn before attempting to request a device and connecting the MuseClient to the GATT server.
const noble = require('noble');
const bluetooth = require('bleat').webbluetooth;
async function connect() {
let device = await bluetooth.requestDevice({
filters: [{ services: [MUSE_SERVICE] }]
});
const gatt = await device.gatt.connect();
const client = new MuseClient();
await client.connect(gatt);
await client.start();
// Now do whatever with muse client...
}
noble.on('stateChange', (state) => {
if (state === 'poweredOn') {
connect();
}
});