nubert-bluetooth

0.1.0 • Public • Published

Nubert Bluetooth Control 🔊

Bluetooth control of Nubert nuPro X speakers using Node.js. For implementing similar controls in other languages, the bluetooth codes are listed in the constants.js file. Tested with Node v8.

Installation

npm install nubert-bluetooth

Getting Started

 
// Specify local name of the speaker (same as in the nuPro App)
var nubert = require('./index.js')({
    localName: 'nubert X-4 8C12',
});
 
// Connect via Bluetooth LE
nubert.connect(() => console.log('connected'));
 
// After connection is etablished...
nubert.setSource('aux');
nubert.setVolume(-43);
 
// Read changes (for example from the remote control)
nubert.subscribe(event => {
    if (event['type'] === 'volume') {
        console.log('Volume changed');
    }
});

API

 
var nubert = require('./index.js')({
    localName: 'nubert X-4 8C12',
});

You need to call the connect method first.

 
nubert.connect(() => console.log('connected')); // Specify a callback after connection is established
 
// Disconnect from the speakers
nubert.disconnect();

High-level API

There are a couple of high-level APIs for controlling the Nubert speakers.

nubert.powerOn();
nubert.powerOff();
nubert.setVolume(-38);
nubert.setMute();
nubert.unsetMute();
nubert.setSource('opto2'); // Possible sources are: 'aux', 'opto1', 'opto2', 'xlr', 'usb', 'port', 'coax1', 'coax2'.

Low-level API

If the high-level API is not sufficient for your needs, you can use the low-level API. Then, you can control everything that can be controled also via the nuPro app or the infrared remote.

Constants

A list of all bluetooth flags / constants can be found in the constants.js file.

Send

 
nubert.send(type, command);
 
// Some examples using constants:
nubert.send(nubert.BASS_ADJUST_SET, 0x16);
nubert.send(nubert.DISPLAY_LIGHT_SET, nubert.SET_FALSE);

Subscribe

 
nubert.subscribe(callback(data));
 
// Some examples using constants:
nubert.subscribe((data) => {
    console.log('read:', data);
    if (data['type_raw'] === nubert.DISPLAY_LIGHT_GET) {
        console.log('Somebody changed the display light setting.');
    }
});

License

Nubert-Bluetooth is under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i nubert-bluetooth

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

12.7 kB

Total Files

8

Last publish

Collaborators

  • pantor