|
Version0 /
BLE Module'''This page is no longer being maintained, see VersionCurrent/BLE The BLE module allows accessors to connect to Bluetooth Low Energy peripherals. Using BLE requires hardware support. Newer Mac laptops should work, otherwise a USB BLE dongle will work as well. API
ExampleGet advertisements:
var ble = require('ble');
var bleDevice = new ble();
bleDevice.scan([], null, null, function (peripheral) {
print('Found peripheral with name: ' + peripheral.name);
});
Connect to device and get a characteristic:
var helper = require('helper');
var ble = require('ble');
var bleDevice = new ble();
var token = bleDevice.scan(['abcd'], null, null, function (peripheral) {
print('Found peripheral with name: ' + peripheral.name);
bleDevice.scanStop(token);
bleDevice.connect(peripheral, function () {
bleDevice.discoverServices(peripheral, function (services) {
helper.forEach(services, function (service) {
bleDevice.discoverCharacteristics(service, function (characteristics) {
helper.forEach(characteristics, function (characteristic) {
bleDevice.readCharacteristic(characteristic, function (value) {
print('Got value from characteristic: ' + value);
});
});
});
});
});
});
});
Stay Connected to a device that advertises the service "ff11" and has name "BestBLE":
var ble = require('ble');
var bleDevice = new ble();
bleDevice.stayConnected('ff11', 'BestBLE', null, function (peripheral) {
...
}, function () {
...disconnected...
}, function () {
...error...
});
Back to Optional JavaScript Modules |